Skip to content

Commit

Permalink
Maria has a median() function
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Oct 7, 2022
1 parent bf7a51c commit 2a9f6da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Expand Up @@ -33,6 +33,7 @@
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;

Expand Down Expand Up @@ -87,6 +88,11 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
.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
Expand Down
Expand Up @@ -470,7 +470,8 @@ public static class SupportsMedian implements DialectFeatureCheck {
public boolean apply(Dialect dialect) {
return !( dialect instanceof MySQLDialect
|| dialect instanceof SybaseDialect
|| dialect instanceof DerbyDialect );
|| dialect instanceof DerbyDialect )
|| dialect instanceof MariaDBDialect;
}
}
}

0 comments on commit 2a9f6da

Please sign in to comment.