diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractAggregateFunction.java b/jOOQ/src/main/java/org/jooq/impl/AbstractAggregateFunction.java index 97bb00b9f0..0ee6044719 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractAggregateFunction.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractAggregateFunction.java @@ -222,7 +222,7 @@ implements /** * Render function arguments and argument modifiers */ - private final void toSQLArguments(Context ctx) { + final void toSQLArguments(Context ctx) { acceptFunctionName(ctx); ctx.sql('('); acceptArguments0(ctx); diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index 6be3029e2f..a41a0d58d0 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -24915,6 +24915,54 @@ public class DSL { return new Product(field, true); } + /** + * The PERCENTILE_CONT function. + *

+ * Calculate the PERCENTILE_CONT inverse distribution aggregate function. + * + * @param percentile is wrapped as {@link DSL#val(Object)}. + */ + @NotNull + @Support({ DUCKDB, H2, MARIADB, POSTGRES, YUGABYTEDB }) + public static OrderedAggregateFunction percentileCont(Number percentile) { + return new PercentileCont(Tools.field(percentile)); + } + + /** + * The PERCENTILE_CONT function. + *

+ * Calculate the PERCENTILE_CONT inverse distribution aggregate function. + */ + @NotNull + @Support({ DUCKDB, H2, MARIADB, POSTGRES, YUGABYTEDB }) + public static OrderedAggregateFunction percentileCont(Field percentile) { + return new PercentileCont(percentile); + } + + /** + * The PERCENTILE_DISC function. + *

+ * Calculate the PERCENTILE_DISC inverse distribution aggregate function. + * + * @param percentile is wrapped as {@link DSL#val(Object)}. + */ + @NotNull + @Support({ DUCKDB, H2, MARIADB, POSTGRES, YUGABYTEDB }) + public static OrderedAggregateFunction percentileDisc(Number percentile) { + return new PercentileDisc(Tools.field(percentile)); + } + + /** + * The PERCENTILE_DISC function. + *

+ * Calculate the PERCENTILE_DISC inverse distribution aggregate function. + */ + @NotNull + @Support({ DUCKDB, H2, MARIADB, POSTGRES, YUGABYTEDB }) + public static OrderedAggregateFunction percentileDisc(Field percentile) { + return new PercentileDisc(percentile); + } + /** * The REGR_AVGX function. *

@@ -32330,66 +32378,6 @@ public class DSL { return new DefaultAggregateFunction<>(N_CUME_DIST, SQLDataType.NUMERIC, fields.toArray(EMPTY_FIELD)); } - /** - * The - * percentile_cont([number]) within group (order by [column]) - * function. - *

- * While most dialects support this as an aggregate function, - * {@link SQLDialect#BIGQUERY}, {@link SQLDialect#SQLSERVER}, and - * {@link SQLDialect#REDSHIFT} support only its window function variant. - */ - @NotNull - @Support({ DUCKDB, H2, MARIADB, POSTGRES, YUGABYTEDB }) - public static OrderedAggregateFunction percentileCont(Number number) { - return percentileCont(val(number)); - } - - /** - * The - * percentile_cont([number]) within group (order by [column]) - * function. - *

- * While most dialects support this as an aggregate function, - * {@link SQLDialect#BIGQUERY}, {@link SQLDialect#SQLSERVER}, and - * {@link SQLDialect#REDSHIFT} support only its window function variant. - */ - @NotNull - @Support({ DUCKDB, H2, MARIADB, POSTGRES, YUGABYTEDB }) - public static OrderedAggregateFunction percentileCont(Field field) { - return new DefaultAggregateFunction<>(N_PERCENTILE_CONT, SQLDataType.NUMERIC, Tools.nullSafe(field)); - } - - /** - * The - * percentile_disc([number]) within group (order by [column]) - * function. - *

- * While most dialects support this as an aggregate function, - * {@link SQLDialect#BIGQUERY}, {@link SQLDialect#SQLSERVER}, and - * {@link SQLDialect#REDSHIFT} support only its window function variant. - */ - @NotNull - @Support({ DUCKDB, H2, MARIADB, POSTGRES, YUGABYTEDB }) - public static OrderedAggregateFunction percentileDisc(Number number) { - return percentileDisc(val(number)); - } - - /** - * The - * percentile_disc([number]) within group (order by [column]) - * function. - *

- * While most dialects support this as an aggregate function, - * {@link SQLDialect#BIGQUERY}, {@link SQLDialect#SQLSERVER}, and - * {@link SQLDialect#REDSHIFT} support only its window function variant. - */ - @NotNull - @Support({ DUCKDB, H2, MARIADB, POSTGRES, YUGABYTEDB }) - public static OrderedAggregateFunction percentileDisc(Field field) { - return new DefaultAggregateFunction<>(N_PERCENTILE_DISC, SQLDataType.NUMERIC, Tools.nullSafe(field)); - } - // ------------------------------------------------------------------------- // XXX Window clauses // ------------------------------------------------------------------------- diff --git a/jOOQ/src/main/java/org/jooq/impl/Names.java b/jOOQ/src/main/java/org/jooq/impl/Names.java index 04b55eae91..24cd0e4c60 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Names.java +++ b/jOOQ/src/main/java/org/jooq/impl/Names.java @@ -234,8 +234,6 @@ final class Names { static final Name N_ORDINAL = systemName("ordinal"); static final Name N_OREPLACE = systemName("oreplace"); static final Name N_PARSE_JSON = systemName("parse_json"); - static final Name N_PERCENTILE_CONT = systemName("percentile_cont"); - static final Name N_PERCENTILE_DISC = systemName("percentile_disc"); static final Name N_PERCENT_RANK = systemName("percent_rank"); static final Name N_PIVOT = systemName("pivot"); static final Name N_PLPGSQL = systemName("plpgsql"); @@ -546,6 +544,8 @@ final class Names { static final Name N_OCTET_LENGTH = systemName("octet_length"); static final Name N_OTRANSLATE = systemName("otranslate"); static final Name N_OVERLAY = systemName("overlay"); + static final Name N_PERCENTILE_CONT = systemName("percentile_cont"); + static final Name N_PERCENTILE_DISC = systemName("percentile_disc"); static final Name N_PI = systemName("pi"); static final Name N_POSITION = systemName("position"); static final Name N_POW = systemName("pow"); diff --git a/jOOQ/src/main/java/org/jooq/impl/PercentileCont.java b/jOOQ/src/main/java/org/jooq/impl/PercentileCont.java new file mode 100644 index 0000000000..816d65ebd7 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/PercentileCont.java @@ -0,0 +1,179 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.ParamType; +import org.jooq.tools.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import java.math.BigDecimal; + + +/** + * The PERCENTILE CONT statement. + */ +@SuppressWarnings({ "rawtypes", "unused" }) +final class PercentileCont +extends + AbstractAggregateFunction +implements + QOM.PercentileCont +{ + + PercentileCont( + Field percentile + ) { + super( + false, + N_PERCENTILE_CONT, + NUMERIC, + nullSafeNotNull(percentile, INTEGER) + ); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept(Context ctx) { + switch (ctx.family()) { + + + + + + + + + + + + + + + + + + default: + super.accept(ctx); + break; + } + } + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @SuppressWarnings("unchecked") + @Override + public final Field $percentile() { + return (Field) getArgument(0); + } + + @Override + public final QOM.PercentileCont $percentile(Field newValue) { + return $constructor().apply(newValue); + } + + public final Function1, ? extends QOM.PercentileCont> $constructor() { + return (a1) -> new PercentileCont(a1); + } + + + + + + + + + + + + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.PercentileCont o) { + return + StringUtils.equals($percentile(), o.$percentile()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/PercentileDisc.java b/jOOQ/src/main/java/org/jooq/impl/PercentileDisc.java new file mode 100644 index 0000000000..fed4b6c68a --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/PercentileDisc.java @@ -0,0 +1,179 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.ParamType; +import org.jooq.tools.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import java.math.BigDecimal; + + +/** + * The PERCENTILE DISC statement. + */ +@SuppressWarnings({ "rawtypes", "unused" }) +final class PercentileDisc +extends + AbstractAggregateFunction +implements + QOM.PercentileDisc +{ + + PercentileDisc( + Field percentile + ) { + super( + false, + N_PERCENTILE_DISC, + NUMERIC, + nullSafeNotNull(percentile, INTEGER) + ); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept(Context ctx) { + switch (ctx.family()) { + + + + + + + + + + + + + + + + + + default: + super.accept(ctx); + break; + } + } + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @SuppressWarnings("unchecked") + @Override + public final Field $percentile() { + return (Field) getArgument(0); + } + + @Override + public final QOM.PercentileDisc $percentile(Field newValue) { + return $constructor().apply(newValue); + } + + public final Function1, ? extends QOM.PercentileDisc> $constructor() { + return (a1) -> new PercentileDisc(a1); + } + + + + + + + + + + + + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.PercentileDisc o) { + return + StringUtils.equals($percentile(), o.$percentile()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/QOM.java b/jOOQ/src/main/java/org/jooq/impl/QOM.java index a96f9bdab8..892484b80e 100644 --- a/jOOQ/src/main/java/org/jooq/impl/QOM.java +++ b/jOOQ/src/main/java/org/jooq/impl/QOM.java @@ -8106,6 +8106,7 @@ public final class QOM { */ public /*sealed*/ interface MaxBy extends + QueryPart, org.jooq.OptionallyOrderedAggregateFunction //permits // MaxBy @@ -8172,6 +8173,7 @@ public final class QOM { */ public /*sealed*/ interface MinBy extends + QueryPart, org.jooq.OptionallyOrderedAggregateFunction //permits // MinBy @@ -8229,6 +8231,40 @@ public final class QOM { @NotNull Product $distinct(boolean distinct); } + /** + * The PERCENTILE CONT function. + *

+ * Calculate the PERCENTILE_CONT inverse distribution aggregate function. + */ + public /*sealed*/ interface PercentileCont + extends + QueryPart, + org.jooq.OrderedAggregateFunction + //permits + // PercentileCont + { + @NotNull Field $percentile(); + @CheckReturnValue + @NotNull PercentileCont $percentile(Field percentile); + } + + /** + * The PERCENTILE DISC function. + *

+ * Calculate the PERCENTILE_DISC inverse distribution aggregate function. + */ + public /*sealed*/ interface PercentileDisc + extends + QueryPart, + org.jooq.OrderedAggregateFunction + //permits + // PercentileDisc + { + @NotNull Field $percentile(); + @CheckReturnValue + @NotNull PercentileDisc $percentile(Field percentile); + } + /** * The REGR AVGX function. *