[VL] Add support of percentile_approx / approx_percentile
- 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
Assessment
This issue has not been assessed yet.