amansinha100 commented on a change in pull request #1744: Drill 7148 - Join
order, multi-col ndv and aggregate rowcount fixes for TPCH queries
URL: https://github.com/apache/drill/pull/1744#discussion_r275079027
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillRelOptUtil.java
##########
@@ -667,4 +667,66 @@ public static DrillTable getDrillTable(final TableScan
scan) {
}
return drillTable;
}
+
+ public static List<Pair<Integer, Integer>> analyzeSimpleEquiJoin(Join join) {
+ List<Pair<Integer, Integer>> joinConditions = new ArrayList<>();
+ try {
+ RexVisitor<Void> visitor =
+ new RexVisitorImpl<Void>(true) {
+ public Void visitCall(RexCall call) {
+ if (call.getKind() == SqlKind.AND || call.getKind() ==
SqlKind.OR) {
+ super.visitCall(call);
+ } else {
+ if (call.getKind() == SqlKind.EQUALS) {
+ int leftFieldCount =
join.getLeft().getRowType().getFieldCount();
+ int rightFieldCount =
join.getRight().getRowType().getFieldCount();
+ RexNode leftComparand = call.operands.get(0);
+ RexNode rightComparand = call.operands.get(1);
+ RexInputRef leftFieldAccess = (RexInputRef) leftComparand;
+ RexInputRef rightFieldAccess = (RexInputRef) rightComparand;
+ if (leftFieldAccess.getIndex() >= leftFieldCount +
rightFieldCount ||
Review comment:
If this is a sanity check borrowed from Calcite, maybe you can add a
comment.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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