gparai 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_r275195349
##########
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 ||
+ rightFieldAccess.getIndex() >= leftFieldCount +
rightFieldCount) {
+ joinConditions.clear();
+ throw new Util.FoundOne(call);
+ }
+ /* Both columns reference same table */
+ if ((leftFieldAccess.getIndex() >= leftFieldCount &&
Review comment:
For such conditions we generate a filter condition. For a self-join, it
would be two different tables so that would still go fine.
----------------------------------------------------------------
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