Michael Smith has posted comments on this change. (
http://gerrit.cloudera.org:8080/22091 )
Change subject: IMPALA-13531: Calcite CTE frontend
......................................................................
Patch Set 25:
(1 comment)
> Patch Set 25:
>
> WITH v as (SELECT i current price p FROM item WHERE i color = 'red'),
> w as (SELECT v1.p FROM v as v1, v as v2 WHERE v1.p < v2.p)
> SELECT * FROM v as v3, w as w1, w as w2
> WHERE v3.p < w1.p + w2.p;
>
> Hi, can you add this case?
>
> this case from 'Optimization of Common Table Expressions in MPP Database
> Systems'
This produces the logical plan
ImpalaSequence, id = 2313
LogicalProject(P=[$0], P0=[$3], P1=[$1]), id = 2310
LogicalJoin(condition=[<(CAST($0):BIGINT, +(CAST($3):BIGINT,
CAST($1):BIGINT))], joinType=[inner]), id = 2308
LogicalJoin(condition=[<($1, $2)], joinType=[inner]), id = 2302
LogicalJoin(condition=[true], joinType=[inner]), id = 2299
ImpalaCTEConsumer(cteName=[cte_suggestion_0]), id = 2232
ImpalaCTEConsumer(cteName=[cte_suggestion_0]), id = 2232
ImpalaCTEConsumer(cteName=[cte_suggestion_0]), id = 2232
LogicalJoin(condition=[<($0, $1)], joinType=[inner]), id = 2306
ImpalaCTEConsumer(cteName=[cte_suggestion_0]), id = 2232
ImpalaCTEConsumer(cteName=[cte_suggestion_0]), id = 2232
ImpalaCTEProducer(readType=[EAGER], writeType=[EAGER],
cteName=[cte_suggestion_0]), id = 2312
LogicalProject(P=[$0]), id = 2212
LogicalFilter(condition=[AND(=($1, _UTF-8'red'), IS NOT NULL($0))]), id =
2210
LogicalTableScan(table=[[default, item]]), id = 1675
Are you just looking for whether it matches this case? Or a specific set of
CTEs?
http://gerrit.cloudera.org:8080/#/c/22091/25/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
File
java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java:
http://gerrit.cloudera.org:8080/#/c/22091/25/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java@405
PS25, Line 405: return new ImpalaSequence(inputs);
> in a query, there are at most one ImpalaSequence?
Yes, currently this is added at the top of the query after creating the syntax
tree. We could get more granular, but I didn't bother since it gets removed in
distributed query planning, which covers most cases.
--
To view, visit http://gerrit.cloudera.org:8080/22091
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id0840c0859d2fe25628d799a18d302cee1eb36e8
Gerrit-Change-Number: 22091
Gerrit-PatchSet: 25
Gerrit-Owner: Michael Smith <[email protected]>
Gerrit-Reviewer: Anonymous Coward (816)
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Joe McDonnell <[email protected]>
Gerrit-Reviewer: Michael Smith <[email protected]>
Gerrit-Reviewer: Steve Carlin <[email protected]>
Gerrit-Comment-Date: Tue, 03 Mar 2026 00:08:38 +0000
Gerrit-HasComments: Yes