Skip to content

Commit

Permalink
Fix joins to check for coerced types
Browse files Browse the repository at this point in the history
Also added test that ran without this fix, but produced incorrect plan.
  • Loading branch information
Raghav Sethi committed Apr 14, 2016
1 parent d6879e6 commit fdad339
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ private PlanBuilder appendProjections(PlanBuilder subPlan, Iterable<Expression>

ImmutableMap.Builder<Symbol, Expression> newTranslations = ImmutableMap.builder();
for (Expression expression : expressions) {
Symbol symbol = symbolAllocator.newSymbol(expression, analysis.getType(expression));
Symbol symbol = symbolAllocator.newSymbol(expression, analysis.getTypeWithCoercions(expression));

// TODO: CHECK IF THE REWRITE OF A SEMI JOINED EXPRESSION WILL WORK!!!!!!!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,13 @@ public void testJoinCoercion()
assertQuery("SELECT COUNT(*) FROM orders t join (SELECT * FROM orders LIMIT 1) t2 ON sin(t2.custkey) = 0");
}

@Test
public void testJoinCoercionOnEqualityComparison()
throws Exception
{
assertQuery("SELECT o.clerk, avg(o.shippriority), COUNT(l.linenumber) FROM orders o LEFT OUTER JOIN lineitem l ON o.orderkey=l.orderkey AND o.shippriority=1 GROUP BY o.clerk");
}

@Test
public void testGroupByNoAggregations()
throws Exception
Expand Down

0 comments on commit fdad339

Please sign in to comment.