Zoltan Borok-Nagy has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/25072


Change subject: PROTOTYPE IMPALA-15524: Keep selective DISTINCT under Calcite 
semi-joins
......................................................................

PROTOTYPE IMPALA-15524: Keep selective DISTINCT under Calcite semi-joins

ProjectToSemiJoinRule rewrites Project(InnerJoin(left, Aggregate(x)))
into Project(SemiJoin(left, x)) when the join keys are the group keys.
When the Aggregate reduces its input a lot, this is a bad trade for
Impala: the whole input is shuffled and built into the hash table,
whereas with the Aggregate a streaming pre-aggregation runs before
the exchange. In TPC-DS q14_1 all 43M web_sales rows are shuffled 15
times instead of 87.75K pre-aggregated rows.

The new ImpalaProjectToSemiJoinRule produces
Project(SemiJoin(left, Aggregate(x))) instead when the Aggregate is a
plain DISTINCT whose estimated input has at least 1M rows and is more
than 10x its estimated output. Otherwise it behaves like Calcite's
rule. The join condition is reused verbatim, because the right input's
row type does not change, and every left row matches at most one
Aggregate row.

Testing:
- Among the 104 TPC-DS queries, only q14_1's plan changes.
- Together with IMPALA-15523, TPC-DS SF100 at MT_DOP=8 and
  CTE_THRESHOLD=1: q14_1 22.3 s -> 7.0 s, total 147.0 s -> 128.4 s.
  No new tests.

Change-Id: Ia59f136a695ff4ee7a90c77e7e65e58ce51c3f2a
Assisted-by: Claude Opus 5.5 (Claude Code)
---
M 
java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaCoreRules.java
A 
java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaProjectToSemiJoinRule.java
2 files changed, 131 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/72/25072/1
--
To view, visit http://gerrit.cloudera.org:8080/25072
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia59f136a695ff4ee7a90c77e7e65e58ce51c3f2a
Gerrit-Change-Number: 25072
Gerrit-PatchSet: 1
Gerrit-Owner: Zoltan Borok-Nagy <[email protected]>

Reply via email to