apache / apache/gluten

[VL] Add support of percentile_approx / approx_percentile

Open
#4,889 8 comments 0 reactions 1 assignee Assigned to @WangGuangxin View on GitHub
enhancement
Dominant language
Scala
Stars
1.6k
Forks
657
Avg merge
2d 14h
Merged PRs (30d)
80

Description

### Description

Part of https://github.com/apache/incubator-gluten/issues/4039

Velox(presto)'s `approx_percentile` has different intermediate types with Spark's function with same name.

Velox's signature code of `approx_percentile` :

```cpp
void addSignatures(
const std::string& inputType,
const std::string& percentileType,
const std::string& returnType,
std::vector>&
signatures) {
auto intermediateType = fmt::format(
"row(array(double), boolean, double, integer, bigint, {0}, {0}, array({0}), array(integer))",
inputType);
signatures.push_back(exec::AggregateFunctionSignatureBuilder()
.returnType(returnType)
.intermediateType(intermediateType)
.argumentType(inputType)
.argumentType(percentileType)
.build());
signatures.push_back(exec::AggregateFunctionSignatureBuilder()
.returnType(returnType)
.intermediateType(intermediateType)
.argumentType(inputType)
.argumentType("bigint")
.argumentType(percentileType)
.build());
signatures.push_back(exec::AggregateFunctionSignatureBuilder()
.returnType(returnType)
.intermediateType(intermediateType)
.argumentType(inputType)
.argumentType(percentileType)
.argumentType("double")
.build());
signatures.push_back(exec::AggregateFunctionSignatureBuilder()
.returnType(returnType)
.intermediateType(intermediateType)
.argumentType(inputType)
.argumentType("bigint")
.argumentType(percentileType)
.argumentType("double")
.build());
}
```

Link https://github.com/facebookincubator/velox/blob/main/velox/functions/prestosql/aggregates/ApproxPercentileAggregate.cpp#L790C1-L828C1

Spark's code of `approx_percentile` / `percentile_approx`:
https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/ApproximatePercentile.scala

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.