Commit 038691b
feat: support SQL aggregate FILTER (WHERE ...) clause in native execution
Previously, Comet fell back to Spark for any aggregation containing
a FILTER (WHERE ...) clause (e.g. SUM(x) FILTER (WHERE y > 0)).
The native SumInt/SumDecimal accumulators already received opt_filter
support in the previous commit. This commit wires the full pipeline:
Proto (expr.proto):
- Add optional Expr filter = 89 to AggExpr message
Scala serialization (QueryPlanSerde.scala):
- In aggExprToProto, serialize aggExpr.filter into the proto when
aggExpr.mode == Partial (filters are only meaningful in partial mode)
- If the filter expression cannot be serialized, fall back gracefully
Native planner (planner.rs):
- Build per-aggregate filter PhysicalExpr from agg_expr.filter
- Pass to AggregateExec::try_new instead of vec![None; num_agg]
Comet planner (operators.scala):
- Remove the blanket fallback guard for aggregate expressions with filter
Tests (aggregate_filter.sql):
- Update queries from expect_fallback to plain query mode now that
native execution is supported; tests verify results match Spark
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 3e44050 commit 038691b
5 files changed
Lines changed: 42 additions & 17 deletions
File tree
- native
- core/src/execution
- proto/src/proto
- spark/src
- main/scala/org/apache
- comet/serde
- spark/sql/comet
- test/resources/sql-tests/expressions/aggregate
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
975 | 975 | | |
976 | 976 | | |
977 | 977 | | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
978 | 993 | | |
979 | 994 | | |
980 | 995 | | |
981 | 996 | | |
982 | 997 | | |
983 | | - | |
| 998 | + | |
984 | 999 | | |
985 | 1000 | | |
986 | 1001 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
| |||
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
520 | | - | |
| 520 | + | |
521 | 521 | | |
522 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
523 | 535 | | |
524 | 536 | | |
525 | 537 | | |
526 | | - | |
| 538 | + | |
527 | 539 | | |
528 | 540 | | |
529 | 541 | | |
| |||
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1362 | 1362 | | |
1363 | 1363 | | |
1364 | 1364 | | |
1365 | | - | |
1366 | | - | |
1367 | | - | |
1368 | | - | |
1369 | | - | |
1370 | | - | |
1371 | 1365 | | |
1372 | 1366 | | |
1373 | 1367 | | |
| |||
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
0 commit comments