Skip to content

Commit 764869e

Browse files
committed
test: cover native DISTINCT rewrite fallback guards
Add EXPLAIN regressions for mixed aggregates and unknown specialized DISTINCT support with native planning enabled and one target partition. Generated-by: OpenAI Codex
1 parent 0db14a0 commit 764869e

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎datafusion/sqllogictest/test_files/grouped_count_distinct.slt‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ logical_plan
7070
03)----Aggregate: groupBy=[[numeric_counts.g, numeric_counts.f AS alias1]], aggr=[[]]
7171
04)------TableScan: numeric_counts projection=[g, f]
7272

73+
# A non-DISTINCT aggregate alongside keeps the rewrite.
74+
query TT
75+
EXPLAIN SELECT g, count(DISTINCT x), sum(x) FROM numeric_counts GROUP BY g;
76+
----
77+
logical_plan
78+
01)Projection: numeric_counts.g, count(alias1) AS count(DISTINCT numeric_counts.x), sum(alias2) AS sum(numeric_counts.x)
79+
02)--Aggregate: groupBy=[[numeric_counts.g]], aggr=[[count(alias1), sum(alias2)]]
80+
03)----Aggregate: groupBy=[[numeric_counts.g, numeric_counts.x AS alias1]], aggr=[[sum(CAST(numeric_counts.x AS Int64)) AS alias2]]
81+
04)------TableScan: numeric_counts projection=[g, x]
82+
83+
# `sum` does not report specialized DISTINCT support, so it keeps the rewrite.
84+
query TT
85+
EXPLAIN SELECT g, sum(DISTINCT x) FROM numeric_counts GROUP BY g;
86+
----
87+
logical_plan
88+
01)Projection: numeric_counts.g, sum(alias1) AS sum(DISTINCT numeric_counts.x)
89+
02)--Aggregate: groupBy=[[numeric_counts.g]], aggr=[[sum(alias1)]]
90+
03)----Aggregate: groupBy=[[numeric_counts.g, CAST(numeric_counts.x AS Int64) AS alias1]], aggr=[[]]
91+
04)------TableScan: numeric_counts projection=[g, x]
92+
7393
# The global aggregate does not use a GroupsAccumulator.
7494
query TT
7595
EXPLAIN SELECT count(DISTINCT x) FROM numeric_counts;

0 commit comments

Comments
 (0)