[jOOQ/jOOQ#12465] Move MIN, MAX, COUNT, SUM, AVG to API generator

This commit is contained in:
Lukas Eder 2021-09-23 11:58:14 +02:00
parent a5533230c5
commit fa286e821f
6 changed files with 547 additions and 90 deletions

View File

@ -0,0 +1,92 @@
/*
* 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
*
* http://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: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
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.DataExtendedKey.*;
import static org.jooq.impl.Tools.DataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Record;
import org.jooq.conf.*;
import org.jooq.impl.*;
import org.jooq.tools.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
import java.math.BigDecimal;
/**
* The <code>AVG</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unused" })
final class Avg
extends
AbstractAggregateFunction<BigDecimal>
{
Avg(
Field<? extends Number> field,
boolean avgDistinct
) {
super(
avgDistinct,
N_AVG,
NUMERIC,
nullSafeNotNull(field, INTEGER)
);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
public final void accept(Context<?> ctx) {
super.accept(ctx);
}
}

View File

@ -0,0 +1,91 @@
/*
* 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
*
* http://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: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
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.DataExtendedKey.*;
import static org.jooq.impl.Tools.DataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Record;
import org.jooq.conf.*;
import org.jooq.impl.*;
import org.jooq.tools.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
/**
* The <code>COUNT</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unused" })
final class Count
extends
AbstractAggregateFunction<Integer>
{
Count(
Field<?> field,
boolean countDistinct
) {
super(
countDistinct,
N_COUNT,
INTEGER,
nullSafeNotNull(field, OTHER)
);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
public final void accept(Context<?> ctx) {
super.accept(ctx);
}
}

View File

@ -19799,6 +19799,24 @@ public class DSL {
// Aggregate functions
// -------------------------------------------------------------------------
/**
* The <code>AVG</code> function.
*/
@NotNull
@Support
public static AggregateFunction<BigDecimal> avg(Field<? extends Number> field) {
return new Avg(field, false);
}
/**
* The <code>AVG_DISTINCT</code> function.
*/
@NotNull
@Support
public static AggregateFunction<BigDecimal> avgDistinct(Field<? extends Number> field) {
return new Avg(field, true);
}
/**
* The <code>BIT_AND_AGG</code> function.
* <p>
@ -19846,6 +19864,24 @@ public class DSL {
return new Corr(y, x);
}
/**
* The <code>COUNT</code> function.
*/
@NotNull
@Support
public static AggregateFunction<Integer> count(Field<?> field) {
return new Count(field, false);
}
/**
* The <code>COUNT_DISTINCT</code> function.
*/
@NotNull
@Support
public static AggregateFunction<Integer> countDistinct(Field<?> field) {
return new Count(field, true);
}
/**
* The <code>COVAR_SAMP</code> function.
* <p>
@ -19874,6 +19910,24 @@ public class DSL {
return new CovarPop(y, x);
}
/**
* The <code>MAX</code> function.
*/
@NotNull
@Support
public static <T> AggregateFunction<T> max(Field<T> field) {
return new Max(field, false);
}
/**
* The <code>MAX_DISTINCT</code> function.
*/
@NotNull
@Support
public static <T> AggregateFunction<T> maxDistinct(Field<T> field) {
return new Max(field, true);
}
/**
* The <code>MEDIAN</code> function.
*/
@ -19883,6 +19937,24 @@ public class DSL {
return new Median(field);
}
/**
* The <code>MIN</code> function.
*/
@NotNull
@Support
public static <T> AggregateFunction<T> min(Field<T> field) {
return new Min(field, false);
}
/**
* The <code>MIN_DISTINCT</code> function.
*/
@NotNull
@Support
public static <T> AggregateFunction<T> minDistinct(Field<T> field) {
return new Min(field, true);
}
/**
* The <code>REGR_AVGX</code> function.
* <p>
@ -20037,6 +20109,24 @@ public class DSL {
return new StddevSamp(field);
}
/**
* The <code>SUM</code> function.
*/
@NotNull
@Support
public static AggregateFunction<BigDecimal> sum(Field<? extends Number> field) {
return new Sum(field, false);
}
/**
* The <code>SUM_DISTINCT</code> function.
*/
@NotNull
@Support
public static AggregateFunction<BigDecimal> sumDistinct(Field<? extends Number> field) {
return new Sum(field, true);
}
/**
* The <code>VAR_POP</code> function.
* <p>
@ -23597,15 +23687,6 @@ public class DSL {
return count(DefaultAggregateFunction.ASTERISK);
}
/**
* Get the count(field) function.
*/
@NotNull
@Support
public static AggregateFunction<Integer> count(Field<?> field) {
return new DefaultAggregateFunction<>(N_COUNT, SQLDataType.INTEGER, Tools.nullSafe(field));
}
/**
* Get the count(field) function.
*/
@ -23628,15 +23709,6 @@ public class DSL {
return new CountTable(table, false);
}
/**
* Get the count(distinct field) function.
*/
@NotNull
@Support
public static AggregateFunction<Integer> countDistinct(Field<?> field) {
return new DefaultAggregateFunction<>(true, N_COUNT, SQLDataType.INTEGER, Tools.nullSafe(field));
}
/**
* Get the count(distinct field) function.
*/
@ -24994,60 +25066,6 @@ public class DSL {
/**
* Get the max value over a field: max(field).
*/
@NotNull
@Support
public static <T> AggregateFunction<T> max(Field<T> field) {
return new DefaultAggregateFunction<>(N_MAX, Tools.nullSafeDataType(field), Tools.nullSafe(field));
}
/**
* Get the max value over a field: max(distinct field).
*/
@NotNull
@Support
public static <T> AggregateFunction<T> maxDistinct(Field<T> field) {
return new DefaultAggregateFunction<>(true, N_MAX, Tools.nullSafeDataType(field), Tools.nullSafe(field));
}
/**
* Get the min value over a field: min(field).
*/
@NotNull
@Support
public static <T> AggregateFunction<T> min(Field<T> field) {
return new DefaultAggregateFunction<>(N_MIN, Tools.nullSafeDataType(field), Tools.nullSafe(field));
}
/**
* Get the min value over a field: min(distinct field).
*/
@NotNull
@Support
public static <T> AggregateFunction<T> minDistinct(Field<T> field) {
return new DefaultAggregateFunction<>(true, N_MIN, Tools.nullSafeDataType(field), Tools.nullSafe(field));
}
/**
* Get the sum over a numeric field: sum(field).
*/
@NotNull
@Support
public static AggregateFunction<BigDecimal> sum(Field<? extends Number> field) {
return new DefaultAggregateFunction<>(N_SUM, SQLDataType.NUMERIC, Tools.nullSafe(field));
}
/**
* Get the sum over a numeric field: sum(distinct field).
*/
@NotNull
@Support
public static AggregateFunction<BigDecimal> sumDistinct(Field<? extends Number> field) {
return new DefaultAggregateFunction<>(true, N_SUM, SQLDataType.NUMERIC, Tools.nullSafe(field));
}
/**
* Get the product over a numeric field: product(field).
@ -25087,24 +25105,6 @@ public class DSL {
return new Product(true, Tools.nullSafe(field));
}
/**
* Get the average over a numeric field: avg(field).
*/
@NotNull
@Support
public static AggregateFunction<BigDecimal> avg(Field<? extends Number> field) {
return new DefaultAggregateFunction<>(N_AVG, SQLDataType.NUMERIC, Tools.nullSafe(field));
}
/**
* Get the average over a numeric field: avg(distinct field).
*/
@NotNull
@Support
public static AggregateFunction<BigDecimal> avgDistinct(Field<? extends Number> field) {
return new DefaultAggregateFunction<>(true, N_AVG, SQLDataType.NUMERIC, Tools.nullSafe(field));
}
/**
* The <code>mode(field)</code> aggregate function.
*/

View File

@ -0,0 +1,91 @@
/*
* 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
*
* http://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: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
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.DataExtendedKey.*;
import static org.jooq.impl.Tools.DataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Record;
import org.jooq.conf.*;
import org.jooq.impl.*;
import org.jooq.tools.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
/**
* The <code>MAX</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
final class Max<T>
extends
AbstractAggregateFunction<T>
{
Max(
Field<T> field,
boolean maxDistinct
) {
super(
maxDistinct,
N_MAX,
Tools.nullSafeDataType(field),
nullSafeNotNull(field, (DataType) OTHER)
);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
public final void accept(Context<?> ctx) {
super.accept(ctx);
}
}

View File

@ -0,0 +1,91 @@
/*
* 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
*
* http://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: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
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.DataExtendedKey.*;
import static org.jooq.impl.Tools.DataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Record;
import org.jooq.conf.*;
import org.jooq.impl.*;
import org.jooq.tools.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
/**
* The <code>MIN</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
final class Min<T>
extends
AbstractAggregateFunction<T>
{
Min(
Field<T> field,
boolean minDistinct
) {
super(
minDistinct,
N_MIN,
Tools.nullSafeDataType(field),
nullSafeNotNull(field, (DataType) OTHER)
);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
public final void accept(Context<?> ctx) {
super.accept(ctx);
}
}

View File

@ -0,0 +1,92 @@
/*
* 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
*
* http://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: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
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.DataExtendedKey.*;
import static org.jooq.impl.Tools.DataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Record;
import org.jooq.conf.*;
import org.jooq.impl.*;
import org.jooq.tools.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
import java.math.BigDecimal;
/**
* The <code>SUM</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unused" })
final class Sum
extends
AbstractAggregateFunction<BigDecimal>
{
Sum(
Field<? extends Number> field,
boolean sumDistinct
) {
super(
sumDistinct,
N_SUM,
NUMERIC,
nullSafeNotNull(field, INTEGER)
);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
public final void accept(Context<?> ctx) {
super.accept(ctx);
}
}