From aec7351483dd7dd6b8788adac0a77a1bf9c8aa2f Mon Sep 17 00:00:00 2001 From: Dain Sundstrom Date: Sat, 4 Sep 2021 20:04:34 -0700 Subject: [PATCH] Require aggregation metadata at construction Require full aggregation function metadata during construction of aggregation. Change intermediate types to allow generic type signatures. --- .../metadata/AggregationFunctionMetadata.java | 26 +++++++++++++ .../io/trino/metadata/FunctionRegistry.java | 8 ++-- .../io/trino/metadata/MetadataManager.java | 8 +++- .../metadata/SqlAggregationFunction.java | 39 +++---------------- .../AbstractMinMaxAggregationFunction.java | 26 ++----------- .../AbstractMinMaxNAggregationFunction.java | 15 +++---- .../ArbitraryAggregationFunction.java | 26 ++----------- .../ChecksumAggregationFunction.java | 13 +++---- .../operator/aggregation/CountColumn.java | 12 ++---- .../DecimalAverageAggregation.java | 13 +++---- .../aggregation/DecimalSumAggregation.java | 14 +++---- .../aggregation/MapAggregationFunction.java | 13 ++----- .../aggregation/MapUnionAggregation.java | 13 ++----- .../MergeQuantileDigestFunction.java | 14 +++---- .../aggregation/ParametricAggregation.java | 13 ++----- .../QuantileDigestAggregationFunction.java | 14 +++---- .../aggregation/RealAverageAggregation.java | 18 ++++----- .../ReduceAggregationFunction.java | 12 ++---- .../arrayagg/ArrayAggregationFunction.java | 16 +++----- .../aggregation/histogram/Histogram.java | 13 ++----- .../listagg/ListaggAggregationFunction.java | 17 ++++---- .../minmaxby/AbstractMinMaxBy.java | 22 +++-------- .../AbstractMinMaxByNAggregationFunction.java | 19 ++++----- .../MultimapAggregationFunction.java | 15 +++---- .../sql/planner/plan/AggregationNode.java | 3 +- .../TestAnnotationEngineForAggregates.java | 22 +++++------ 26 files changed, 156 insertions(+), 268 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/metadata/AggregationFunctionMetadata.java b/core/trino-main/src/main/java/io/trino/metadata/AggregationFunctionMetadata.java index 6603ceb9e9e6..a17f8a70daad 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/AggregationFunctionMetadata.java +++ b/core/trino-main/src/main/java/io/trino/metadata/AggregationFunctionMetadata.java @@ -13,11 +13,15 @@ */ package io.trino.metadata; +import io.trino.spi.type.StandardTypes; import io.trino.spi.type.TypeSignature; +import io.trino.spi.type.TypeSignatureParameter; +import java.util.Arrays; import java.util.Optional; import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.collect.ImmutableList.toImmutableList; import static java.util.Objects.requireNonNull; public class AggregationFunctionMetadata @@ -25,6 +29,23 @@ public class AggregationFunctionMetadata private final boolean orderSensitive; private final Optional intermediateType; + public AggregationFunctionMetadata(boolean orderSensitive, TypeSignature... intermediateTypes) + { + this.orderSensitive = orderSensitive; + + if (intermediateTypes.length == 0) { + intermediateType = Optional.empty(); + } + else if (intermediateTypes.length == 1) { + intermediateType = Optional.of(intermediateTypes[0]); + } + else { + intermediateType = Optional.of(new TypeSignature(StandardTypes.ROW, Arrays.stream(intermediateTypes) + .map(TypeSignatureParameter::anonymousField) + .collect(toImmutableList()))); + } + } + public AggregationFunctionMetadata(boolean orderSensitive, Optional intermediateType) { this.orderSensitive = orderSensitive; @@ -36,6 +57,11 @@ public boolean isOrderSensitive() return orderSensitive; } + public boolean isDecomposable() + { + return intermediateType.isPresent(); + } + public Optional getIntermediateType() { return intermediateType; diff --git a/core/trino-main/src/main/java/io/trino/metadata/FunctionRegistry.java b/core/trino-main/src/main/java/io/trino/metadata/FunctionRegistry.java index 6064d9b50d1c..bfa5711261de 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/FunctionRegistry.java +++ b/core/trino-main/src/main/java/io/trino/metadata/FunctionRegistry.java @@ -820,13 +820,13 @@ public FunctionMetadata get(FunctionId functionId) return functions.get(functionId).getFunctionMetadata(); } - public AggregationFunctionMetadata getAggregationFunctionMetadata(FunctionBinding functionBinding) + public AggregationFunctionMetadata getAggregationFunctionMetadata(FunctionId functionId) { - SqlFunction function = functions.get(functionBinding.getFunctionId()); - checkArgument(function instanceof SqlAggregationFunction, "%s is not an aggregation function", functionBinding.getBoundSignature()); + SqlFunction function = functions.get(functionId); + checkArgument(function instanceof SqlAggregationFunction, "%s is not an aggregation function", function.getFunctionMetadata().getSignature()); SqlAggregationFunction aggregationFunction = (SqlAggregationFunction) function; - return aggregationFunction.getAggregationMetadata(functionBinding); + return aggregationFunction.getAggregationMetadata(); } public WindowFunctionSupplier getWindowFunctionImplementation(FunctionBinding functionBinding, FunctionDependencies functionDependencies) diff --git a/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java b/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java index 3fd136c24e51..894677c4eb12 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java +++ b/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java @@ -2397,7 +2397,13 @@ public FunctionMetadata getFunctionMetadata(ResolvedFunction resolvedFunction) @Override public AggregationFunctionMetadata getAggregationFunctionMetadata(ResolvedFunction resolvedFunction) { - return functions.getAggregationFunctionMetadata(toFunctionBinding(resolvedFunction)); + AggregationFunctionMetadata aggregationFunctionMetadata = functions.getAggregationFunctionMetadata(resolvedFunction.getFunctionId()); + return new AggregationFunctionMetadata( + aggregationFunctionMetadata.isOrderSensitive(), + aggregationFunctionMetadata.getIntermediateType().map(typeSignature -> { + FunctionBinding functionBinding = toFunctionBinding(resolvedFunction); + return applyBoundVariables(typeSignature, functionBinding); + })); } @Override diff --git a/core/trino-main/src/main/java/io/trino/metadata/SqlAggregationFunction.java b/core/trino-main/src/main/java/io/trino/metadata/SqlAggregationFunction.java index eb334cd31875..62e46a02056c 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/SqlAggregationFunction.java +++ b/core/trino-main/src/main/java/io/trino/metadata/SqlAggregationFunction.java @@ -16,36 +16,26 @@ import com.google.common.collect.ImmutableList; import io.trino.operator.aggregation.AggregationFromAnnotationsParser; import io.trino.operator.aggregation.InternalAggregationFunction; -import io.trino.spi.type.StandardTypes; -import io.trino.spi.type.TypeSignature; -import io.trino.spi.type.TypeSignatureParameter; import java.util.List; -import java.util.Optional; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.ImmutableList.toImmutableList; -import static com.google.common.collect.Iterables.getOnlyElement; import static java.util.Objects.requireNonNull; public abstract class SqlAggregationFunction implements SqlFunction { private final FunctionMetadata functionMetadata; - private final boolean orderSensitive; - private final boolean decomposable; + private final AggregationFunctionMetadata aggregationFunctionMetadata; public static List createFunctionsByAnnotations(Class aggregationDefinition) { return ImmutableList.copyOf(AggregationFromAnnotationsParser.parseFunctionDefinitions(aggregationDefinition)); } - protected SqlAggregationFunction(FunctionMetadata functionMetadata, boolean decomposable, boolean orderSensitive) + public SqlAggregationFunction(FunctionMetadata functionMetadata, AggregationFunctionMetadata aggregationFunctionMetadata) { this.functionMetadata = requireNonNull(functionMetadata, "functionMetadata is null"); - checkArgument(functionMetadata.isDeterministic(), "Aggregation function must be deterministic"); - this.orderSensitive = orderSensitive; - this.decomposable = decomposable; + this.aggregationFunctionMetadata = requireNonNull(aggregationFunctionMetadata, "aggregationFunctionMetadata is null"); } @Override @@ -54,28 +44,9 @@ public FunctionMetadata getFunctionMetadata() return functionMetadata; } - public AggregationFunctionMetadata getAggregationMetadata(FunctionBinding functionBinding) + public AggregationFunctionMetadata getAggregationMetadata() { - if (!decomposable) { - return new AggregationFunctionMetadata(orderSensitive, Optional.empty()); - } - - List intermediateTypes = getIntermediateTypes(functionBinding); - TypeSignature intermediateType; - if (intermediateTypes.size() == 1) { - intermediateType = getOnlyElement(intermediateTypes); - } - else { - intermediateType = new TypeSignature(StandardTypes.ROW, intermediateTypes.stream() - .map(TypeSignatureParameter::anonymousField) - .collect(toImmutableList())); - } - return new AggregationFunctionMetadata(orderSensitive, Optional.of(intermediateType)); - } - - protected List getIntermediateTypes(FunctionBinding functionBinding) - { - throw new UnsupportedOperationException(); + return aggregationFunctionMetadata; } public InternalAggregationFunction specialize(FunctionBinding functionBinding, FunctionDependencies functionDependencies) diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/AbstractMinMaxAggregationFunction.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/AbstractMinMaxAggregationFunction.java index b851d5e7ed03..49a4f131a7fc 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/AbstractMinMaxAggregationFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/AbstractMinMaxAggregationFunction.java @@ -16,6 +16,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; import io.trino.annotation.UsedByGeneratedCode; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionDependencies; @@ -32,9 +33,6 @@ import io.trino.operator.aggregation.state.GenericDoubleStateSerializer; import io.trino.operator.aggregation.state.GenericLongState; import io.trino.operator.aggregation.state.GenericLongStateSerializer; -import io.trino.operator.aggregation.state.NullableBooleanState; -import io.trino.operator.aggregation.state.NullableDoubleState; -import io.trino.operator.aggregation.state.NullableLongState; import io.trino.operator.aggregation.state.StateCompiler; import io.trino.spi.block.Block; import io.trino.spi.block.BlockBuilder; @@ -104,8 +102,9 @@ protected AbstractMinMaxAggregationFunction(String name, boolean min, String des true, description, AGGREGATE), - true, - false); + new AggregationFunctionMetadata( + false, + new TypeSignature("E"))); this.min = min; } @@ -115,23 +114,6 @@ public FunctionDependencyDeclaration getFunctionDependencies() return getMinMaxCompareFunctionDependencies(new TypeSignature("E"), min); } - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - Type type = functionBinding.getTypeVariable("E"); - if (type.getJavaType() == long.class) { - return ImmutableList.of(StateCompiler.getSerializedType(NullableLongState.class).getTypeSignature()); - } - if (type.getJavaType() == double.class) { - return ImmutableList.of(StateCompiler.getSerializedType(NullableDoubleState.class).getTypeSignature()); - } - if (type.getJavaType() == boolean.class) { - return ImmutableList.of(StateCompiler.getSerializedType(NullableBooleanState.class).getTypeSignature()); - } - // native container type is Slice or Block - return ImmutableList.of(new BlockPositionStateSerializer(type).getSerializedType().getTypeSignature()); - } - @Override public InternalAggregationFunction specialize(FunctionBinding functionBinding, FunctionDependencies functionDependencies) { diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/AbstractMinMaxNAggregationFunction.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/AbstractMinMaxNAggregationFunction.java index 683317e2a442..eb41aa0336b7 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/AbstractMinMaxNAggregationFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/AbstractMinMaxNAggregationFunction.java @@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionDependencies; @@ -30,7 +31,6 @@ import io.trino.spi.block.Block; import io.trino.spi.block.BlockBuilder; import io.trino.spi.type.ArrayType; -import io.trino.spi.type.RowType; import io.trino.spi.type.Type; import io.trino.spi.type.TypeSignature; import io.trino.util.MinMaxCompare; @@ -87,18 +87,13 @@ protected AbstractMinMaxNAggregationFunction(String name, boolean min, String de true, description, AGGREGATE), - true, - false); + new AggregationFunctionMetadata( + false, + BIGINT.getTypeSignature(), + TypeSignature.arrayType(new TypeSignature("E")))); this.min = min; } - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - Type type = functionBinding.getTypeVariable("E"); - return ImmutableList.of(RowType.anonymous(ImmutableList.of(BIGINT, type)).getTypeSignature()); - } - @Override public FunctionDependencyDeclaration getFunctionDependencies(FunctionBinding functionBinding) { diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/ArbitraryAggregationFunction.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/ArbitraryAggregationFunction.java index c329a459c94a..b9e65797c917 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/ArbitraryAggregationFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/ArbitraryAggregationFunction.java @@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -29,9 +30,6 @@ import io.trino.operator.aggregation.state.GenericDoubleStateSerializer; import io.trino.operator.aggregation.state.GenericLongState; import io.trino.operator.aggregation.state.GenericLongStateSerializer; -import io.trino.operator.aggregation.state.NullableBooleanState; -import io.trino.operator.aggregation.state.NullableDoubleState; -import io.trino.operator.aggregation.state.NullableLongState; import io.trino.operator.aggregation.state.StateCompiler; import io.trino.spi.block.Block; import io.trino.spi.block.BlockBuilder; @@ -92,25 +90,9 @@ protected ArbitraryAggregationFunction() true, "Return an arbitrary non-null input value", AGGREGATE), - true, - false); - } - - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - Type type = functionBinding.getTypeVariable("T"); - if (type.getJavaType() == long.class) { - return ImmutableList.of(StateCompiler.getSerializedType(NullableLongState.class).getTypeSignature()); - } - if (type.getJavaType() == double.class) { - return ImmutableList.of(StateCompiler.getSerializedType(NullableDoubleState.class).getTypeSignature()); - } - if (type.getJavaType() == boolean.class) { - return ImmutableList.of(StateCompiler.getSerializedType(NullableBooleanState.class).getTypeSignature()); - } - // native container type is Slice or Block - return ImmutableList.of(new BlockPositionStateSerializer(type).getSerializedType().getTypeSignature()); + new AggregationFunctionMetadata( + false, + new TypeSignature("T"))); } @Override diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/ChecksumAggregationFunction.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/ChecksumAggregationFunction.java index 3d151e8c708b..a576617b2c91 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/ChecksumAggregationFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/ChecksumAggregationFunction.java @@ -16,6 +16,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -44,6 +45,7 @@ import static io.trino.operator.aggregation.AggregationMetadata.ParameterMetadata.ParameterType.NULLABLE_BLOCK_INPUT_CHANNEL; import static io.trino.operator.aggregation.AggregationMetadata.ParameterMetadata.ParameterType.STATE; import static io.trino.operator.aggregation.AggregationUtils.generateAggregationName; +import static io.trino.spi.type.BigintType.BIGINT; import static io.trino.spi.type.VarbinaryType.VARBINARY; import static io.trino.util.Reflection.methodHandle; import static java.util.Objects.requireNonNull; @@ -77,17 +79,12 @@ public ChecksumAggregationFunction(BlockTypeOperators blockTypeOperators) true, "Checksum of the given values", AGGREGATE), - true, - false); + new AggregationFunctionMetadata( + false, + BIGINT.getTypeSignature())); this.blockTypeOperators = requireNonNull(blockTypeOperators, "blockTypeOperators is null"); } - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - return ImmutableList.of(StateCompiler.getSerializedType(NullableLongState.class).getTypeSignature()); - } - @Override public InternalAggregationFunction specialize(FunctionBinding functionBinding) { diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/CountColumn.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/CountColumn.java index 7a16260d6245..c4e86c69f590 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/CountColumn.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/CountColumn.java @@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -72,14 +73,9 @@ public CountColumn() true, "Counts the non-null values", AGGREGATE), - true, - false); - } - - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - return ImmutableList.of(StateCompiler.getSerializedType(LongState.class).getTypeSignature()); + new AggregationFunctionMetadata( + false, + BIGINT.getTypeSignature())); } @Override diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/DecimalAverageAggregation.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/DecimalAverageAggregation.java index a8bc106fad4c..ec9219592512 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/DecimalAverageAggregation.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/DecimalAverageAggregation.java @@ -17,6 +17,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; import io.airlift.slice.Slice; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -57,6 +58,7 @@ import static io.trino.spi.type.Decimals.writeShortDecimal; import static io.trino.spi.type.TypeSignatureParameter.typeVariable; import static io.trino.spi.type.UnscaledDecimal128Arithmetic.UNSCALED_DECIMAL_128_SLICE_LENGTH; +import static io.trino.spi.type.VarbinaryType.VARBINARY; import static io.trino.util.Reflection.methodHandle; import static java.math.BigDecimal.ROUND_HALF_UP; @@ -95,14 +97,9 @@ public DecimalAverageAggregation() true, "Calculates the average value", AGGREGATE), - true, - false); - } - - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - return ImmutableList.of(new LongDecimalWithOverflowAndLongStateSerializer().getSerializedType().getTypeSignature()); + new AggregationFunctionMetadata( + false, + VARBINARY.getTypeSignature())); } @Override diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/DecimalSumAggregation.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/DecimalSumAggregation.java index e5499a6a3166..2780f2d9b879 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/DecimalSumAggregation.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/DecimalSumAggregation.java @@ -16,13 +16,13 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; import io.airlift.slice.Slice; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; import io.trino.metadata.Signature; import io.trino.metadata.SqlAggregationFunction; import io.trino.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor; -import io.trino.operator.aggregation.state.LongDecimalWithOverflowAndLongStateSerializer; import io.trino.operator.aggregation.state.LongDecimalWithOverflowState; import io.trino.operator.aggregation.state.LongDecimalWithOverflowStateFactory; import io.trino.operator.aggregation.state.LongDecimalWithOverflowStateSerializer; @@ -55,6 +55,7 @@ import static io.trino.spi.type.UnscaledDecimal128Arithmetic.throwIfOverflows; import static io.trino.spi.type.UnscaledDecimal128Arithmetic.throwOverflowException; import static io.trino.spi.type.UnscaledDecimal128Arithmetic.unscaledDecimal; +import static io.trino.spi.type.VarbinaryType.VARBINARY; import static io.trino.util.Reflection.methodHandle; public class DecimalSumAggregation @@ -87,14 +88,9 @@ public DecimalSumAggregation() true, "Calculates the sum over the input values", AGGREGATE), - true, - false); - } - - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - return ImmutableList.of(new LongDecimalWithOverflowAndLongStateSerializer().getSerializedType().getTypeSignature()); + new AggregationFunctionMetadata( + false, + VARBINARY.getTypeSignature())); } @Override diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/MapAggregationFunction.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/MapAggregationFunction.java index 08aa37bae266..5e59371bc874 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/MapAggregationFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/MapAggregationFunction.java @@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -91,18 +92,12 @@ public MapAggregationFunction(BlockTypeOperators blockTypeOperators) true, "Aggregates all the rows (key/value pairs) into a single map", AGGREGATE), - true, - true); + new AggregationFunctionMetadata( + true, + mapType(new TypeSignature("K"), new TypeSignature("V")))); this.blockTypeOperators = requireNonNull(blockTypeOperators, "blockTypeOperators is null"); } - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - MapType outputType = (MapType) functionBinding.getBoundSignature().getReturnType(); - return ImmutableList.of(outputType.getTypeSignature()); - } - @Override public InternalAggregationFunction specialize(FunctionBinding functionBinding) { diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/MapUnionAggregation.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/MapUnionAggregation.java index 4c7791cfb9e9..b28f9d1ca44e 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/MapUnionAggregation.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/MapUnionAggregation.java @@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -84,18 +85,12 @@ public MapUnionAggregation(BlockTypeOperators blockTypeOperators) true, "Aggregate all the maps into a single map", AGGREGATE), - true, - false); + new AggregationFunctionMetadata( + false, + mapType(new TypeSignature("K"), new TypeSignature("V")))); this.blockTypeOperators = requireNonNull(blockTypeOperators, "blockTypeOperators is null"); } - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - MapType outputType = (MapType) functionBinding.getBoundSignature().getReturnType(); - return ImmutableList.of(outputType.getTypeSignature()); - } - @Override public InternalAggregationFunction specialize(FunctionBinding functionBinding) { diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/MergeQuantileDigestFunction.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/MergeQuantileDigestFunction.java index f11a38027433..0b6769441cd5 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/MergeQuantileDigestFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/MergeQuantileDigestFunction.java @@ -16,6 +16,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; import io.airlift.stats.QuantileDigest; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -46,6 +47,7 @@ import static io.trino.operator.aggregation.AggregationMetadata.ParameterMetadata.ParameterType.BLOCK_INPUT_CHANNEL; import static io.trino.operator.aggregation.AggregationMetadata.ParameterMetadata.ParameterType.STATE; import static io.trino.operator.aggregation.AggregationUtils.generateAggregationName; +import static io.trino.spi.type.StandardTypes.QDIGEST; import static io.trino.spi.type.TypeSignature.parametricType; import static io.trino.util.MoreMath.nearlyEqual; import static io.trino.util.Reflection.methodHandle; @@ -78,15 +80,9 @@ public MergeQuantileDigestFunction() true, "Merges the input quantile digests into a single quantile digest", AGGREGATE), - true, - true); - } - - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - Type valueType = functionBinding.getTypeVariable("T"); - return ImmutableList.of(new QuantileDigestStateSerializer(valueType).getSerializedType().getTypeSignature()); + new AggregationFunctionMetadata( + true, + parametricType(QDIGEST, new TypeSignature("T")))); } @Override diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/ParametricAggregation.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/ParametricAggregation.java index c11e5eb43b7a..3cf71a0f4e54 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/ParametricAggregation.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/ParametricAggregation.java @@ -16,6 +16,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.BoundSignature; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionDependencies; @@ -77,8 +78,9 @@ public ParametricAggregation( details.getDescription().orElse(""), AGGREGATE, details.isDeprecated()), - details.isDecomposable(), - details.isOrderSensitive()); + new AggregationFunctionMetadata( + details.isOrderSensitive(), + details.isDecomposable() ? Optional.of(getSerializedType(stateClass).getTypeSignature()) : Optional.empty())); this.stateClass = requireNonNull(stateClass, "stateClass is null"); checkArgument(implementations.isNullable(), "currently aggregates are required to be nullable"); this.implementations = requireNonNull(implementations, "implementations is null"); @@ -109,13 +111,6 @@ private static void declareDependencies(FunctionDependencyDeclarationBuilder bui } } - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - // Use state compiler to extract intermediate types - return ImmutableList.of(getSerializedType(stateClass).getTypeSignature()); - } - @Override public InternalAggregationFunction specialize(FunctionBinding functionBinding, FunctionDependencies functionDependencies) { diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/QuantileDigestAggregationFunction.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/QuantileDigestAggregationFunction.java index b62ad1817d9e..697ffcab1289 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/QuantileDigestAggregationFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/QuantileDigestAggregationFunction.java @@ -16,6 +16,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; import io.airlift.stats.QuantileDigest; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -51,6 +52,7 @@ import static io.trino.operator.scalar.QuantileDigestFunctions.verifyWeight; import static io.trino.spi.type.BigintType.BIGINT; import static io.trino.spi.type.DoubleType.DOUBLE; +import static io.trino.spi.type.StandardTypes.QDIGEST; import static io.trino.spi.type.TypeSignature.parametricType; import static io.trino.util.Reflection.methodHandle; import static java.lang.Float.intBitsToFloat; @@ -89,15 +91,9 @@ private QuantileDigestAggregationFunction(TypeSignature... typeSignatures) true, "Returns a qdigest from the set of reals, bigints or doubles", AGGREGATE), - true, - true); - } - - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - Type valueType = functionBinding.getTypeVariable("V"); - return ImmutableList.of(new QuantileDigestType(valueType).getTypeSignature()); + new AggregationFunctionMetadata( + true, + parametricType(QDIGEST, new TypeSignature("V")))); } @Override diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/RealAverageAggregation.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/RealAverageAggregation.java index f7b6913b6ea4..c40dbcba725c 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/RealAverageAggregation.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/RealAverageAggregation.java @@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -28,7 +29,6 @@ import io.trino.spi.function.AccumulatorState; import io.trino.spi.function.AccumulatorStateSerializer; import io.trino.spi.type.Type; -import io.trino.spi.type.TypeSignature; import java.lang.invoke.MethodHandle; import java.util.List; @@ -41,6 +41,8 @@ import static io.trino.operator.aggregation.AggregationMetadata.ParameterMetadata.ParameterType.INPUT_CHANNEL; import static io.trino.operator.aggregation.AggregationMetadata.ParameterMetadata.ParameterType.STATE; import static io.trino.operator.aggregation.AggregationUtils.generateAggregationName; +import static io.trino.spi.type.BigintType.BIGINT; +import static io.trino.spi.type.DoubleType.DOUBLE; import static io.trino.spi.type.RealType.REAL; import static io.trino.util.Reflection.methodHandle; import static java.lang.Float.floatToIntBits; @@ -74,16 +76,10 @@ protected RealAverageAggregation() true, "Returns the average value of the argument", AGGREGATE), - true, - false); - } - - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - return ImmutableList.of( - StateCompiler.getSerializedType(LongState.class).getTypeSignature(), - StateCompiler.getSerializedType(DoubleState.class).getTypeSignature()); + new AggregationFunctionMetadata( + false, + BIGINT.getTypeSignature(), + DOUBLE.getTypeSignature())); } @Override diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/ReduceAggregationFunction.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/ReduceAggregationFunction.java index f833d3e7cadd..8823fe4933d0 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/ReduceAggregationFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/ReduceAggregationFunction.java @@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -92,14 +93,9 @@ public ReduceAggregationFunction() true, "Reduce input elements into a single value", AGGREGATE), - true, - false); - } - - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - return ImmutableList.of(functionBinding.getTypeVariable("S").getTypeSignature()); + new AggregationFunctionMetadata( + false, + new TypeSignature("S"))); } @Override diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/arrayagg/ArrayAggregationFunction.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/arrayagg/ArrayAggregationFunction.java index 32ae989544b5..1d336c2fdf24 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/arrayagg/ArrayAggregationFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/arrayagg/ArrayAggregationFunction.java @@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -46,6 +47,7 @@ import static io.trino.operator.aggregation.AggregationMetadata.ParameterMetadata.ParameterType.NULLABLE_BLOCK_INPUT_CHANNEL; import static io.trino.operator.aggregation.AggregationMetadata.ParameterMetadata.ParameterType.STATE; import static io.trino.operator.aggregation.AggregationUtils.generateAggregationName; +import static io.trino.spi.type.TypeSignature.arrayType; import static io.trino.util.Reflection.methodHandle; public class ArrayAggregationFunction @@ -65,7 +67,7 @@ private ArrayAggregationFunction() NAME, ImmutableList.of(typeVariable("T")), ImmutableList.of(), - TypeSignature.arrayType(new TypeSignature("T")), + arrayType(new TypeSignature("T")), ImmutableList.of(new TypeSignature("T")), false), true, @@ -74,15 +76,9 @@ private ArrayAggregationFunction() true, "return an array of values", AGGREGATE), - true, - true); - } - - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - Type type = functionBinding.getTypeVariable("T"); - return ImmutableList.of(new ArrayAggregationStateSerializer(type).getSerializedType().getTypeSignature()); + new AggregationFunctionMetadata( + true, + arrayType(new TypeSignature("T")))); } @Override diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/histogram/Histogram.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/histogram/Histogram.java index ba67f44929e1..dd6839184646 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/histogram/Histogram.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/histogram/Histogram.java @@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -78,18 +79,12 @@ public Histogram(BlockTypeOperators blockTypeOperators) true, "Count the number of times each value occurs", AGGREGATE), - true, - false); + new AggregationFunctionMetadata( + false, + mapType(new TypeSignature("K"), BIGINT.getTypeSignature()))); this.blockTypeOperators = blockTypeOperators; } - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - Type outputType = functionBinding.getBoundSignature().getReturnType(); - return ImmutableList.of(outputType.getTypeSignature()); - } - @Override public InternalAggregationFunction specialize(FunctionBinding functionBinding) { diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/listagg/ListaggAggregationFunction.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/listagg/ListaggAggregationFunction.java index 12f894d6959a..efa6e64c5aa5 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/listagg/ListaggAggregationFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/listagg/ListaggAggregationFunction.java @@ -18,6 +18,7 @@ import io.airlift.bytecode.DynamicClassLoader; import io.airlift.slice.Slice; import io.airlift.slice.Slices; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -55,6 +56,7 @@ import static io.trino.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT; import static io.trino.spi.block.PageBuilderStatus.DEFAULT_MAX_PAGE_SIZE_IN_BYTES; import static io.trino.spi.type.BooleanType.BOOLEAN; +import static io.trino.spi.type.TypeSignature.arrayType; import static io.trino.spi.type.VarcharType.VARCHAR; import static io.trino.util.Reflection.methodHandle; import static java.lang.String.format; @@ -98,14 +100,13 @@ private ListaggAggregationFunction() true, "concatenates the input values with the specified separator", AGGREGATE), - true, - true); - } - - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - return ImmutableList.of(new ListaggAggregationStateSerializer(VARCHAR).getSerializedType().getTypeSignature()); + new AggregationFunctionMetadata( + true, + VARCHAR.getTypeSignature(), + BOOLEAN.getTypeSignature(), + VARCHAR.getTypeSignature(), + BOOLEAN.getTypeSignature(), + arrayType(VARCHAR.getTypeSignature()))); } @Override diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/minmaxby/AbstractMinMaxBy.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/minmaxby/AbstractMinMaxBy.java index 491ddd325202..16938028a14c 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/minmaxby/AbstractMinMaxBy.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/minmaxby/AbstractMinMaxBy.java @@ -23,6 +23,7 @@ import io.airlift.bytecode.Parameter; import io.airlift.bytecode.control.IfStatement; import io.airlift.bytecode.expression.BytecodeExpression; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionDependencies; @@ -112,8 +113,10 @@ protected AbstractMinMaxBy(boolean min, String description) true, description, AGGREGATE), - true, - false); + new AggregationFunctionMetadata( + false, + new TypeSignature("K"), + new TypeSignature("V"))); this.min = min; } @@ -123,21 +126,6 @@ public FunctionDependencyDeclaration getFunctionDependencies() return getMinMaxCompareFunctionDependencies(new TypeSignature("K"), min); } - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - Type keyType = functionBinding.getTypeVariable("K"); - Type valueType = functionBinding.getTypeVariable("V"); - - Class stateClass = getStateClass(keyType.getJavaType(), valueType.getJavaType()); - if (valueType.getJavaType().isPrimitive()) { - Map stateFieldTypes = ImmutableMap.of("First", keyType, "Second", valueType); - return ImmutableList.of(StateCompiler.getSerializedType(stateClass, stateFieldTypes).getTypeSignature()); - } - - return ImmutableList.of(getStateSerializer(keyType, valueType).getSerializedType().getTypeSignature()); - } - @Override public InternalAggregationFunction specialize(FunctionBinding functionBinding, FunctionDependencies functionDependencies) { diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/minmaxby/AbstractMinMaxByNAggregationFunction.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/minmaxby/AbstractMinMaxByNAggregationFunction.java index ace488d8de6f..6e837996d72a 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/minmaxby/AbstractMinMaxByNAggregationFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/minmaxby/AbstractMinMaxByNAggregationFunction.java @@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionDependencies; @@ -56,6 +57,7 @@ import static io.trino.spi.function.InvocationConvention.InvocationReturnConvention.FAIL_ON_NULL; import static io.trino.spi.function.InvocationConvention.simpleConvention; import static io.trino.spi.type.BigintType.BIGINT; +import static io.trino.spi.type.TypeSignature.arrayType; import static io.trino.util.Failures.checkCondition; import static io.trino.util.MinMaxCompare.getMinMaxCompare; import static io.trino.util.Reflection.methodHandle; @@ -81,7 +83,7 @@ protected AbstractMinMaxByNAggregationFunction(String name, boolean min, String name, ImmutableList.of(typeVariable("V"), orderableTypeParameter("K")), ImmutableList.of(), - TypeSignature.arrayType(new TypeSignature("V")), + arrayType(new TypeSignature("V")), ImmutableList.of(new TypeSignature("V"), new TypeSignature("K"), BIGINT.getTypeSignature()), false), true, @@ -93,20 +95,15 @@ protected AbstractMinMaxByNAggregationFunction(String name, boolean min, String true, description, AGGREGATE), - true, - false); + new AggregationFunctionMetadata( + false, + BIGINT.getTypeSignature(), + arrayType(new TypeSignature("K")), + arrayType(new TypeSignature("V")))); this.name = requireNonNull(name, "name is null"); this.min = min; } - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - Type keyType = functionBinding.getTypeVariable("K"); - Type valueType = functionBinding.getTypeVariable("V"); - return ImmutableList.of(TypedKeyValueHeap.getSerializedType(keyType, valueType).getTypeSignature()); - } - @Override public FunctionDependencyDeclaration getFunctionDependencies(FunctionBinding functionBinding) { diff --git a/core/trino-main/src/main/java/io/trino/operator/aggregation/multimapagg/MultimapAggregationFunction.java b/core/trino-main/src/main/java/io/trino/operator/aggregation/multimapagg/MultimapAggregationFunction.java index 1e21ea4d6205..3bfce7443d29 100644 --- a/core/trino-main/src/main/java/io/trino/operator/aggregation/multimapagg/MultimapAggregationFunction.java +++ b/core/trino-main/src/main/java/io/trino/operator/aggregation/multimapagg/MultimapAggregationFunction.java @@ -16,6 +16,7 @@ import com.google.common.collect.ImmutableList; import io.airlift.bytecode.DynamicClassLoader; import io.trino.array.ObjectBigArray; +import io.trino.metadata.AggregationFunctionMetadata; import io.trino.metadata.FunctionArgumentDefinition; import io.trino.metadata.FunctionBinding; import io.trino.metadata.FunctionMetadata; @@ -105,19 +106,13 @@ public MultimapAggregationFunction(BlockTypeOperators blockTypeOperators) true, "Aggregates all the rows (key/value pairs) into a single multimap", AGGREGATE), - true, - true); + new AggregationFunctionMetadata( + true, + new TypeSignature("V"), + new TypeSignature("K"))); this.blockTypeOperators = requireNonNull(blockTypeOperators, "blockTypeOperators is null"); } - @Override - public List getIntermediateTypes(FunctionBinding functionBinding) - { - Type keyType = functionBinding.getTypeVariable("K"); - Type valueType = functionBinding.getTypeVariable("V"); - return ImmutableList.of(new MultimapAggregationStateSerializer(keyType, valueType).getSerializedType().getTypeSignature()); - } - @Override public InternalAggregationFunction specialize(FunctionBinding functionBinding) { diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/plan/AggregationNode.java b/core/trino-main/src/main/java/io/trino/sql/planner/plan/AggregationNode.java index c35ff1c4aa30..52a748c5cc56 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/plan/AggregationNode.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/plan/AggregationNode.java @@ -229,8 +229,7 @@ public boolean isDecomposable(Metadata metadata) boolean decomposableFunctions = getAggregations().values().stream() .map(Aggregation::getResolvedFunction) .map(metadata::getAggregationFunctionMetadata) - .map(AggregationFunctionMetadata::getIntermediateType) - .allMatch(Optional::isPresent); + .allMatch(AggregationFunctionMetadata::isDecomposable); return !hasOrderBy && !hasDistinct && decomposableFunctions; } diff --git a/core/trino-main/src/test/java/io/trino/operator/TestAnnotationEngineForAggregates.java b/core/trino-main/src/test/java/io/trino/operator/TestAnnotationEngineForAggregates.java index bce3bb613c38..c8cf492bbc48 100644 --- a/core/trino-main/src/test/java/io/trino/operator/TestAnnotationEngineForAggregates.java +++ b/core/trino-main/src/test/java/io/trino/operator/TestAnnotationEngineForAggregates.java @@ -142,7 +142,7 @@ public void testSimpleExactAggregationParse() new BoundSignature(expectedSignature.getName(), DoubleType.DOUBLE, ImmutableList.of(DoubleType.DOUBLE)), ImmutableMap.of(), ImmutableMap.of()); - AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(functionBinding); + AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(); assertFalse(aggregationMetadata.isOrderSensitive()); assertTrue(aggregationMetadata.getIntermediateType().isPresent()); InternalAggregationFunction specialized = aggregation.specialize(functionBinding, NO_FUNCTION_DEPENDENCIES); @@ -227,7 +227,7 @@ public void testNotAnnotatedAggregateStateAggregationParse() new BoundSignature(aggregation.getFunctionMetadata().getSignature().getName(), DoubleType.DOUBLE, ImmutableList.of(DoubleType.DOUBLE)), ImmutableMap.of(), ImmutableMap.of()); - AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(functionBinding); + AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(); assertFalse(aggregationMetadata.isOrderSensitive()); assertTrue(aggregationMetadata.getIntermediateType().isPresent()); InternalAggregationFunction specialized = aggregation.specialize(functionBinding, NO_FUNCTION_DEPENDENCIES); @@ -282,7 +282,7 @@ public void testNotDecomposableAggregationParse() new BoundSignature(aggregation.getFunctionMetadata().getSignature().getName(), DoubleType.DOUBLE, ImmutableList.of(DoubleType.DOUBLE)), ImmutableMap.of(), ImmutableMap.of()); - AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(functionBinding); + AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(); assertFalse(aggregationMetadata.isOrderSensitive()); assertFalse(aggregationMetadata.getIntermediateType().isPresent()); InternalAggregationFunction specialized = aggregation.specialize(functionBinding, NO_FUNCTION_DEPENDENCIES); @@ -371,7 +371,7 @@ public void testSimpleGenericAggregationFunctionParse() new BoundSignature(aggregation.getFunctionMetadata().getSignature().getName(), DoubleType.DOUBLE, ImmutableList.of(DoubleType.DOUBLE)), ImmutableMap.of("T", DoubleType.DOUBLE), ImmutableMap.of()); - AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(functionBinding); + AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(); assertFalse(aggregationMetadata.isOrderSensitive()); assertTrue(aggregationMetadata.getIntermediateType().isPresent()); InternalAggregationFunction specialized = aggregation.specialize(functionBinding, NO_FUNCTION_DEPENDENCIES); @@ -436,7 +436,7 @@ public void testSimpleBlockInputAggregationParse() new BoundSignature(aggregation.getFunctionMetadata().getSignature().getName(), DoubleType.DOUBLE, ImmutableList.of(DoubleType.DOUBLE)), ImmutableMap.of(), ImmutableMap.of()); - AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(functionBinding); + AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(); assertFalse(aggregationMetadata.isOrderSensitive()); assertTrue(aggregationMetadata.getIntermediateType().isPresent()); InternalAggregationFunction specialized = aggregation.specialize(functionBinding, NO_FUNCTION_DEPENDENCIES); @@ -533,7 +533,7 @@ public void testSimpleImplicitSpecializedAggregationParse() new BoundSignature(aggregation.getFunctionMetadata().getSignature().getName(), DoubleType.DOUBLE, ImmutableList.of(new ArrayType(DoubleType.DOUBLE))), ImmutableMap.of("T", DoubleType.DOUBLE), ImmutableMap.of()); - AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(functionBinding); + AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(); assertFalse(aggregationMetadata.isOrderSensitive()); assertTrue(aggregationMetadata.getIntermediateType().isPresent()); InternalAggregationFunction specialized = aggregation.specialize(functionBinding, NO_FUNCTION_DEPENDENCIES); @@ -630,7 +630,7 @@ public void testSimpleExplicitSpecializedAggregationParse() new BoundSignature(aggregation.getFunctionMetadata().getSignature().getName(), DoubleType.DOUBLE, ImmutableList.of(new ArrayType(DoubleType.DOUBLE))), ImmutableMap.of("T", DoubleType.DOUBLE), ImmutableMap.of()); - AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(functionBinding); + AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(); assertFalse(aggregationMetadata.isOrderSensitive()); assertTrue(aggregationMetadata.getIntermediateType().isPresent()); InternalAggregationFunction specialized = aggregation.specialize(functionBinding, NO_FUNCTION_DEPENDENCIES); @@ -721,7 +721,7 @@ public void testMultiOutputAggregationParse() new BoundSignature(aggregation1.getFunctionMetadata().getSignature().getName(), DoubleType.DOUBLE, ImmutableList.of(DoubleType.DOUBLE)), ImmutableMap.of(), ImmutableMap.of()); - AggregationFunctionMetadata aggregationMetadata = aggregation1.getAggregationMetadata(functionBinding); + AggregationFunctionMetadata aggregationMetadata = aggregation1.getAggregationMetadata(); assertFalse(aggregationMetadata.isOrderSensitive()); assertTrue(aggregationMetadata.getIntermediateType().isPresent()); InternalAggregationFunction specialized = aggregation1.specialize(functionBinding, NO_FUNCTION_DEPENDENCIES); @@ -939,7 +939,7 @@ public void testInjectLiteralAggregateParse() new BoundSignature(aggregation.getFunctionMetadata().getSignature().getName(), createVarcharType(17), ImmutableList.of(createVarcharType(17))), ImmutableMap.of(), ImmutableMap.of("x", 17L)); - AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(functionBinding); + AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(); assertFalse(aggregationMetadata.isOrderSensitive()); assertTrue(aggregationMetadata.getIntermediateType().isPresent()); InternalAggregationFunction specialized = aggregation.specialize(functionBinding, NO_FUNCTION_DEPENDENCIES); @@ -1015,7 +1015,7 @@ public void testLongConstraintAggregateFunctionParse() .put("y", 13L) .put("z", 30L) .build()); - AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(functionBinding); + AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(); assertFalse(aggregationMetadata.isOrderSensitive()); assertTrue(aggregationMetadata.getIntermediateType().isPresent()); InternalAggregationFunction specialized = aggregation.specialize(functionBinding, NO_FUNCTION_DEPENDENCIES); @@ -1232,7 +1232,7 @@ private static InternalAggregationFunction specializeAggregationFunction(BoundSi FunctionMetadata functionMetadata = aggregation.getFunctionMetadata(); FunctionBinding functionBinding = MetadataManager.toFunctionBinding(functionMetadata.getFunctionId(), boundSignature, functionMetadata.getSignature()); - AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(functionBinding); + AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata(); assertFalse(aggregationMetadata.isOrderSensitive()); assertTrue(aggregationMetadata.getIntermediateType().isPresent());