diff --git a/src/frontend/planner_test/tests/testdata/input/agg.yaml b/src/frontend/planner_test/tests/testdata/input/agg.yaml index 75aa7249accce..9310a826a691e 100644 --- a/src/frontend/planner_test/tests/testdata/input/agg.yaml +++ b/src/frontend/planner_test/tests/testdata/input/agg.yaml @@ -1070,6 +1070,13 @@ expected_outputs: - logical_plan - stream_plan +- name: test approx_percentile hash_agg forced should use single phase agg + sql: | + SET RW_FORCE_TWO_PHASE_AGG=true; + create table t (v1 int, grp_col int); + select approx_percentile(0.5, 0.01) WITHIN GROUP (order by v1) from t group by grp_col; + expected_outputs: + - stream_error - name: test approx percentile with default relative_error sql: | CREATE TABLE t (v1 int); diff --git a/src/frontend/planner_test/tests/testdata/output/agg.yaml b/src/frontend/planner_test/tests/testdata/output/agg.yaml index 9fd70f1fb28fd..97d440b64df12 100644 --- a/src/frontend/planner_test/tests/testdata/output/agg.yaml +++ b/src/frontend/planner_test/tests/testdata/output/agg.yaml @@ -2103,6 +2103,14 @@ └─StreamHashAgg { group_key: [$expr5], aggs: [sum(t.v1), count, max(t.v2)] } └─StreamProject { exprs: [t.v1, t.v1::Float64 as $expr3, t.v2, t.v2::Float64 as $expr4, t._row_id, Vnode(t._row_id) as $expr5] } └─StreamTableScan { table: t, columns: [t.v1, t.v2, t._row_id], stream_scan_type: ArrangementBackfill, stream_key: [t._row_id], pk: [_row_id], dist: UpstreamHashShard(t._row_id) } +- name: test approx_percentile hash_agg forced should use single phase agg + sql: | + SET RW_FORCE_TWO_PHASE_AGG=true; + create table t (v1 int, grp_col int); + select approx_percentile(0.5, 0.01) WITHIN GROUP (order by v1) from t group by grp_col; + stream_error: |- + Feature is not yet implemented: two-phase streaming approx percentile aggregation with group key, please use single phase aggregation instead + No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml - name: test approx percentile with default relative_error sql: | CREATE TABLE t (v1 int); diff --git a/src/frontend/src/optimizer/plan_node/logical_agg.rs b/src/frontend/src/optimizer/plan_node/logical_agg.rs index e63b7d760a68f..cf7025be90872 100644 --- a/src/frontend/src/optimizer/plan_node/logical_agg.rs +++ b/src/frontend/src/optimizer/plan_node/logical_agg.rs @@ -311,7 +311,10 @@ impl LogicalAgg { col_mapping: approx_percentile_col_mapping, } = approx; if !self.group_key().is_empty() && !approx_percentile_agg_calls.is_empty() { - bail_not_implemented!("two-phase approx percentile agg with group key, please use single phase agg for approx_percentile with group key"); + bail_not_implemented!( + "two-phase streaming approx percentile aggregation with group key, \ + please use single phase aggregation instead" + ); } // Either we have approx percentile aggs and non_approx percentile aggs,