Created
March 9, 2016 09:23
-
-
Save kokosing/159224a2380ce9927a0e to your computer and use it in GitHub Desktop.
Coercion and subqueries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/presto-main/src/main/java/com/facebook/presto/sql/planner/QueryPlanner.java b/presto-main/src/main/java/com/f | |
index 07606fe..2c3d0aa 100644 | |
--- a/presto-main/src/main/java/com/facebook/presto/sql/planner/QueryPlanner.java | |
+++ b/presto-main/src/main/java/com/facebook/presto/sql/planner/QueryPlanner.java | |
@@ -679,10 +679,28 @@ class QueryPlanner | |
private PlanBuilder appendScalarSubqueryJoin(PlanBuilder builder, SubqueryExpression scalarSubquery) | |
{ | |
- EnforceSingleRowNode enforceSingleRowNode = new EnforceSingleRowNode(idAllocator.getNextId(), createRelationPlan( | |
+ PlanNode enforceSingleRowNode = new EnforceSingleRowNode(idAllocator.getNextId(), createRelationPlan(scalarSubque | |
+ | |
+ Symbol output = getOnlyElement(enforceSingleRowNode.getOutputSymbols()); | |
+ Type coercion = analysis.getCoercion(scalarSubquery); | |
+ if (coercion != null) { | |
+ analysis.addCoercion(output.toQualifiedNameReference(), coercion); | |
+ Type type = analysis.getType(scalarSubquery); | |
+ Cast cast = new Cast( | |
+ output.toQualifiedNameReference(), | |
+ coercion.getTypeSignature().toString(), | |
+ false, | |
+ isTypeOnlyCoercion(type.getTypeSignature(), coercion.getTypeSignature())); | |
+ | |
+ output = symbolAllocator.newSymbol("field", type); | |
+ enforceSingleRowNode = new ProjectNode( | |
+ idAllocator.getNextId(), | |
+ enforceSingleRowNode, | |
+ ImmutableMap.of(output, cast)); | |
+ } | |
TranslationMap translations = copyTranslations(builder); | |
- translations.put(scalarSubquery, getOnlyElement(enforceSingleRowNode.getOutputSymbols())); | |
+ translations.put(scalarSubquery, output); | |
// Cross join current (root) relation with subquery | |
PlanNode root = builder.getRoot(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment