You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Steve Carlin (Code Review)" <ge...@cloudera.org> on 2024/07/01 20:23:31 UTC

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Steve Carlin has uploaded this change for review. ( http://gerrit.cloudera.org:8080/21239


Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................

IMPALA-13043: Implement Join Capability to the Calcite Planner

This commit adds the ability to handle joins in the Calcite planner.

Some of the items worth noting:

There is extra handling in the ImpalaJoinRel class to deal with outer
joins.  The AnalyzedTupleIsNullExpr object is needed for processing
which derives from TupleIsNullExpr. Normally, expressions are created
in the CreateExprVisitor, but the join requires that the TupleIsNullExpr
object is wrapped around the expressions retrieved from the inputs.

The execution engine requires separation of the equijoin conditions and
the non-equijoin conditions. Furthermore, the equijoin conditions are
BinaryCompPredicates instead of normal FunctionCallExprs, so the
AnalyzedBinaryCompExpr class had to be created.

Special processing needed to be coded for runtime filter generators.
The conditions needed to be added to the value transfer graph in order
to enable the Impala planner logic to create and push these generators.

There is some special case logic in the join that requires the execution
engine to run on a single node. The original logic can be found in the
JoinNode planner object, but this code isn't executed. The new mechanism
for checking single node executions is passed back to the root via the
NodeWithExprs object, and is checked in the ImpalaJoinRel.useSingleNode
method.

The join also required some rules to be added to the optimizer. If a join
is done through the "ON" clause, Calcite is able to place the join
condition directly in the Join RelNode. However, if it is in the "WHERE"
clause, Calcite creates a Filter RelNode and creates a cross join RelNode
object. Therefore, in order to handle "WHERE" joins, we need to implement
the rules in the optimizer.

Change-Id: I5db097577907d79877f52feff2922000af074ecd
---
A java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedTupleIsNullExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ConvertToImpalaRelRules.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaAggRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaHdfsScanRel.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaPlanRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaProjectRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaSortRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaValuesRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeWithExprs.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaNestedLoopJoinNode.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/type/ImpalaTypeConverter.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
22 files changed, 1,018 insertions(+), 37 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/39/21239/9
-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 9
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 11:

(10 comments)

http://gerrit.cloudera.org:8080/#/c/21239/11/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java:

http://gerrit.cloudera.org:8080/#/c/21239/11/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@223
PS11, Line 223:    * generates a Left Outer Join and checks the nullability of the column being output from
line too long (91 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/11/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@224
PS11, Line 224:    * the right side of the LOJ. Since the literal TRUE is a non-null value coming into the join
line too long (95 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/11/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@225
PS11, Line 225:    * but after the join becomes nullable, we add this function to ensure that happens. Without
line too long (94 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/11/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@226
PS11, Line 226:    * adding this function the direct translation would be 'TRUE IS NULL' which is incorrect.
line too long (92 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/11/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@446
PS11, Line 446:     // node. This is checked during the validatePlan(). In some cases, the check for small query
line too long (96 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/11/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@447
PS11, Line 447:     // optimization (done at the end of the single node planning phase) will determine that the
line too long (95 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/11/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@448
PS11, Line 448:     // cardinality of the query is lower than the exec_single_node_rows_threshold and will force
line too long (96 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/11/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@449
PS11, Line 449:     // the num_nodes = 1. However, that check gets bypassed for some tests run through the test
line too long (95 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/11/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@454
PS11, Line 454:         (joinOp == JoinOperator.RIGHT_OUTER_JOIN || joinOp == JoinOperator.FULL_OUTER_JOIN) &&
line too long (94 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/11/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java:

http://gerrit.cloudera.org:8080/#/c/21239/11/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java@43
PS11, Line 43:     super(leftInput, rightInput, isStraightJoin, distMode, joinOp, equiJoinConjuncts, nonEquijoinConjuncts);
line too long (108 > 90)



-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 11
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Mon, 08 Jul 2024 23:12:00 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Steve Carlin has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 16:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/21239/16//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/21239/16//COMMIT_MSG@28
PS16, Line 28: There is some special case logic in the join that requires the execution
             : engine to run on a single node. The original logic can be found in the
             : JoinNode planner object, but this code isn't executed. The new mechanism
             : for checking single node executions is passed back to the root via the
             : NodeWithExprs object, and is checked in the ImpalaJoinRel.useSingleNode
             : method.
> I'm comparing this to how the legacy planner worked. Is there a specific SQ
Ok...I had to reexamine this. I didn't code this part the first time and put this in based on some comments I saw in a draft that was created outside of this commit...

This logic is based on the logic in SingleNodePlanner.validatePlan(), which is the only case the num nodes is used right now.  I haven't checked e2e tests to see where this is tested.

But on second glance, we throw an exception in this case.  Now I'm wondering if I should revisit this logic and instead of setting numNodes to 1, if we should set an exception?  It would simplify the code. I'm not sure it would break something else, but maybe I should make this change.  

I do want your thoughts on this because perhaps I'm missing some nuance in the existing logic.  But if there is, we'll probably catch it later when implementing all e2e tests.


http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java:

http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java@65
PS16, Line 65:     return 1;
> Nit: Does it matter that this is 1 versus UNKNOWN_COST? (Not a real issue s
Yeah, IIRC (and I may be misremembering) I think it crashed in PlanNode.orderConjunctsByCost() because it needed an actual cost defined.


http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java:

http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@258
PS16, Line 258:       // Mapping it to a Left Semi Join in Impala seems to make
              :       // sense since it is unclear when we would need a
              :       // Right Semi Join
              :       return JoinOperator.LEFT_SEMI_JOIN;
> Looking at the Calcite code, it looks like Calcite's SEMI join is by defini
Yeah, we're probably going to have to make some Calcite changes to handle this.  From what I've seen of Calcite, it doesn't handle RIGHT_SEMI_JOIN.

I can put a TODO here and file a Jira if you think that's what is best.


http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java:

http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java@120
PS16, Line 120:     if (useSingleNode) {
              :       plannerContext.getQueryOptions().setNum_nodes(1);
              :     }
> For the plans that set num_nodes=1 here, would any of them get fixed by the
My hope is that by the end of this project, there is no need to call "invertJoins", though this may be impossible. I haven't looked at invertJoins too closely.  Are there physical node reasons why we would invert the join?  Because if it's all based on stats and even if there are query options, it really should be handled in the logical optimization of the plan. And if so, then by the time it hits this portion, the plan should be set.

But see my comment above in the "commit message".  Perhaps I should be throwing an exception here.

And yes, I think later join tests will help test this.



-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 16
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Fri, 30 Aug 2024 15:15:39 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................

IMPALA-13043: Implement Join Capability to the Calcite Planner

This commit adds the ability to handle joins in the Calcite planner.

Some items worth noting:

There is extra handling in the ImpalaJoinRel class to deal with outer
joins.  The AnalyzedTupleIsNullExpr object is needed for processing
which derives from TupleIsNullExpr. Normally, expressions are created
in the CreateExprVisitor, but the join requires that the TupleIsNullExpr
object is wrapped around the expressions retrieved from the inputs.

The execution engine requires separation of the equijoin conditions and
the non-equijoin conditions. Furthermore, the equijoin conditions are
BinaryCompPredicates instead of normal FunctionCallExprs, so the
AnalyzedBinaryCompExpr class had to be created.

Special processing needed to be coded for runtime filter generators.
The conditions needed to be added to the value transfer graph in order
to enable the Impala planner logic to create and push these generators.

The join also required some rules to be added to the optimizer. If a join
is done through the "ON" clause, Calcite is able to place the join
condition directly in the Join RelNode. However, if it is in the "WHERE"
clause, Calcite creates a Filter RelNode and creates a cross join RelNode
object. Therefore, in order to handle "WHERE" joins, we need to implement
the rules in the optimizer.

Change-Id: I5db097577907d79877f52feff2922000af074ecd
Reviewed-on: http://gerrit.cloudera.org:8080/21239
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Reviewed-by: Michael Smith <mi...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
A java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ConvertToImpalaRelRules.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaAggRel.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaPlanRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaProjectRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaSortRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeWithExprs.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaNestedLoopJoinNode.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/type/ImpalaTypeConverter.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
18 files changed, 896 insertions(+), 46 deletions(-)

Approvals:
  Impala Public Jenkins: Looks good to me, approved; Verified
  Michael Smith: Looks good to me, but someone else must approve

-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 21
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 13:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/16488/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 13
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Thu, 11 Jul 2024 00:21:13 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 11:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/16467/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 11
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Mon, 08 Jul 2024 23:36:48 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Michael Smith (Code Review)" <ge...@cloudera.org>.
Michael Smith has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 20: Code-Review+1


-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 20
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Thu, 05 Sep 2024 16:19:43 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Joe McDonnell has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 19: Code-Review+2

Ok, this looks good to me. I'll start a test job


-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 19
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Thu, 05 Sep 2024 16:06:01 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 19:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/16878/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 19
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 04 Sep 2024 19:40:01 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Joe McDonnell, Csaba Ringhofer, Michael Smith, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/21239

to look at the new patch set (#13).

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................

IMPALA-13043: Implement Join Capability to the Calcite Planner

This commit adds the ability to handle joins in the Calcite planner.

Some of the items worth noting:

There is extra handling in the ImpalaJoinRel class to deal with outer
joins.  The AnalyzedTupleIsNullExpr object is needed for processing
which derives from TupleIsNullExpr. Normally, expressions are created
in the CreateExprVisitor, but the join requires that the TupleIsNullExpr
object is wrapped around the expressions retrieved from the inputs.

The execution engine requires separation of the equijoin conditions and
the non-equijoin conditions. Furthermore, the equijoin conditions are
BinaryCompPredicates instead of normal FunctionCallExprs, so the
AnalyzedBinaryCompExpr class had to be created.

Special processing needed to be coded for runtime filter generators.
The conditions needed to be added to the value transfer graph in order
to enable the Impala planner logic to create and push these generators.

There is some special case logic in the join that requires the execution
engine to run on a single node. The original logic can be found in the
JoinNode planner object, but this code isn't executed. The new mechanism
for checking single node executions is passed back to the root via the
NodeWithExprs object, and is checked in the ImpalaJoinRel.useSingleNode
method.

The join also required some rules to be added to the optimizer. If a join
is done through the "ON" clause, Calcite is able to place the join
condition directly in the Join RelNode. However, if it is in the "WHERE"
clause, Calcite creates a Filter RelNode and creates a cross join RelNode
object. Therefore, in order to handle "WHERE" joins, we need to implement
the rules in the optimizer.

Change-Id: I5db097577907d79877f52feff2922000af074ecd
---
A java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ConvertToImpalaRelRules.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaAggRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaHdfsScanRel.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaPlanRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaProjectRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaSortRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaValuesRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeWithExprs.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaNestedLoopJoinNode.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/type/ImpalaTypeConverter.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
21 files changed, 941 insertions(+), 52 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/39/21239/13
-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 13
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Joe McDonnell, Csaba Ringhofer, Michael Smith, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/21239

to look at the new patch set (#11).

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................

IMPALA-13043: Implement Join Capability to the Calcite Planner

This commit adds the ability to handle joins in the Calcite planner.

Some of the items worth noting:

There is extra handling in the ImpalaJoinRel class to deal with outer
joins.  The AnalyzedTupleIsNullExpr object is needed for processing
which derives from TupleIsNullExpr. Normally, expressions are created
in the CreateExprVisitor, but the join requires that the TupleIsNullExpr
object is wrapped around the expressions retrieved from the inputs.

The execution engine requires separation of the equijoin conditions and
the non-equijoin conditions. Furthermore, the equijoin conditions are
BinaryCompPredicates instead of normal FunctionCallExprs, so the
AnalyzedBinaryCompExpr class had to be created.

Special processing needed to be coded for runtime filter generators.
The conditions needed to be added to the value transfer graph in order
to enable the Impala planner logic to create and push these generators.

There is some special case logic in the join that requires the execution
engine to run on a single node. The original logic can be found in the
JoinNode planner object, but this code isn't executed. The new mechanism
for checking single node executions is passed back to the root via the
NodeWithExprs object, and is checked in the ImpalaJoinRel.useSingleNode
method.

The join also required some rules to be added to the optimizer. If a join
is done through the "ON" clause, Calcite is able to place the join
condition directly in the Join RelNode. However, if it is in the "WHERE"
clause, Calcite creates a Filter RelNode and creates a cross join RelNode
object. Therefore, in order to handle "WHERE" joins, we need to implement
the rules in the optimizer.

Change-Id: I5db097577907d79877f52feff2922000af074ecd
---
A java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ConvertToImpalaRelRules.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaAggRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaHdfsScanRel.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaPlanRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaProjectRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaSortRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaValuesRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeWithExprs.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaNestedLoopJoinNode.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/type/ImpalaTypeConverter.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
21 files changed, 939 insertions(+), 37 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/39/21239/11
-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 11
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Steve Carlin has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 16:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java:

http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@258
PS16, Line 258:       // Mapping it to a Left Semi Join in Impala seems to make
              :       // sense since it is unclear when we would need a
              :       // Right Semi Join
              :       return JoinOperator.LEFT_SEMI_JOIN;
> Yeah, this is not a blocker for this change. Let's update this comment to s
Done


http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java:

http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java@120
PS16, Line 120:     if (useSingleNode) {
              :       plannerContext.getQueryOptions().setNum_nodes(1);
              :     }
> There are certain joins that we don't support for distributed plans. In par
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 16
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 04 Sep 2024 19:47:45 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Joe McDonnell has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 16:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/21239/16//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/21239/16//COMMIT_MSG@28
PS16, Line 28: There is some special case logic in the join that requires the execution
             : engine to run on a single node. The original logic can be found in the
             : JoinNode planner object, but this code isn't executed. The new mechanism
             : for checking single node executions is passed back to the root via the
             : NodeWithExprs object, and is checked in the ImpalaJoinRel.useSingleNode
             : method.
> Ok...I had to reexamine this. I didn't code this part the first time and pu
Impala's current planner will throw an error for some SQL statements that can't run in a distributed way. For example, a nested loop join with a FULL OUTER join will fail at that location in SingleNodePlanner.validatePlan(). Example SQL:
select *
from functional.alltypestiny a full outer join functional.alltypessmall b
  on a.id != b.id or a.int_col != b.int_col
where a.id < 10;

A user can get around it by setting num_nodes=1. It's a little bit weird, but that is how Impala works today. Maybe an error can be useful, because sometimes users forget to add a join condition and don't realize they are doing something that will be single-threaded.

invertJoins() can convert nested loop join with RIGHT OUTER or RIGHT SEMI into LEFT OUTER / LEFT SEMI joins, which are compatible with being distributed. So, I don't think we want to fail before that runs. (invertJoins() will eventually be a Calcite rule, but for now it can handle this case.)

I think we could drop the num_nodes=1 code and just let it fail at SingleNodePlanner.validatePlan(). I don't think that would impact any of the TPC queries.


http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java:

http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java@65
PS16, Line 65:     return 1;
> Yeah, IIRC (and I may be misremembering) I think it crashed in PlanNode.ord
Ok, makes sense


http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java:

http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@258
PS16, Line 258:       // Mapping it to a Left Semi Join in Impala seems to make
              :       // sense since it is unclear when we would need a
              :       // Right Semi Join
              :       return JoinOperator.LEFT_SEMI_JOIN;
> Yeah, we're probably going to have to make some Calcite changes to handle t
Yeah, this is not a blocker for this change. Let's update this comment to say that Calcite SEMI is always a LEFT SEMI.


http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java:

http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java@120
PS16, Line 120:     if (useSingleNode) {
              :       plannerContext.getQueryOptions().setNum_nodes(1);
              :     }
> My hope is that by the end of this project, there is no need to call "inver
There are certain joins that we don't support for distributed plans. In particular, nested loop join does not support distributed RIGHT OUTER or RIGHT SEMI. So, the current planner prefers to flip those to LEFT OUTER and LEFT SEMI so it can use distributed execution. It doesn't do that based on cost right now, but there is an implicit calculation that a distributed plan is better than a single-node plan. The join inversion can save this from hitting the condition in SingleNodePlanner::validatePlan().



-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 16
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Tue, 03 Sep 2024 19:00:55 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Michael Smith (Code Review)" <ge...@cloudera.org>.
Michael Smith has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 15:

(12 comments)

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java@54
PS15, Line 54:   // c'tor which does not depend on Calcite's RexCall but is used when Impala's
This description doesn't make as much sense to me when you just removed RexCall from the other constructor.


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java@89
PS15, Line 89:     assert params.size() == 2;
We usually use Preconditions.checkArgument.


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java@42
PS15, Line 42: import org.slf4j.Logger;
Why are these split from the other "import org" statements?


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@149
PS15, Line 149:       analyzer.registerConjuncts(getJoinConjunctListToRegister(nonEquiJoinConjuncts));
Why do we skip registering nonEquiJoinConjuncts if equiJoinConjuncts is empty?


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@206
PS15, Line 206:             input.planNode_.getTupleIds())
nit: There's enough space for this to appear on the previous line. We wrap at 90 characters.


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@261
PS15, Line 261:       // Right Semi Join
Does Calcite simply not create Right Anti Joins? It's possible to declare a RIGHT ANTI JOIN, so what does Calcite map that to?


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@304
PS15, Line 304:    * An example query where we the casting adjustment is needed within the Impala test
nit: extra "we", can just say "where we"


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@331
PS15, Line 331:     Preconditions.checkState(joinConjunct.getChildren().size() > 0);
Shouldn't we check that this is == 2?


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@348
PS15, Line 348:       return Lists.newArrayList(joinConjunct.getChild(0), joinConjunct.getChild(1));
I'm not clear how this is only returning the LHS.


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@448
PS15, Line 448:     // check gets bypassed for some tests run through the test framework which explicitly 
nit: extra whitespace at the end


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java@57
PS15, Line 57:     return new NodeWithExprs(selectNode, nodeWithExprs.outputExprs_,
Could this use the simpler call?

  NodeWithExprs(selectNode, nodeWithExprs)


http://gerrit.cloudera.org:8080/#/c/21239/15/testdata/workloads/functional-query/queries/QueryTest/calcite.test
File testdata/workloads/functional-query/queries/QueryTest/calcite.test:

http://gerrit.cloudera.org:8080/#/c/21239/15/testdata/workloads/functional-query/queries/QueryTest/calcite.test@459
PS15, Line 459: # left outer join test
Should we test every type of join? Or leaving that for when we can enable a larger set of tests?



-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 15
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Wed, 28 Aug 2024 19:01:03 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 9:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/16456/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 9
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Mon, 01 Jul 2024 20:49:01 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Joe McDonnell, Csaba Ringhofer, Michael Smith, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/21239

to look at the new patch set (#12).

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................

IMPALA-13043: Implement Join Capability to the Calcite Planner

This commit adds the ability to handle joins in the Calcite planner.

Some of the items worth noting:

There is extra handling in the ImpalaJoinRel class to deal with outer
joins.  The AnalyzedTupleIsNullExpr object is needed for processing
which derives from TupleIsNullExpr. Normally, expressions are created
in the CreateExprVisitor, but the join requires that the TupleIsNullExpr
object is wrapped around the expressions retrieved from the inputs.

The execution engine requires separation of the equijoin conditions and
the non-equijoin conditions. Furthermore, the equijoin conditions are
BinaryCompPredicates instead of normal FunctionCallExprs, so the
AnalyzedBinaryCompExpr class had to be created.

Special processing needed to be coded for runtime filter generators.
The conditions needed to be added to the value transfer graph in order
to enable the Impala planner logic to create and push these generators.

There is some special case logic in the join that requires the execution
engine to run on a single node. The original logic can be found in the
JoinNode planner object, but this code isn't executed. The new mechanism
for checking single node executions is passed back to the root via the
NodeWithExprs object, and is checked in the ImpalaJoinRel.useSingleNode
method.

The join also required some rules to be added to the optimizer. If a join
is done through the "ON" clause, Calcite is able to place the join
condition directly in the Join RelNode. However, if it is in the "WHERE"
clause, Calcite creates a Filter RelNode and creates a cross join RelNode
object. Therefore, in order to handle "WHERE" joins, we need to implement
the rules in the optimizer.

Change-Id: I5db097577907d79877f52feff2922000af074ecd
---
A java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ConvertToImpalaRelRules.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaAggRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaHdfsScanRel.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaPlanRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaProjectRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaSortRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaValuesRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeWithExprs.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaNestedLoopJoinNode.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/type/ImpalaTypeConverter.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
21 files changed, 937 insertions(+), 52 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/39/21239/12
-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 12
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Steve Carlin has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 16:

(12 comments)

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java@54
PS15, Line 54:   // c'tor when FunctionParams are known
> This description doesn't make as much sense to me when you just removed Rex
Done


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java@89
PS15, Line 89:     Preconditions.checkArgument(params.size() == 2);
> We usually use Preconditions.checkArgument.
Done


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java@42
PS15, Line 42: import java.util.List;
> Why are these split from the other "import org" statements?
Done


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@149
PS15, Line 149:     }
> Why do we skip registering nonEquiJoinConjuncts if equiJoinConjuncts is emp
Good catch.


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@206
PS15, Line 206:           : expr;
> nit: There's enough space for this to appear on the previous line. We wrap 
Done


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@261
PS15, Line 261:       return JoinOperator.LEFT_SEMI_JOIN;
> Does Calcite simply not create Right Anti Joins? It's possible to declare a
Yeah, unfortunately, Calcite doesn't have RIGHT ANTI JOIN.  We're gonna have to figure out what to do on those cases.  Might have to implement it in Calcite.


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@304
PS15, Line 304:    * framework is:
> nit: extra "we", can just say "where we"
I assume you meant to delete the "we"?


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@331
PS15, Line 331:     List<SlotRef> leftSideSlotRefs = new ArrayList<>();
> Shouldn't we check that this is == 2?
Done


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@348
PS15, Line 348:       return Lists.newArrayList(joinConjunct.getChild(0), joinConjunct.getChild(1));
> I'm not clear how this is only returning the LHS.
Changed the message.


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@448
PS15, Line 448:     // check gets bypassed for some tests run through the test framework which explicitly
> nit: extra whitespace at the end
Done


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java@57
PS15, Line 57:     return new NodeWithExprs(selectNode, nodeWithExprs);
> Could this use the simpler call?
Done


http://gerrit.cloudera.org:8080/#/c/21239/15/testdata/workloads/functional-query/queries/QueryTest/calcite.test
File testdata/workloads/functional-query/queries/QueryTest/calcite.test:

http://gerrit.cloudera.org:8080/#/c/21239/15/testdata/workloads/functional-query/queries/QueryTest/calcite.test@459
PS15, Line 459: # left outer join test
> Should we test every type of join? Or leaving that for when we can enable a
Yeah, I was leaving this for a larger join test which will be enabled soon.



-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 16
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Thu, 29 Aug 2024 20:13:02 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Michael Smith (Code Review)" <ge...@cloudera.org>.
Michael Smith has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 16: Code-Review+1

(11 comments)

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java@54
PS15, Line 54:   // c'tor when FunctionParams are known
> Done
Ack


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java@89
PS15, Line 89:     Preconditions.checkArgument(params.size() == 2);
> Done
Ack


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java@42
PS15, Line 42: import java.util.List;
> Done
Ack


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@149
PS15, Line 149:     }
> Good catch.
Ack


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@206
PS15, Line 206:           : expr;
> Done
Ack


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@261
PS15, Line 261:       return JoinOperator.LEFT_SEMI_JOIN;
> Yeah, unfortunately, Calcite doesn't have RIGHT ANTI JOIN.  We're gonna hav
What happens now? Do we get a parse error from Calcite?


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@304
PS15, Line 304:    * framework is:
> I assume you meant to delete the "we"?
Yup, I mistyped too.


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@331
PS15, Line 331:     List<SlotRef> leftSideSlotRefs = new ArrayList<>();
> Done
Ack


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@348
PS15, Line 348:       return Lists.newArrayList(joinConjunct.getChild(0), joinConjunct.getChild(1));
> Changed the message.
Ack


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@448
PS15, Line 448:     // check gets bypassed for some tests run through the test framework which explicitly
> Done
Ack


http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java:

http://gerrit.cloudera.org:8080/#/c/21239/15/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java@57
PS15, Line 57:     return new NodeWithExprs(selectNode, nodeWithExprs);
> Done
Ack



-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 16
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Thu, 29 Aug 2024 20:21:28 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 9:

(10 comments)

http://gerrit.cloudera.org:8080/#/c/21239/9/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java:

http://gerrit.cloudera.org:8080/#/c/21239/9/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@238
PS9, Line 238:    * generates a Left Outer Join and checks the nullability of the column being output from
line too long (91 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/9/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@239
PS9, Line 239:    * the right side of the LOJ. Since the literal TRUE is a non-null value coming into the join
line too long (95 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/9/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@240
PS9, Line 240:    * but after the join becomes nullable, we add this function to ensure that happens. Without
line too long (94 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/9/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@241
PS9, Line 241:    * adding this function the direct translation would be 'TRUE IS NULL' which is incorrect.
line too long (92 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/9/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@461
PS9, Line 461:     // node. This is checked during the validatePlan(). In some cases, the check for small query
line too long (96 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/9/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@462
PS9, Line 462:     // optimization (done at the end of the single node planning phase) will determine that the
line too long (95 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/9/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@463
PS9, Line 463:     // cardinality of the query is lower than the exec_single_node_rows_threshold and will force
line too long (96 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/9/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@464
PS9, Line 464:     // the num_nodes = 1. However, that check gets bypassed for some tests run through the test
line too long (95 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/9/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@469
PS9, Line 469:         (joinOp == JoinOperator.RIGHT_OUTER_JOIN || joinOp == JoinOperator.FULL_OUTER_JOIN) &&
line too long (94 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/9/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java:

http://gerrit.cloudera.org:8080/#/c/21239/9/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java@44
PS9, Line 44:     super(leftInput, rightInput, isStraightJoin, distMode, joinOp, equiJoinConjuncts, nonEquijoinConjuncts);
line too long (108 > 90)



-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 9
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Mon, 01 Jul 2024 20:27:15 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 18:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/16876/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 18
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Wed, 04 Sep 2024 17:19:57 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Joe McDonnell, Csaba Ringhofer, Michael Smith, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/21239

to look at the new patch set (#19).

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................

IMPALA-13043: Implement Join Capability to the Calcite Planner

This commit adds the ability to handle joins in the Calcite planner.

Some items worth noting:

There is extra handling in the ImpalaJoinRel class to deal with outer
joins.  The AnalyzedTupleIsNullExpr object is needed for processing
which derives from TupleIsNullExpr. Normally, expressions are created
in the CreateExprVisitor, but the join requires that the TupleIsNullExpr
object is wrapped around the expressions retrieved from the inputs.

The execution engine requires separation of the equijoin conditions and
the non-equijoin conditions. Furthermore, the equijoin conditions are
BinaryCompPredicates instead of normal FunctionCallExprs, so the
AnalyzedBinaryCompExpr class had to be created.

Special processing needed to be coded for runtime filter generators.
The conditions needed to be added to the value transfer graph in order
to enable the Impala planner logic to create and push these generators.

The join also required some rules to be added to the optimizer. If a join
is done through the "ON" clause, Calcite is able to place the join
condition directly in the Join RelNode. However, if it is in the "WHERE"
clause, Calcite creates a Filter RelNode and creates a cross join RelNode
object. Therefore, in order to handle "WHERE" joins, we need to implement
the rules in the optimizer.

Change-Id: I5db097577907d79877f52feff2922000af074ecd
---
A java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ConvertToImpalaRelRules.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaAggRel.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaPlanRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaProjectRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaSortRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeWithExprs.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaNestedLoopJoinNode.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/type/ImpalaTypeConverter.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
18 files changed, 896 insertions(+), 46 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/39/21239/19
-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 19
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 12:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/16487/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 12
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Wed, 10 Jul 2024 23:18:31 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 12:

(10 comments)

http://gerrit.cloudera.org:8080/#/c/21239/12/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java:

http://gerrit.cloudera.org:8080/#/c/21239/12/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@220
PS12, Line 220:    * generates a Left Outer Join and checks the nullability of the column being output from
line too long (91 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/12/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@221
PS12, Line 221:    * the right side of the LOJ. Since the literal TRUE is a non-null value coming into the join
line too long (95 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/12/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@222
PS12, Line 222:    * but after the join becomes nullable, we add this function to ensure that happens. Without
line too long (94 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/12/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@223
PS12, Line 223:    * adding this function the direct translation would be 'TRUE IS NULL' which is incorrect.
line too long (92 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/12/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@443
PS12, Line 443:     // node. This is checked during the validatePlan(). In some cases, the check for small query
line too long (96 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/12/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@444
PS12, Line 444:     // optimization (done at the end of the single node planning phase) will determine that the
line too long (95 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/12/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@445
PS12, Line 445:     // cardinality of the query is lower than the exec_single_node_rows_threshold and will force
line too long (96 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/12/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@446
PS12, Line 446:     // the num_nodes = 1. However, that check gets bypassed for some tests run through the test
line too long (95 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/12/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@451
PS12, Line 451:         (joinOp == JoinOperator.RIGHT_OUTER_JOIN || joinOp == JoinOperator.FULL_OUTER_JOIN) &&
line too long (94 > 90)


http://gerrit.cloudera.org:8080/#/c/21239/12/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java:

http://gerrit.cloudera.org:8080/#/c/21239/12/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java@43
PS12, Line 43:     super(leftInput, rightInput, isStraightJoin, distMode, joinOp, equiJoinConjuncts, nonEquijoinConjuncts);
line too long (108 > 90)



-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 12
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Wed, 10 Jul 2024 22:54:49 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 20: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 20
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Thu, 05 Sep 2024 21:15:44 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Joe McDonnell, Csaba Ringhofer, Michael Smith, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/21239

to look at the new patch set (#18).

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................

IMPALA-13043: Implement Join Capability to the Calcite Planner

This commit adds the ability to handle joins in the Calcite planner.

Some items worth noting:

There is extra handling in the ImpalaJoinRel class to deal with outer
joins.  The AnalyzedTupleIsNullExpr object is needed for processing
which derives from TupleIsNullExpr. Normally, expressions are created
in the CreateExprVisitor, but the join requires that the TupleIsNullExpr
object is wrapped around the expressions retrieved from the inputs.

The execution engine requires separation of the equijoin conditions and
the non-equijoin conditions. Furthermore, the equijoin conditions are
BinaryCompPredicates instead of normal FunctionCallExprs, so the
AnalyzedBinaryCompExpr class had to be created.

Special processing needed to be coded for runtime filter generators.
The conditions needed to be added to the value transfer graph in order
to enable the Impala planner logic to create and push these generators.

There is some special case logic in the join that requires the execution
engine to run on a single node. The original logic can be found in the
JoinNode planner object, but this code isn't executed. The new mechanism
for checking single node executions is passed back to the root via the
NodeWithExprs object, and is checked in the ImpalaJoinRel.useSingleNode
method.

The join also required some rules to be added to the optimizer. If a join
is done through the "ON" clause, Calcite is able to place the join
condition directly in the Join RelNode. However, if it is in the "WHERE"
clause, Calcite creates a Filter RelNode and creates a cross join RelNode
object. Therefore, in order to handle "WHERE" joins, we need to implement
the rules in the optimizer.

Change-Id: I5db097577907d79877f52feff2922000af074ecd
---
A java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ConvertToImpalaRelRules.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaAggRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaHdfsScanRel.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaPlanRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaProjectRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaSortRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaValuesRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeWithExprs.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaNestedLoopJoinNode.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/type/ImpalaTypeConverter.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
21 files changed, 938 insertions(+), 52 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/39/21239/18
-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 18
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 20: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 20
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Thu, 05 Sep 2024 16:06:29 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 13:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/21239/13/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java:

http://gerrit.cloudera.org:8080/#/c/21239/13/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@448
PS13, Line 448:     // check gets bypassed for some tests run through the test framework which explicitly 
line has trailing whitespace



-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 13
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Comment-Date: Wed, 10 Jul 2024 23:56:36 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Steve Carlin (Code Review)" <ge...@cloudera.org>.
Hello Aman Sinha, Joe McDonnell, Csaba Ringhofer, Michael Smith, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/21239

to look at the new patch set (#16).

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................

IMPALA-13043: Implement Join Capability to the Calcite Planner

This commit adds the ability to handle joins in the Calcite planner.

Some of the items worth noting:

There is extra handling in the ImpalaJoinRel class to deal with outer
joins.  The AnalyzedTupleIsNullExpr object is needed for processing
which derives from TupleIsNullExpr. Normally, expressions are created
in the CreateExprVisitor, but the join requires that the TupleIsNullExpr
object is wrapped around the expressions retrieved from the inputs.

The execution engine requires separation of the equijoin conditions and
the non-equijoin conditions. Furthermore, the equijoin conditions are
BinaryCompPredicates instead of normal FunctionCallExprs, so the
AnalyzedBinaryCompExpr class had to be created.

Special processing needed to be coded for runtime filter generators.
The conditions needed to be added to the value transfer graph in order
to enable the Impala planner logic to create and push these generators.

There is some special case logic in the join that requires the execution
engine to run on a single node. The original logic can be found in the
JoinNode planner object, but this code isn't executed. The new mechanism
for checking single node executions is passed back to the root via the
NodeWithExprs object, and is checked in the ImpalaJoinRel.useSingleNode
method.

The join also required some rules to be added to the optimizer. If a join
is done through the "ON" clause, Calcite is able to place the join
condition directly in the Join RelNode. However, if it is in the "WHERE"
clause, Calcite creates a Filter RelNode and creates a cross join RelNode
object. Therefore, in order to handle "WHERE" joins, we need to implement
the rules in the optimizer.

Change-Id: I5db097577907d79877f52feff2922000af074ecd
---
A java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedFunctionCallExpr.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ConvertToImpalaRelRules.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaAggRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaHdfsScanRel.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaPlanRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaProjectRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaSortRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaValuesRel.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeCreationUtils.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/NodeWithExprs.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaHashJoinNode.java
A java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/phys/ImpalaNestedLoopJoinNode.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
M java/calcite-planner/src/main/java/org/apache/impala/calcite/type/ImpalaTypeConverter.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
21 files changed, 938 insertions(+), 52 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/39/21239/16
-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 16
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 16:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/16839/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 16
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Thu, 29 Aug 2024 20:46:17 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 20:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/10933/ DRY_RUN=false


-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 20
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Thu, 05 Sep 2024 16:06:30 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-13043: Implement Join Capability to the Calcite Planner

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Joe McDonnell has posted comments on this change. ( http://gerrit.cloudera.org:8080/21239 )

Change subject: IMPALA-13043: Implement Join Capability to the Calcite Planner
......................................................................


Patch Set 16:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/21239/16//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/21239/16//COMMIT_MSG@28
PS16, Line 28: There is some special case logic in the join that requires the execution
             : engine to run on a single node. The original logic can be found in the
             : JoinNode planner object, but this code isn't executed. The new mechanism
             : for checking single node executions is passed back to the root via the
             : NodeWithExprs object, and is checked in the ImpalaJoinRel.useSingleNode
             : method.
I'm comparing this to how the legacy planner worked. Is there a specific SQL that needs the num_nodes=1 treatment?


http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java:

http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedBinaryCompExpr.java@65
PS16, Line 65:     return 1;
Nit: Does it matter that this is 1 versus UNKNOWN_COST? (Not a real issue since we'll be doing more here later, just curious.)


http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java:

http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaJoinRel.java@258
PS16, Line 258:       // Mapping it to a Left Semi Join in Impala seems to make
              :       // sense since it is unclear when we would need a
              :       // Right Semi Join
              :       return JoinOperator.LEFT_SEMI_JOIN;
Looking at the Calcite code, it looks like Calcite's SEMI join is by definition a LEFT SEMI (and it's ANTI is a LEFT ANTI).

Since this is implemented via a hash join, the same considerations apply as for any hash join. We would rather have a smaller build side to avoid memory usage for the hash table. 

So, if we have a left semi join and the right input is very large, then we would rather invert the join and use a right semi join.


http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
File java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java:

http://gerrit.cloudera.org:8080/#/c/21239/16/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java@120
PS16, Line 120:     if (useSingleNode) {
              :       plannerContext.getQueryOptions().setNum_nodes(1);
              :     }
For the plans that set num_nodes=1 here, would any of them get fixed by the "invertJoins" call down in createPlans()? In other words, can there be cases where this would restrict itself to one node when the legacy planner would run it on more than one?

I guess this is something we will catch down the line when we run more test suites.



-- 
To view, visit http://gerrit.cloudera.org:8080/21239
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I5db097577907d79877f52feff2922000af074ecd
Gerrit-Change-Number: 21239
Gerrit-PatchSet: 16
Gerrit-Owner: Steve Carlin <sc...@cloudera.com>
Gerrit-Reviewer: Aman Sinha <am...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <cs...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Michael Smith <mi...@cloudera.com>
Gerrit-Reviewer: Steve Carlin <sc...@cloudera.com>
Gerrit-Comment-Date: Fri, 30 Aug 2024 00:44:11 +0000
Gerrit-HasComments: Yes