Skip to content

Commit

Permalink
DRILL-7072: Query with semi join fails for JDBC storage plugin
Browse files Browse the repository at this point in the history
closes #1674
  • Loading branch information
vvysotskyi authored and karthik committed Mar 8, 2019
1 parent 619a499 commit 6bd31f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Expand Up @@ -308,4 +308,19 @@ public void testJoinStar() throws Exception {
.baselineValues(5, 5) .baselineValues(5, 5)
.go(); .go();
} }

@Test
public void testSemiJoin() throws Exception {
String query =
"select person_id from mysql.`drill_mysql_test`.person t1\n" +
"where exists (" +
"select person_id from mysql.`drill_mysql_test`.person\n" +
"where t1.person_id = person_id)";
testBuilder()
.sqlQuery(query)
.unOrdered()
.baselineColumns("person_id")
.baselineValuesForSingleColumn(1, 2, 3, 5)
.go();
}
} }
Expand Up @@ -41,7 +41,7 @@
/** /**
* Planner rule that creates a {@code DrillSemiJoinRel} from a * Planner rule that creates a {@code DrillSemiJoinRel} from a
* {@link org.apache.calcite.rel.core.Join} on top of a * {@link org.apache.calcite.rel.core.Join} on top of a
* {@link org.apache.calcite.rel.logical.LogicalAggregate}. * {@link org.apache.calcite.rel.core.Aggregate}.
*/ */
public abstract class DrillSemiJoinRule extends RelOptRule { public abstract class DrillSemiJoinRule extends RelOptRule {
private static final Predicate<Join> IS_LEFT_OR_INNER = private static final Predicate<Join> IS_LEFT_OR_INNER =
Expand Down Expand Up @@ -168,7 +168,7 @@ private static boolean isSimpleJoinCondition(RexNode joinCondition) {
@Override @Override
public boolean matches(RelOptRuleCall call) { public boolean matches(RelOptRuleCall call) {
Join join = call.rel(0); Join join = call.rel(0);
DrillAggregateRel agg = call.rel(2); Aggregate agg = call.rel(2);
if (agg.getAggCallList().size() != 0) { return false; } if (agg.getAggCallList().size() != 0) { return false; }
return isSimpleJoinCondition(join.getCondition()) && return isSimpleJoinCondition(join.getCondition()) &&
isRowTypeSame(join, call.rel(1), call.rel(2).getInput(0)); isRowTypeSame(join, call.rel(1), call.rel(2).getInput(0));
Expand Down

0 comments on commit 6bd31f3

Please sign in to comment.