Zoltan Borok-Nagy has uploaded this change for review. ( 
https://gerrit.cloudera.org/25369


Change subject: PROTOTYPE IMPALA-15651: Skip an optional Calcite stage that 
throws
......................................................................

PROTOTYPE IMPALA-15651: Skip an optional Calcite stage that throws

An exception in any CalciteOptimizer program fails the whole Calcite
plan, so the query falls back to the original planner or fails. The
CTE substitution stage (runCTEProgram(), active with CTE_THRESHOLD > 0)
only improves the plan and could be skipped instead. TPC-DS q78 with
CTE_THRESHOLD=1 and the IMPALA-15489 change (CR 25030 PS1) hits this:
MaterializedViewJoinRule throws "Type mismatch: the field sizes are not
equal".

CalciteOptimizer now runs the CTE stage through runOptionalStage(). If
the stage throws anything but OutOfMemoryError, it logs a WARN with the
stack, clears what the MV rewrite registered in the cluster's planner,
invalidates the metadata query, records the stage and the exception in
the CalciteSkippedStages info string of the Frontend profile and in the
compilation timeline, and continues with the stage's input plan, which
HepPlanner and VolcanoPlanner leave intact. Essential stages still fail
the Calcite plan. In FE tests (RuntimeEnv.isTestEnv()) the exception is
rethrown, so planner tests still catch a broken stage.

The helper is meant for other optional stages too. Applied to the
aggregate-join transpose program of IMPALA-15668, it keeps TPC-DS q23
on Calcite: at SF10000 on 12 executors q23_1 368 -> 108 s and q23_2
231 -> 91 s. Skipping is not always faster than falling back: q78
without CTEs took 154 s, with the original planner 144 s.

Testing:
- Compiled only; not run. No new tests.

Change-Id: Ib06d3ecea89711bca54ecc3e207c10632657b82a
Assisted-by: Claude Opus 5.5 (Claude Code)
---
M 
java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
1 file changed, 62 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/69/25369/1
--
To view, visit https://gerrit.cloudera.org/25369
To unsubscribe, visit https://gerrit.cloudera.org/settings

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

Reply via email to