New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRILL-6545: Projection Push down into Lateral Join operator. #1347
Conversation
List<RelDataType> fields = new ArrayList<>(); | ||
List<String> fieldNames = new ArrayList<>(); | ||
if (excludeCorrelateColumn) { | ||
int corrVariable = this.requiredColumns.nextSetBit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An assumption here is that there is only 1 correlated column which is true for Drill's Lateral-Unnest implementation but I believe Calcite allows multiple. You could just put a Preconditions check here to be safe.
public boolean matches(RelOptRuleCall call) { | ||
Correlate correlate = call.rel(1); | ||
|
||
if (correlate instanceof DrillLateralJoinRel && ((DrillLateralJoinRel)correlate).excludeCorrelateColumn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls add a comment why this should not match if excludeCorrelateColumn is true.
@@ -104,6 +118,12 @@ private RelNode rename(RelNode input, List<RelDataTypeField> inputFields, List<S | |||
return proj; | |||
} | |||
|
|||
@Override | |||
public RelWriter explainTerms(RelWriter pw) { | |||
return super.explainTerms(pw).item("correlate Column: ", this.excludeCorrelateColumn ? this.getColumn() : "None"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this confuse users in the sense that 'correlate column' is actually always needed for the semantics of lateral join but what excludeCorrelateColumn does is it prevents materialization of that column from the left side of the lateral.
|
||
private Map<Integer, Integer> buildMapWithoutCorrColumn(RelNode corr, int correlationIndex) { | ||
int index = 0; | ||
Map<Integer, Integer> result = new HashedMap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for using a HashedMap instead of just HashMap ? (unless you are using the MapIterator it seems the latter should suffice).
} | ||
} | ||
|
||
public static class RexFieldsTransformer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a generic transformer for Rex exprs ? If so, pls add a java doc for future use of this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@amansinha100 Thank you for the review. |
@amansinha100 Please review this PR.
This PR includes.