diff --git a/be/src/vec/aggregate_functions/aggregate_function_percentile.h b/be/src/vec/aggregate_functions/aggregate_function_percentile.h index dbd52af923f71b..9dfb31864bae84 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_percentile.h +++ b/be/src/vec/aggregate_functions/aggregate_function_percentile.h @@ -383,6 +383,7 @@ struct PercentileState { inited_flag = true; vec_counts.resize(1); vec_quantile.resize(1); + check_quantile(q); vec_quantile[0] = q; } vec_counts[0].increment_batch(source); diff --git a/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions.groovy b/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions.groovy index c64d33e1e82b81..e9683ffb92bbbc 100644 --- a/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions.groovy +++ b/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions.groovy @@ -299,6 +299,28 @@ suite("test_aggregate_all_functions", "arrow_flight_sql") { assert("${ex}".contains("3000")) } + sql """ + drop table if exists percentile_input_no_nullable; + """ + sql """ + create table percentile_input_no_nullable(a int, b int not null) properties ("replication_num" = "1"); + """ + sql """ + insert into percentile_input_no_nullable values (10, 100), (20,200), (30, 300), (40, 400); + """ + + try { + sql " select percentile(b, -1) from percentile_input_no_nullable;" + } catch (Exception ex) { + assert("${ex}".contains("-1")) + } + + try { + sql " select percentile(b, 3000) from percentile_input_no_nullable;" + } catch (Exception ex) { + assert("${ex}".contains("3000")) + } + sql "DROP TABLE IF EXISTS ${tableName_13}"