Maria has a median() function

This commit is contained in:
Gavin King 2022-10-07 08:53:00 +02:00
parent bf7a51cb84
commit 2a9f6dafee
2 changed files with 8 additions and 1 deletions

View File

@ -33,6 +33,7 @@ import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl;
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.NUMERIC;
import static org.hibernate.type.SqlTypes.OTHER;
import static org.hibernate.type.SqlTypes.UUID;
@ -87,6 +88,11 @@ public class MariaDBDialect extends MySQLDialect {
.resolve( StandardBasicTypes.BOOLEAN )
);
commonFunctionFactory.inverseDistributionOrderedSetAggregates_windowEmulation();
queryEngine.getSqmFunctionRegistry().patternDescriptorBuilder( "median", "median(?1) over ()" )
.setInvariantType( queryEngine.getTypeConfiguration().getBasicTypeRegistry().resolve( StandardBasicTypes.DOUBLE ) )
.setExactArgumentCount( 1 )
.setParameterTypes(NUMERIC)
.register();
}
@Override

View File

@ -470,7 +470,8 @@ abstract public class DialectFeatureChecks {
public boolean apply(Dialect dialect) {
return !( dialect instanceof MySQLDialect
|| dialect instanceof SybaseDialect
|| dialect instanceof DerbyDialect );
|| dialect instanceof DerbyDialect )
|| dialect instanceof MariaDBDialect;
}
}
}