vvysotskyi commented on a change in pull request #1426: DRILL-6671: Multi level
lateral unnest join is throwing an exception …
URL: https://github.com/apache/drill/pull/1426#discussion_r208856911
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/LateralUnnestRowIDVisitor.java
##########
@@ -59,16 +65,37 @@ public Prel visitPrel(Prel prel, Boolean isRightOfLateral)
throws RuntimeExcepti
}
@Override
- public Prel visitLateral(LateralJoinPrel prel, Boolean value) throws
RuntimeException {
+ public Prel visitLateral(LateralJoinPrel prel, Boolean isRightOfLateral)
throws RuntimeException {
List<RelNode> children = Lists.newArrayList();
- children.add(((Prel)prel.getInput(0)).accept(this, value));
+ children.add(((Prel)prel.getInput(0)).accept(this, isRightOfLateral));
children.add(((Prel) prel.getInput(1)).accept(this, true));
- return (Prel) prel.copy(prel.getTraitSet(), children);
+ if (!isRightOfLateral) {
+ return (Prel) prel.copy(prel.getTraitSet(), children);
+ } else {
+ //Adjust the column numbering due to an additional column
"$drill_implicit_field$" is added to the inputs.
+ Map<Integer, Integer> requiredColsMap = new HashMap<>();
+ for (Integer corrColIndex : prel.getRequiredColumns()) {
+ requiredColsMap.put(corrColIndex, corrColIndex+1);
+ }
+ ImmutableBitSet requiredColumns = prel.getRequiredColumns().shift(1);
+
+ CorrelationId corrId = prel.getCluster().createCorrel();
+ RexCorrelVariable rexCorrel =
+ (RexCorrelVariable) prel.getCluster().getRexBuilder().makeCorrel(
+ children.get(0).getRowType(),
+ corrId);
+ RelNode rightChild = children.get(1).accept(
Review comment:
Looks like `ProjectCorrelateTransposeRule.RelNodesExprsHandler` does not
replace RexCorrelVariable for the case when RelNode does not have any input. In
our case, this is `UnnestPrel`. So we need to extend this class and override
method `visit(RelNode other)`:
```
@Override
public RelNode visit(RelNode other) {
return super.visit(other.accept(rexVisitor));
}
```
Also, it does not work since `UnnestPrel` use `accept(RexShuttle shuttle)`
method from `AbstractRelNode` which does nothing, so we should override it
somehow like:
```
@Override
public RelNode accept(RexShuttle shuttle) {
RexNode ref = shuttle.apply(this.ref);
if (this.ref == ref) {
return this;
}
return new UnnestPrel(getCluster(), traitSet, rowType, ref);
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services