diff --git a/velox/exec/tests/SimpleAggregateAdapterTest.cpp b/velox/exec/tests/SimpleAggregateAdapterTest.cpp index 5113da90473..98e95afd911 100644 --- a/velox/exec/tests/SimpleAggregateAdapterTest.cpp +++ b/velox/exec/tests/SimpleAggregateAdapterTest.cpp @@ -410,7 +410,8 @@ class CountNullsAggregate { using AccumulatorType = Accumulator; }; -bool registerSimpleCountNullsAggregate(const std::string& name) { +exec::AggregateRegistrationResult registerSimpleCountNullsAggregate( + const std::string& name) { std::vector> signatures{ exec::AggregateFunctionSignatureBuilder() .returnType("bigint") @@ -418,7 +419,7 @@ bool registerSimpleCountNullsAggregate(const std::string& name) { .argumentType("double") .build()}; - exec::registerAggregateFunction( + return exec::registerAggregateFunction( name, std::move(signatures), [name]( @@ -432,7 +433,6 @@ bool registerSimpleCountNullsAggregate(const std::string& name) { return std::make_unique>( resultType); }); - return true; } void registerSimpleCountNullsAggregate() { diff --git a/velox/functions/prestosql/aggregates/ApproxMostFrequentAggregate.cpp b/velox/functions/prestosql/aggregates/ApproxMostFrequentAggregate.cpp index 8f785f27a95..a2bf995fce2 100644 --- a/velox/functions/prestosql/aggregates/ApproxMostFrequentAggregate.cpp +++ b/velox/functions/prestosql/aggregates/ApproxMostFrequentAggregate.cpp @@ -349,8 +349,10 @@ std::unique_ptr makeApproxMostFrequentAggregate( } } -exec::AggregateRegistrationResult registerApproxMostFrequent( - const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerApproxMostFrequentAggregate( + const std::string& prefix) { std::vector> signatures; for (const auto& valueType : {"tinyint", "smallint", "integer", "bigint", "varchar"}) { @@ -364,6 +366,7 @@ exec::AggregateRegistrationResult registerApproxMostFrequent( .argumentType("bigint") .build()); } + auto name = prefix + kApproxMostFrequent; return exec::registerAggregateFunction( name, std::move(signatures), @@ -385,10 +388,4 @@ exec::AggregateRegistrationResult registerApproxMostFrequent( }); } -} // namespace - -void registerApproxMostFrequentAggregate(const std::string& prefix) { - registerApproxMostFrequent(prefix + kApproxMostFrequent); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/ApproxPercentileAggregate.cpp b/velox/functions/prestosql/aggregates/ApproxPercentileAggregate.cpp index e5cc773a2d4..1e5a9e35b54 100644 --- a/velox/functions/prestosql/aggregates/ApproxPercentileAggregate.cpp +++ b/velox/functions/prestosql/aggregates/ApproxPercentileAggregate.cpp @@ -802,8 +802,10 @@ void addSignatures( .build()); } -exec::AggregateRegistrationResult registerApproxPercentile( - const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerApproxPercentileAggregate( + const std::string& prefix) { std::vector> signatures; for (const auto& inputType : {"tinyint", "smallint", "integer", "bigint", "real", "double"}) { @@ -814,6 +816,7 @@ exec::AggregateRegistrationResult registerApproxPercentile( fmt::format("array({})", inputType), signatures); } + auto name = prefix + kApproxPercentile; return exec::registerAggregateFunction( name, std::move(signatures), @@ -905,10 +908,4 @@ exec::AggregateRegistrationResult registerApproxPercentile( /*registerCompanionFunctions*/ true); } -} // namespace - -void registerApproxPercentileAggregate(const std::string& prefix) { - registerApproxPercentile(prefix + kApproxPercentile); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/ArbitraryAggregate.cpp b/velox/functions/prestosql/aggregates/ArbitraryAggregate.cpp index b7cf112c998..cf570f3fa2d 100644 --- a/velox/functions/prestosql/aggregates/ArbitraryAggregate.cpp +++ b/velox/functions/prestosql/aggregates/ArbitraryAggregate.cpp @@ -254,7 +254,10 @@ class NonNumericArbitrary : public exec::Aggregate { } }; -exec::AggregateRegistrationResult registerArbitrary(const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerArbitraryAggregate( + const std::string& prefix) { std::vector> signatures{ exec::AggregateFunctionSignatureBuilder() .typeVariable("T") @@ -263,6 +266,7 @@ exec::AggregateRegistrationResult registerArbitrary(const std::string& name) { .argumentType("T") .build()}; + auto name = prefix + kArbitrary; return exec::registerAggregateFunction( name, std::move(signatures), @@ -312,10 +316,4 @@ exec::AggregateRegistrationResult registerArbitrary(const std::string& name) { }); } -} // namespace - -void registerArbitraryAggregate(const std::string& prefix) { - registerArbitrary(prefix + kArbitrary); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/ArrayAggAggregate.cpp b/velox/functions/prestosql/aggregates/ArrayAggAggregate.cpp index 52966d29585..2be1d5b45fe 100644 --- a/velox/functions/prestosql/aggregates/ArrayAggAggregate.cpp +++ b/velox/functions/prestosql/aggregates/ArrayAggAggregate.cpp @@ -235,7 +235,10 @@ class ArrayAggAggregate : public exec::Aggregate { DecodedVector decodedIntermediate_; }; -exec::AggregateRegistrationResult registerArray(const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerArrayAggAggregate( + const std::string& prefix) { std::vector> signatures{ exec::AggregateFunctionSignatureBuilder() .typeVariable("E") @@ -244,6 +247,7 @@ exec::AggregateRegistrationResult registerArray(const std::string& name) { .argumentType("E") .build()}; + auto name = prefix + kArrayAgg; return exec::registerAggregateFunction( name, std::move(signatures), @@ -260,10 +264,4 @@ exec::AggregateRegistrationResult registerArray(const std::string& name) { /*registerCompanionFunctions*/ true); } -} // namespace - -void registerArrayAggregate(const std::string& prefix) { - registerArray(prefix + kArrayAgg); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/AverageAggregate.cpp b/velox/functions/prestosql/aggregates/AverageAggregate.cpp index 36f3123ffaa..940a5221f8e 100644 --- a/velox/functions/prestosql/aggregates/AverageAggregate.cpp +++ b/velox/functions/prestosql/aggregates/AverageAggregate.cpp @@ -20,7 +20,6 @@ using namespace facebook::velox::functions::aggregate; namespace facebook::velox::aggregate::prestosql { -namespace { /// Count is BIGINT() while sum and the final aggregates type depends on /// the input types: @@ -30,7 +29,8 @@ namespace { /// REAL | DOUBLE | REAL /// ALL INTs | DOUBLE | DOUBLE /// DECIMAL | DECIMAL | DECIMAL -exec::AggregateRegistrationResult registerAverage(const std::string& name) { +exec::AggregateRegistrationResult registerAverageAggregate( + const std::string& prefix) { std::vector> signatures; for (const auto& inputType : {"smallint", "integer", "bigint", "double"}) { @@ -55,6 +55,7 @@ exec::AggregateRegistrationResult registerAverage(const std::string& name) { .returnType("DECIMAL(a_precision, a_scale)") .build()); + auto name = prefix + kAvg; return exec::registerAggregateFunction( name, std::move(signatures), @@ -140,10 +141,5 @@ exec::AggregateRegistrationResult registerAverage(const std::string& name) { }, /*registerCompanionFunctions*/ true); } -} // namespace - -void registerAverageAggregate(const std::string& prefix) { - registerAverage(prefix + kAvg); -} } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/BitwiseXorAggregate.cpp b/velox/functions/prestosql/aggregates/BitwiseXorAggregate.cpp index 415d2dc1bc9..0e825278aa9 100644 --- a/velox/functions/prestosql/aggregates/BitwiseXorAggregate.cpp +++ b/velox/functions/prestosql/aggregates/BitwiseXorAggregate.cpp @@ -66,7 +66,8 @@ class BitwiseXorAggregate { } // namespace -void registerBitwiseXorAggregate(const std::string& prefix) { +exec::AggregateRegistrationResult registerBitwiseXorAggregate( + const std::string& prefix) { const std::string name = prefix + kBitwiseXor; std::vector> signatures; @@ -79,7 +80,7 @@ void registerBitwiseXorAggregate(const std::string& prefix) { .build()); } - exec::registerAggregateFunction( + return exec::registerAggregateFunction( name, std::move(signatures), [name]( diff --git a/velox/functions/prestosql/aggregates/ChecksumAggregate.cpp b/velox/functions/prestosql/aggregates/ChecksumAggregate.cpp index 0f48fd26867..c243f46f48c 100644 --- a/velox/functions/prestosql/aggregates/ChecksumAggregate.cpp +++ b/velox/functions/prestosql/aggregates/ChecksumAggregate.cpp @@ -207,7 +207,10 @@ class ChecksumAggregate : public exec::Aggregate { DecodedVector decodedIntermediate_; }; -exec::AggregateRegistrationResult registerChecksum(const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerChecksumAggregate( + const std::string& prefix) { std::vector> signatures{ exec::AggregateFunctionSignatureBuilder() .typeVariable("T") @@ -217,6 +220,7 @@ exec::AggregateRegistrationResult registerChecksum(const std::string& name) { .build(), }; + auto name = prefix + kChecksum; return exec::registerAggregateFunction( name, std::move(signatures), @@ -236,10 +240,4 @@ exec::AggregateRegistrationResult registerChecksum(const std::string& name) { }); } -} // namespace - -void registerChecksumAggregate(const std::string& prefix) { - registerChecksum(prefix + kChecksum); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/CountAggregate.cpp b/velox/functions/prestosql/aggregates/CountAggregate.cpp index 70c01432260..edf0622e69a 100644 --- a/velox/functions/prestosql/aggregates/CountAggregate.cpp +++ b/velox/functions/prestosql/aggregates/CountAggregate.cpp @@ -148,7 +148,10 @@ class CountAggregate : public SimpleNumericAggregate { DecodedVector decodedIntermediate_; }; -exec::AggregateRegistrationResult registerCount(const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerCountAggregate( + const std::string& prefix) { std::vector> signatures{ exec::AggregateFunctionSignatureBuilder() .returnType("bigint") @@ -162,6 +165,7 @@ exec::AggregateRegistrationResult registerCount(const std::string& name) { .build(), }; + auto name = prefix + kCount; return exec::registerAggregateFunction( name, std::move(signatures), @@ -177,10 +181,4 @@ exec::AggregateRegistrationResult registerCount(const std::string& name) { }); } -} // namespace - -void registerCountAggregate(const std::string& prefix) { - registerCount(prefix + kCount); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/CountIfAggregate.cpp b/velox/functions/prestosql/aggregates/CountIfAggregate.cpp index 5b053c823a9..6cd1bc923ef 100644 --- a/velox/functions/prestosql/aggregates/CountIfAggregate.cpp +++ b/velox/functions/prestosql/aggregates/CountIfAggregate.cpp @@ -168,7 +168,10 @@ class CountIfAggregate : public exec::Aggregate { } }; -exec::AggregateRegistrationResult registerCountIf(const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerCountIfAggregate( + const std::string& prefix) { std::vector> signatures{ exec::AggregateFunctionSignatureBuilder() .returnType("bigint") @@ -177,6 +180,7 @@ exec::AggregateRegistrationResult registerCountIf(const std::string& name) { .build(), }; + auto name = prefix + kCountIf; return exec::registerAggregateFunction( name, std::move(signatures), @@ -201,10 +205,4 @@ exec::AggregateRegistrationResult registerCountIf(const std::string& name) { }); } -} // namespace - -void registerCountIfAggregate(const std::string& prefix) { - registerCountIf(prefix + kCountIf); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/EntropyAggregates.cpp b/velox/functions/prestosql/aggregates/EntropyAggregates.cpp index 04a17f722e0..2cdbbe12ce5 100644 --- a/velox/functions/prestosql/aggregates/EntropyAggregates.cpp +++ b/velox/functions/prestosql/aggregates/EntropyAggregates.cpp @@ -334,7 +334,10 @@ void checkRowType(const TypePtr& type, const std::string& errorMessage) { errorMessage); } -exec::AggregateRegistrationResult registerEntropy(const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerEntropyAggregate( + const std::string& prefix) { std::vector> signatures; std::vector inputTypes = {"smallint", "integer", "bigint"}; for (const auto& inputType : inputTypes) { @@ -345,6 +348,7 @@ exec::AggregateRegistrationResult registerEntropy(const std::string& name) { .build()); } + auto name = prefix + kEntropy; return exec::registerAggregateFunction( name, std::move(signatures), @@ -382,10 +386,4 @@ exec::AggregateRegistrationResult registerEntropy(const std::string& name) { }); } -} // namespace - -void registerEntropyAggregates(const std::string& prefix) { - registerEntropy(prefix + kEntropy); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/GeometricMeanAggregate.cpp b/velox/functions/prestosql/aggregates/GeometricMeanAggregate.cpp index 0ea083a2160..0f01dc78919 100644 --- a/velox/functions/prestosql/aggregates/GeometricMeanAggregate.cpp +++ b/velox/functions/prestosql/aggregates/GeometricMeanAggregate.cpp @@ -82,7 +82,8 @@ class GeometricMeanAggregate { } // namespace -void registerGeometricMeanAggregate(const std::string& prefix) { +exec::AggregateRegistrationResult registerGeometricMeanAggregate( + const std::string& prefix) { const std::string name = prefix + kGeometricMean; std::vector> signatures; @@ -102,7 +103,7 @@ void registerGeometricMeanAggregate(const std::string& prefix) { .argumentType("real") .build()); - exec::registerAggregateFunction( + return exec::registerAggregateFunction( name, std::move(signatures), [name]( diff --git a/velox/functions/prestosql/aggregates/HistogramAggregate.cpp b/velox/functions/prestosql/aggregates/HistogramAggregate.cpp index 32661a367e8..7ccaafe2886 100644 --- a/velox/functions/prestosql/aggregates/HistogramAggregate.cpp +++ b/velox/functions/prestosql/aggregates/HistogramAggregate.cpp @@ -338,7 +338,10 @@ class HistogramAggregate : public exec::Aggregate { DecodedVector decodedIntermediate_; }; -exec::AggregateRegistrationResult registerHistogram(const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerHistogramAggregate( + const std::string& prefix) { std::vector> signatures; for (const auto inputType : {"boolean", @@ -360,6 +363,7 @@ exec::AggregateRegistrationResult registerHistogram(const std::string& name) { .build()); } + auto name = prefix + kHistogram; return exec::registerAggregateFunction( name, std::move(signatures), @@ -405,10 +409,4 @@ exec::AggregateRegistrationResult registerHistogram(const std::string& name) { }); } -} // namespace - -void registerHistogramAggregate(const std::string& prefix) { - registerHistogram(prefix + kHistogram); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/MapAggAggregate.cpp b/velox/functions/prestosql/aggregates/MapAggAggregate.cpp index 134afda0b65..84b96cee674 100644 --- a/velox/functions/prestosql/aggregates/MapAggAggregate.cpp +++ b/velox/functions/prestosql/aggregates/MapAggAggregate.cpp @@ -145,7 +145,10 @@ class MapAggAggregate : public MapAggregateBase { const bool throwOnNestedNulls_; }; -exec::AggregateRegistrationResult registerMapAgg(const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerMapAggAggregate( + const std::string& prefix) { std::vector> signatures{ exec::AggregateFunctionSignatureBuilder() .knownTypeVariable("K") @@ -156,6 +159,7 @@ exec::AggregateRegistrationResult registerMapAgg(const std::string& name) { .argumentType("V") .build()}; + auto name = prefix + kMapAgg; return exec::registerAggregateFunction( name, std::move(signatures), @@ -208,10 +212,4 @@ exec::AggregateRegistrationResult registerMapAgg(const std::string& name) { }); } -} // namespace - -void registerMapAggAggregate(const std::string& prefix) { - registerMapAgg(prefix + kMapAgg); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/MapUnionAggregate.cpp b/velox/functions/prestosql/aggregates/MapUnionAggregate.cpp index fd4b2440116..73c82a06a2e 100644 --- a/velox/functions/prestosql/aggregates/MapUnionAggregate.cpp +++ b/velox/functions/prestosql/aggregates/MapUnionAggregate.cpp @@ -73,7 +73,10 @@ class MapUnionAggregate : public MapAggregateBase { } }; -exec::AggregateRegistrationResult registerMapUnion(const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerMapUnionAggregate( + const std::string& prefix) { std::vector> signatures{ exec::AggregateFunctionSignatureBuilder() .typeVariable("K") @@ -83,6 +86,7 @@ exec::AggregateRegistrationResult registerMapUnion(const std::string& name) { .argumentType("map(K,V)") .build()}; + auto name = prefix + kMapUnion; return exec::registerAggregateFunction( name, std::move(signatures), @@ -102,10 +106,4 @@ exec::AggregateRegistrationResult registerMapUnion(const std::string& name) { }); } -} // namespace - -void registerMapUnionAggregate(const std::string& prefix) { - registerMapUnion(prefix + kMapUnion); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/MapUnionSumAggregate.cpp b/velox/functions/prestosql/aggregates/MapUnionSumAggregate.cpp index 72d0c1a03c7..a12d3376ca8 100644 --- a/velox/functions/prestosql/aggregates/MapUnionSumAggregate.cpp +++ b/velox/functions/prestosql/aggregates/MapUnionSumAggregate.cpp @@ -345,7 +345,10 @@ std::unique_ptr createMapUnionSumAggregate( } } -exec::AggregateRegistrationResult registerMapUnionSum(const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerMapUnionSumAggregate( + const std::string& prefix) { const std::vector keyTypes = { "tinyint", "smallint", @@ -376,6 +379,7 @@ exec::AggregateRegistrationResult registerMapUnionSum(const std::string& name) { } } + auto name = prefix + kMapUnionSum; return exec::registerAggregateFunction( name, std::move(signatures), @@ -417,10 +421,4 @@ exec::AggregateRegistrationResult registerMapUnionSum(const std::string& name) { }); } -} // namespace - -void registerMapUnionSumAggregate(const std::string& prefix) { - registerMapUnionSum(prefix + kMapUnionSum); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/MaxSizeForStatsAggregate.cpp b/velox/functions/prestosql/aggregates/MaxSizeForStatsAggregate.cpp index 5d9f63766d1..9967102c5b1 100644 --- a/velox/functions/prestosql/aggregates/MaxSizeForStatsAggregate.cpp +++ b/velox/functions/prestosql/aggregates/MaxSizeForStatsAggregate.cpp @@ -202,8 +202,10 @@ class MaxSizeForStatsAggregate } }; -exec::AggregateRegistrationResult registerMaxSizeForStats( - const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerMaxDataSizeForStatsAggregate( + const std::string& prefix) { std::vector> signatures; signatures.push_back(exec::AggregateFunctionSignatureBuilder() @@ -213,6 +215,7 @@ exec::AggregateRegistrationResult registerMaxSizeForStats( .argumentType("T") .build()); + auto name = prefix + kMaxSizeForStats; return exec::registerAggregateFunction( name, std::move(signatures), @@ -229,10 +232,4 @@ exec::AggregateRegistrationResult registerMaxSizeForStats( }); } -} // namespace - -void registerMaxDataSizeForStatsAggregate(const std::string& prefix) { - registerMaxSizeForStats(prefix + kMaxSizeForStats); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/MultiMapAggAggregate.cpp b/velox/functions/prestosql/aggregates/MultiMapAggAggregate.cpp index 622edc9854f..f61442d1b79 100644 --- a/velox/functions/prestosql/aggregates/MultiMapAggAggregate.cpp +++ b/velox/functions/prestosql/aggregates/MultiMapAggAggregate.cpp @@ -361,7 +361,10 @@ class MultiMapAggAggregate : public exec::Aggregate { DecodedVector decodedValueArrays_; }; -exec::AggregateRegistrationResult registerMultiMapAgg(const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerMultiMapAggAggregate( + const std::string& prefix) { static const std::vector kSupportedKeyTypes = { "boolean", "tinyint", @@ -389,6 +392,7 @@ exec::AggregateRegistrationResult registerMultiMapAgg(const std::string& name) { .build()); } + auto name = prefix + kMultiMapAgg; return exec::registerAggregateFunction( name, std::move(signatures), @@ -431,10 +435,4 @@ exec::AggregateRegistrationResult registerMultiMapAgg(const std::string& name) { }); } -} // namespace - -void registerMultiMapAggAggregate(const std::string& prefix) { - registerMultiMapAgg(prefix + kMultiMapAgg); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/ReduceAgg.cpp b/velox/functions/prestosql/aggregates/ReduceAgg.cpp index 138c3d5e73d..5c96ca654f2 100644 --- a/velox/functions/prestosql/aggregates/ReduceAgg.cpp +++ b/velox/functions/prestosql/aggregates/ReduceAgg.cpp @@ -786,7 +786,7 @@ class ReduceAgg : public exec::Aggregate { } // namespace -void registerReduceAgg(const std::string& prefix) { +exec::AggregateRegistrationResult registerReduceAgg(const std::string& prefix) { std::vector> signatures{ exec::AggregateFunctionSignatureBuilder() .typeVariable("T") @@ -801,7 +801,7 @@ void registerReduceAgg(const std::string& prefix) { const std::string name = prefix + kReduceAgg; - exec::registerAggregateFunction( + return exec::registerAggregateFunction( name, std::move(signatures), [name]( diff --git a/velox/functions/prestosql/aggregates/RegisterAggregateFunctions.cpp b/velox/functions/prestosql/aggregates/RegisterAggregateFunctions.cpp index ccd6aef9c33..d9dc50277ed 100644 --- a/velox/functions/prestosql/aggregates/RegisterAggregateFunctions.cpp +++ b/velox/functions/prestosql/aggregates/RegisterAggregateFunctions.cpp @@ -14,37 +14,60 @@ * limitations under the License. */ #include "velox/functions/prestosql/aggregates/RegisterAggregateFunctions.h" +#include "velox/exec/Aggregate.h" namespace facebook::velox::aggregate::prestosql { +extern exec::AggregateRegistrationResult registerApproxMostFrequentAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerApproxPercentileAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerArbitraryAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerArrayAggAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerAverageAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerBitwiseXorAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerChecksumAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerCountAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerCountIfAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerEntropyAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerGeometricMeanAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerHistogramAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerMapAggAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerMapUnionAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerMapUnionSumAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerMaxDataSizeForStatsAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerMultiMapAggAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerSumDataSizeForStatsAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerReduceAgg( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerSetAggAggregate( + const std::string& prefix); +extern exec::AggregateRegistrationResult registerSetUnionAggregate( + const std::string& prefix); + extern void registerApproxDistinctAggregates(const std::string& prefix); -extern void registerApproxMostFrequentAggregate(const std::string& prefix); -extern void registerApproxPercentileAggregate(const std::string& prefix); -extern void registerArbitraryAggregate(const std::string& prefix); -extern void registerArrayAggregate(const std::string& prefix); -extern void registerAverageAggregate(const std::string& prefix); extern void registerBitwiseAggregates(const std::string& prefix); -extern void registerBitwiseXorAggregate(const std::string& prefix); extern void registerBoolAggregates(const std::string& prefix); extern void registerCentralMomentsAggregates(const std::string& prefix); -extern void registerChecksumAggregate(const std::string& prefix); -extern void registerCountAggregate(const std::string& prefix); -extern void registerCountIfAggregate(const std::string& prefix); extern void registerCovarianceAggregates(const std::string& prefix); -extern void registerEntropyAggregates(const std::string& prefix); -extern void registerGeometricMeanAggregate(const std::string& prefix); -extern void registerHistogramAggregate(const std::string& prefix); -extern void registerMapAggAggregate(const std::string& prefix); -extern void registerMapUnionAggregate(const std::string& prefix); -extern void registerMapUnionSumAggregate(const std::string& prefix); -extern void registerMaxDataSizeForStatsAggregate(const std::string& prefix); -extern void registerMultiMapAggAggregate(const std::string& prefix); -extern void registerSumDataSizeForStatsAggregate(const std::string& prefix); extern void registerMinMaxAggregates(const std::string& prefix); extern void registerMinMaxByAggregates(const std::string& prefix); -extern void registerReduceAgg(const std::string& prefix); -extern void registerSetAggAggregate(const std::string& prefix); -extern void registerSetUnionAggregate(const std::string& prefix); extern void registerSumAggregate(const std::string& prefix); extern void registerVarianceAggregates(const std::string& prefix); @@ -53,7 +76,7 @@ void registerAllAggregateFunctions(const std::string& prefix) { registerApproxMostFrequentAggregate(prefix); registerApproxPercentileAggregate(prefix); registerArbitraryAggregate(prefix); - registerArrayAggregate(prefix); + registerArrayAggAggregate(prefix); registerAverageAggregate(prefix); registerBitwiseAggregates(prefix); registerBitwiseXorAggregate(prefix); @@ -63,7 +86,7 @@ void registerAllAggregateFunctions(const std::string& prefix) { registerCountAggregate(prefix); registerCountIfAggregate(prefix); registerCovarianceAggregates(prefix); - registerEntropyAggregates(prefix); + registerEntropyAggregate(prefix); registerGeometricMeanAggregate(prefix); registerHistogramAggregate(prefix); registerMapAggAggregate(prefix); diff --git a/velox/functions/prestosql/aggregates/SetAggregates.cpp b/velox/functions/prestosql/aggregates/SetAggregates.cpp index f385ebc1375..3c727fec15c 100644 --- a/velox/functions/prestosql/aggregates/SetAggregates.cpp +++ b/velox/functions/prestosql/aggregates/SetAggregates.cpp @@ -419,7 +419,10 @@ std::unique_ptr create( } } -exec::AggregateRegistrationResult registerSetAgg(const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerSetAggAggregate( + const std::string& prefix) { std::vector> signatures = { exec::AggregateFunctionSignatureBuilder() .typeVariable("T") @@ -428,6 +431,7 @@ exec::AggregateRegistrationResult registerSetAgg(const std::string& name) { .argumentType("T") .build()}; + auto name = prefix + kSetAgg; return exec::registerAggregateFunction( name, std::move(signatures), @@ -479,7 +483,8 @@ exec::AggregateRegistrationResult registerSetAgg(const std::string& name) { }); } -exec::AggregateRegistrationResult registerSetUnion(const std::string& name) { +exec::AggregateRegistrationResult registerSetUnionAggregate( + const std::string& prefix) { std::vector> signatures = { exec::AggregateFunctionSignatureBuilder() .typeVariable("T") @@ -488,6 +493,7 @@ exec::AggregateRegistrationResult registerSetUnion(const std::string& name) { .argumentType("array(T)") .build()}; + auto name = prefix + kSetUnion; return exec::registerAggregateFunction( name, std::move(signatures), @@ -505,14 +511,4 @@ exec::AggregateRegistrationResult registerSetUnion(const std::string& name) { }); } -} // namespace - -void registerSetAggAggregate(const std::string& prefix) { - registerSetAgg(prefix + kSetAgg); -} - -void registerSetUnionAggregate(const std::string& prefix) { - registerSetUnion(prefix + kSetUnion); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/prestosql/aggregates/SumDataSizeForStatsAggregate.cpp b/velox/functions/prestosql/aggregates/SumDataSizeForStatsAggregate.cpp index af910db6082..8d90149c411 100644 --- a/velox/functions/prestosql/aggregates/SumDataSizeForStatsAggregate.cpp +++ b/velox/functions/prestosql/aggregates/SumDataSizeForStatsAggregate.cpp @@ -182,8 +182,10 @@ class SumDataSizeForStatsAggregate std::vector rowIndices_; }; -exec::AggregateRegistrationResult registerSumDataSizeForStats( - const std::string& name) { +} // namespace + +exec::AggregateRegistrationResult registerSumDataSizeForStatsAggregate( + const std::string& prefix) { std::vector> signatures; signatures.push_back(exec::AggregateFunctionSignatureBuilder() @@ -193,6 +195,7 @@ exec::AggregateRegistrationResult registerSumDataSizeForStats( .argumentType("T") .build()); + auto name = prefix + kSumDataSizeForStats; return exec::registerAggregateFunction( name, std::move(signatures), @@ -209,10 +212,4 @@ exec::AggregateRegistrationResult registerSumDataSizeForStats( }); } -} // namespace - -void registerSumDataSizeForStatsAggregate(const std::string& prefix) { - registerSumDataSizeForStats(prefix + kSumDataSizeForStats); -} - } // namespace facebook::velox::aggregate::prestosql diff --git a/velox/functions/sparksql/aggregates/SumAggregate.cpp b/velox/functions/sparksql/aggregates/SumAggregate.cpp index d0f3df57c4b..486331631ec 100644 --- a/velox/functions/sparksql/aggregates/SumAggregate.cpp +++ b/velox/functions/sparksql/aggregates/SumAggregate.cpp @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "velox/functions/sparksql/aggregates/SumAggregate.h" + #include "velox/functions/lib/aggregates/SumAggregateBase.h" using namespace facebook::velox::functions::aggregate; @@ -24,7 +26,7 @@ template using SumAggregate = SumAggregateBase; } -void registerSum(const std::string& name) { +exec::AggregateRegistrationResult registerSum(const std::string& name) { std::vector> signatures{ exec::AggregateFunctionSignatureBuilder() .returnType("real") @@ -46,7 +48,7 @@ void registerSum(const std::string& name) { .build()); } - exec::registerAggregateFunction( + return exec::registerAggregateFunction( name, std::move(signatures), [name]( diff --git a/velox/functions/sparksql/aggregates/SumAggregate.h b/velox/functions/sparksql/aggregates/SumAggregate.h index 01712756f71..fbeb4198a9a 100644 --- a/velox/functions/sparksql/aggregates/SumAggregate.h +++ b/velox/functions/sparksql/aggregates/SumAggregate.h @@ -18,8 +18,10 @@ #include +#include "velox/exec/Aggregate.h" + namespace facebook::velox::functions::aggregate::sparksql { -void registerSum(const std::string& name); +exec::AggregateRegistrationResult registerSum(const std::string& name); } // namespace facebook::velox::functions::aggregate::sparksql