use of io.trino.sql.planner.plan.ValuesNode in project trino by trinodb.
the class TestJoinNodeFlattener method testPushesProjectionsThroughJoin.
@Test
public void testPushesProjectionsThroughJoin() {
PlanNodeIdAllocator planNodeIdAllocator = new PlanNodeIdAllocator();
PlanBuilder p = planBuilder(planNodeIdAllocator);
Symbol a = p.symbol("A");
Symbol b = p.symbol("B");
Symbol c = p.symbol("C");
Symbol d = p.symbol("D");
ValuesNode valuesA = p.values(a);
ValuesNode valuesB = p.values(b);
ValuesNode valuesC = p.values(c);
JoinNode joinNode = p.join(INNER, p.project(Assignments.of(d, new ArithmeticUnaryExpression(MINUS, a.toSymbolReference())), p.join(INNER, valuesA, valuesB, equiJoinClause(a, b))), valuesC, equiJoinClause(d, c));
MultiJoinNode actual = toMultiJoinNode(queryRunner.getPlannerContext(), joinNode, noLookup(), planNodeIdAllocator, DEFAULT_JOIN_LIMIT, true, testSessionBuilder().build(), createTestingTypeAnalyzer(queryRunner.getPlannerContext()), p.getTypes());
assertEquals(actual.getOutputSymbols(), ImmutableList.of(d, c));
assertEquals(actual.getFilter(), and(createEqualsExpression(a, b), createEqualsExpression(d, c)));
assertTrue(actual.isPushedProjectionThroughJoin());
List<PlanNode> actualSources = ImmutableList.copyOf(actual.getSources());
assertPlan(p.getTypes(), actualSources.get(0), node(ProjectNode.class, values("a")).withNumberOfOutputColumns(2));
assertPlan(p.getTypes(), actualSources.get(1), node(ProjectNode.class, values("b")).withNumberOfOutputColumns(1));
assertPlan(p.getTypes(), actualSources.get(2), values("c"));
}
use of io.trino.sql.planner.plan.ValuesNode in project trino by trinodb.
the class TestMergeExcept method buildNestedExcept.
private PlanNode buildNestedExcept(PlanBuilder builder, boolean sourceDistinct, boolean parentDistinct) {
Symbol v1 = builder.symbol("v_1");
Symbol v2 = builder.symbol("v_2");
Symbol a = builder.symbol("a");
Symbol b = builder.symbol("b");
Symbol c = builder.symbol("c");
ExceptNode child1 = builder.except(ImmutableListMultimap.of(a, v1, a, v2), ImmutableList.of(builder.values(v1), builder.values(v2)), sourceDistinct);
ValuesNode child2 = builder.values(b);
return builder.except(ImmutableListMultimap.of(c, a, c, b), ImmutableList.of(child1, child2), parentDistinct);
}
use of io.trino.sql.planner.plan.ValuesNode in project trino by trinodb.
the class TestPlanNodeSearcher method joinNodePreorder.
/**
* This method adds PlanNodeIds of JoinNodes to the builder in pre-order.
* The plan tree must contain only JoinNodes and ValuesNodes.
*/
private static void joinNodePreorder(PlanNode root, ImmutableList.Builder<PlanNodeId> builder) {
if (root instanceof ValuesNode) {
return;
}
if (root instanceof JoinNode) {
builder.add(root.getId());
JoinNode join = (JoinNode) root;
joinNodePreorder(join.getLeft(), builder);
joinNodePreorder(join.getRight(), builder);
return;
}
throw new IllegalArgumentException("unsupported node type: " + root.getClass().getSimpleName());
}
use of io.trino.sql.planner.plan.ValuesNode in project trino by trinodb.
the class TestVerifyOnlyOneOutputNode method testValidateSuccessful.
@Test
public void testValidateSuccessful() {
// random seemingly valid plan
PlanNode root = new OutputNode(idAllocator.getNextId(), new ProjectNode(idAllocator.getNextId(), new ValuesNode(idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of()), Assignments.of()), ImmutableList.of(), ImmutableList.of());
new VerifyOnlyOneOutputNode().validate(root, null, PLANNER_CONTEXT, null, null, WarningCollector.NOOP);
}
use of io.trino.sql.planner.plan.ValuesNode in project trino by trinodb.
the class RelationPlanner method planSingleEmptyRow.
private PlanBuilder planSingleEmptyRow(Optional<Scope> parent) {
Scope.Builder scope = Scope.builder();
parent.ifPresent(scope::withOuterQueryParent);
PlanNode values = new ValuesNode(idAllocator.getNextId(), 1);
TranslationMap translations = new TranslationMap(outerContext, scope.build(), analysis, lambdaDeclarationToSymbolMap, ImmutableList.of());
return new PlanBuilder(translations, values);
}
Aggregations