use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestVerifyNoOriginalExpression method setup.
@BeforeClass
public void setup() {
metadata = getQueryRunner().getMetadata();
builder = new PlanBuilder(TEST_SESSION, new PlanNodeIdAllocator(), metadata);
valuesNode = builder.values();
comparisonCallExpression = new CallExpression("LESS_THAN", metadata.getFunctionAndTypeManager().resolveOperator(LESS_THAN, fromTypes(BIGINT, BIGINT)), BooleanType.BOOLEAN, ImmutableList.of(VARIABLE_REFERENCE_EXPRESSION, VARIABLE_REFERENCE_EXPRESSION));
}
use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestJoinNodeFlattener method testRetainsOutputSymbols.
@Test
public void testRetainsOutputSymbols() {
PlanBuilder p = planBuilder();
VariableReferenceExpression a1 = p.variable("A1");
VariableReferenceExpression b1 = p.variable("B1");
VariableReferenceExpression b2 = p.variable("B2");
VariableReferenceExpression c1 = p.variable("C1");
VariableReferenceExpression c2 = p.variable("C2");
ValuesNode valuesA = p.values(a1);
ValuesNode valuesB = p.values(b1, b2);
ValuesNode valuesC = p.values(c1, c2);
JoinNode joinNode = p.join(INNER, valuesA, p.join(INNER, valuesB, valuesC, ImmutableList.of(equiJoinClause(b1, c1)), ImmutableList.of(b1, b2, c1, c2), Optional.empty()), ImmutableList.of(equiJoinClause(a1, b1)), ImmutableList.of(a1, b1), Optional.empty());
MultiJoinNode expected = MultiJoinNode.builder().setSources(valuesA, valuesB, valuesC).setFilter(and(createEqualsExpression(b1, c1), createEqualsExpression(a1, b1))).setOutputVariables(a1, b1).build();
assertEquals(toMultiJoinNode(joinNode, noLookup(), DEFAULT_JOIN_LIMIT, functionResolution, determinismEvaluator), expected);
}
use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestJoinNodeFlattener method testDoesNotConvertNestedOuterJoins.
@Test
public void testDoesNotConvertNestedOuterJoins() {
PlanBuilder p = planBuilder();
VariableReferenceExpression a1 = p.variable("A1");
VariableReferenceExpression b1 = p.variable("B1");
VariableReferenceExpression c1 = p.variable("C1");
JoinNode leftJoin = p.join(LEFT, p.values(a1), p.values(b1), ImmutableList.of(equiJoinClause(a1, b1)), ImmutableList.of(a1, b1), Optional.empty());
ValuesNode valuesC = p.values(c1);
JoinNode joinNode = p.join(INNER, leftJoin, valuesC, ImmutableList.of(equiJoinClause(a1, c1)), ImmutableList.of(a1, b1, c1), Optional.empty());
MultiJoinNode expected = MultiJoinNode.builder().setSources(leftJoin, valuesC).setFilter(createEqualsExpression(a1, c1)).setOutputVariables(a1, b1, c1).build();
assertEquals(toMultiJoinNode(joinNode, noLookup(), DEFAULT_JOIN_LIMIT, functionResolution, determinismEvaluator), expected);
}
use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestJoinNodeFlattener method testMoreThanJoinLimit.
@Test
public void testMoreThanJoinLimit() {
PlanBuilder p = planBuilder();
VariableReferenceExpression a1 = p.variable("A1");
VariableReferenceExpression b1 = p.variable("B1");
VariableReferenceExpression c1 = p.variable("C1");
VariableReferenceExpression d1 = p.variable("D1");
VariableReferenceExpression d2 = p.variable("D2");
VariableReferenceExpression e1 = p.variable("E1");
VariableReferenceExpression e2 = p.variable("E2");
ValuesNode valuesA = p.values(a1);
ValuesNode valuesB = p.values(b1);
ValuesNode valuesC = p.values(c1);
ValuesNode valuesD = p.values(d1, d2);
ValuesNode valuesE = p.values(e1, e2);
JoinNode join1 = p.join(INNER, valuesA, valuesB, ImmutableList.of(equiJoinClause(a1, b1)), ImmutableList.of(a1, b1), Optional.empty());
JoinNode join2 = p.join(INNER, valuesD, valuesE, ImmutableList.of(equiJoinClause(d1, e1), equiJoinClause(d2, e2)), ImmutableList.of(d1, d2, e1, e2), Optional.empty());
JoinNode joinNode = p.join(INNER, p.join(INNER, join1, valuesC, ImmutableList.of(equiJoinClause(a1, c1)), ImmutableList.of(a1, b1, c1), Optional.empty()), join2, ImmutableList.of(equiJoinClause(b1, e1)), ImmutableList.of(a1, b1, c1, d1, d2, e1, e2), Optional.empty());
MultiJoinNode expected = MultiJoinNode.builder().setSources(join1, join2, valuesC).setFilter(and(createEqualsExpression(a1, c1), createEqualsExpression(b1, e1))).setOutputVariables(a1, b1, c1, d1, d2, e1, e2).build();
assertEquals(toMultiJoinNode(joinNode, noLookup(), 2, functionResolution, determinismEvaluator), expected);
}
use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestPlanRemoteProjections method testLocalOnly.
@Test
void testLocalOnly() {
PlanBuilder planBuilder = new PlanBuilder(TEST_SESSION, new PlanNodeIdAllocator(), getMetadata());
planBuilder.variable("x", INTEGER);
planBuilder.variable("y", INTEGER);
PlanRemotePojections rule = new PlanRemotePojections(getFunctionAndTypeManager());
List<ProjectionContext> rewritten = rule.planRemoteAssignments(Assignments.builder().put(planBuilder.variable("a"), planBuilder.rowExpression("abs(x) + abs(y)")).put(planBuilder.variable("b", BOOLEAN), planBuilder.rowExpression("x is null and y is null")).build(), new PlanVariableAllocator(planBuilder.getTypes().allVariables()));
assertEquals(rewritten.size(), 1);
assertEquals(rewritten.get(0).getProjections().size(), 2);
}
Aggregations