From 2a9f6dafee38124458e272352d7f921d3bfb6cb1 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Fri, 7 Oct 2022 08:53:00 +0200 Subject: [PATCH] Maria has a median() function --- .../src/main/java/org/hibernate/dialect/MariaDBDialect.java | 6 ++++++ .../hibernate/testing/orm/junit/DialectFeatureChecks.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/MariaDBDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/MariaDBDialect.java index 26158aff94..1f24fd3efe 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/MariaDBDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/MariaDBDialect.java @@ -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 diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DialectFeatureChecks.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DialectFeatureChecks.java index 842c1a8de1..f8594d70df 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DialectFeatureChecks.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DialectFeatureChecks.java @@ -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; } } }