Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void register_aggregate_function_percentile(AggregateFunctionSimpleFactory& fact
creator_with_numeric_type::creator<AggregateFunctionPercentile>);
factory.register_function_both(
"percentile_array",
creator_with_integer_type::creator<AggregateFunctionPercentileArray>);
creator_with_numeric_type::creator<AggregateFunctionPercentileArray>);
}

void register_percentile_approx_old_function(AggregateFunctionSimpleFactory& factory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.doris.nereids.types.ArrayType;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.DoubleType;
import org.apache.doris.nereids.types.FloatType;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.LargeIntType;
import org.apache.doris.nereids.types.SmallIntType;
Expand All @@ -45,6 +46,10 @@ public class PercentileArray extends AggregateFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNotNullable {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
.args(DoubleType.INSTANCE, ArrayType.of(DoubleType.INSTANCE)),
FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
.args(FloatType.INSTANCE, ArrayType.of(DoubleType.INSTANCE)),
FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
.args(LargeIntType.INSTANCE, ArrayType.of(DoubleType.INSTANCE)),
FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@
5 29.0 29.0 29.0 [29, 29, 29]
6 101.0 101.0 101.0 [101, 101, 101]

-- !select --
[19.5, 24.25, 101.325]

Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,21 @@ suite("test_aggregate_percentile_no_cast") {
sql "INSERT INTO percentile_test_db values(1,10), (2,8), (2,114) ,(3,10) ,(5,29) ,(6,101)"
qt_select "select id,percentile(level,0.5) , percentile(level,0.55) , percentile(level,0.805) , percentile_array(level,[0.5,0.55,0.805])from percentile_test_db group by id order by id"

sql "DROP TABLE IF EXISTS percentile_test_db2"
sql """
CREATE TABLE IF NOT EXISTS percentile_test_db2 (
id int,
level double
)
DISTRIBUTED BY HASH(id) BUCKETS 1
PROPERTIES (
"replication_num" = "1"
)
"""
explain {
sql("""select percentile_array(level,[0.5,0.55,0.805])from percentile_test_db2;""")
notContains("cast")
}
sql "INSERT INTO percentile_test_db2 values(1,10.1), (2,8.2), (2,114.3) ,(3,10.4) ,(5,29.5) ,(6,101.6)"
qt_select "select percentile_array(level,[0.5,0.55,0.805])from percentile_test_db2;"
}