Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions velox/docs/functions/presto/aggregate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ General Aggregate Functions

Returns an arbitrary non-null value of ``x``, if one exists.

.. function:: any_value(x) -> [same as x]

This is an alias for :func:`arbitrary(x)`.

.. function:: array_agg(x) -> array<[same as x]>

Returns an array created from the input ``x`` elements. Ignores null
Expand Down
1 change: 1 addition & 0 deletions velox/functions/prestosql/aggregates/AggregateNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const char* const kApproxMostFrequent = "approx_most_frequent";
const char* const kApproxPercentile = "approx_percentile";
const char* const kApproxSet = "approx_set";
const char* const kArbitrary = "arbitrary";
const char* const kAnyValue = "any_value";
const char* const kArrayAgg = "array_agg";
const char* const kAvg = "avg";
const char* const kBitwiseAnd = "bitwise_and_agg";
Expand Down
11 changes: 5 additions & 6 deletions velox/functions/prestosql/aggregates/ArbitraryAggregate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ class NonNumericArbitrary : public exec::Aggregate {

} // namespace

exec::AggregateRegistrationResult registerArbitraryAggregate(
const std::string& prefix) {
void registerArbitraryAggregate(const std::string& prefix) {
std::vector<std::shared_ptr<exec::AggregateFunctionSignature>> signatures{
exec::AggregateFunctionSignatureBuilder()
.typeVariable("T")
Expand All @@ -266,11 +265,11 @@ exec::AggregateRegistrationResult registerArbitraryAggregate(
.argumentType("T")
.build()};

auto name = prefix + kArbitrary;
return exec::registerAggregateFunction(
name,
std::vector<std::string> names = {prefix + kArbitrary, prefix + kAnyValue};
exec::registerAggregateFunction(
names,
std::move(signatures),
[name](
[name = names.front()](
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is used for error message. I passed the first name, also open to pass a concatenated string like "arbitrary/any_value".

core::AggregationNode::Step step,
const std::vector<TypePtr>& argTypes,
const TypePtr& /*resultType*/,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ extern exec::AggregateRegistrationResult registerApproxMostFrequentAggregate(
extern exec::AggregateRegistrationResult registerApproxPercentileAggregate(
const std::string& prefix,
bool withCompanionFunctions);
extern exec::AggregateRegistrationResult registerArbitraryAggregate(
const std::string& prefix);
void registerArbitraryAggregate(const std::string& prefix);
extern exec::AggregateRegistrationResult registerArrayAggAggregate(
const std::string& prefix,
bool withCompanionFunctions);
Expand Down
4 changes: 2 additions & 2 deletions velox/functions/prestosql/aggregates/tests/ArbitraryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ TEST_F(ArbitraryTest, noNulls) {
std::vector<std::string> aggregates = {
"arbitrary(c1)",
"arbitrary(c2)",
"arbitrary(c3)",
"any_value(c3)",
"arbitrary(c4)",
"arbitrary(c5)",
"arbitrary(c6)"};
"any_value(c6)"};

// We do not test with TableScan because having two input splits makes the
// result non-deterministic.
Expand Down