use of io.trino.sql.planner.PlanNodeIdAllocator in project trino by trinodb.
the class TestValidateAggregationsWithDefaultValues method setup.
@BeforeClass
public void setup() {
plannerContext = getQueryRunner().getPlannerContext();
builder = new PlanBuilder(new PlanNodeIdAllocator(), plannerContext.getMetadata(), TEST_SESSION);
CatalogName catalogName = getCurrentConnectorId();
TableHandle nationTableHandle = new TableHandle(catalogName, new TpchTableHandle("sf1", "nation", 1.0), TestingTransactionHandle.create());
TpchColumnHandle nationkeyColumnHandle = new TpchColumnHandle("nationkey", BIGINT);
symbol = new Symbol("nationkey");
tableScanNode = builder.tableScan(nationTableHandle, ImmutableList.of(symbol), ImmutableMap.of(symbol, nationkeyColumnHandle));
}
use of io.trino.sql.planner.PlanNodeIdAllocator in project trino by trinodb.
the class TestPushProjectionThroughJoin method testDoesNotPushStraddlingProjection.
@Test
public void testDoesNotPushStraddlingProjection() {
PlanBuilder p = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata(), TEST_SESSION);
Symbol a = p.symbol("a");
Symbol b = p.symbol("b");
Symbol c = p.symbol("c");
ProjectNode planNode = p.project(Assignments.of(c, new ArithmeticBinaryExpression(ADD, a.toSymbolReference(), b.toSymbolReference())), p.join(INNER, p.values(a), p.values(b)));
Optional<PlanNode> rewritten = pushProjectionThroughJoin(PLANNER_CONTEXT, planNode, noLookup(), new PlanNodeIdAllocator(), testSessionBuilder().build(), createTestingTypeAnalyzer(PLANNER_CONTEXT), p.getTypes());
assertThat(rewritten).isEmpty();
}
use of io.trino.sql.planner.PlanNodeIdAllocator in project trino by trinodb.
the class TestPushProjectionThroughJoin method testDoesNotPushProjectionThroughOuterJoin.
@Test
public void testDoesNotPushProjectionThroughOuterJoin() {
PlanBuilder p = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata(), TEST_SESSION);
Symbol a = p.symbol("a");
Symbol b = p.symbol("b");
Symbol c = p.symbol("c");
ProjectNode planNode = p.project(Assignments.of(c, new ArithmeticUnaryExpression(MINUS, a.toSymbolReference())), p.join(LEFT, p.values(a), p.values(b)));
Optional<PlanNode> rewritten = pushProjectionThroughJoin(PLANNER_CONTEXT, planNode, noLookup(), new PlanNodeIdAllocator(), testSessionBuilder().build(), createTestingTypeAnalyzer(PLANNER_CONTEXT), p.getTypes());
assertThat(rewritten).isEmpty();
}
use of io.trino.sql.planner.PlanNodeIdAllocator in project trino by trinodb.
the class TestPushProjectionThroughJoin method testPushesProjectionThroughJoin.
@Test
public void testPushesProjectionThroughJoin() {
PlanNodeIdAllocator idAllocator = new PlanNodeIdAllocator();
PlanBuilder p = new PlanBuilder(idAllocator, dummyMetadata(), TEST_SESSION);
Symbol a0 = p.symbol("a0");
Symbol a1 = p.symbol("a1");
Symbol a2 = p.symbol("a2");
Symbol a3 = p.symbol("a3");
Symbol b0 = p.symbol("b0");
Symbol b1 = p.symbol("b1");
Symbol b2 = p.symbol("b2");
ProjectNode planNode = p.project(Assignments.of(a3, new ArithmeticUnaryExpression(MINUS, a2.toSymbolReference()), b2, new ArithmeticUnaryExpression(PLUS, b1.toSymbolReference())), p.join(INNER, // intermediate non-identity projections should be fully inlined
p.project(Assignments.of(a2, new ArithmeticUnaryExpression(PLUS, a0.toSymbolReference()), a1, a1.toSymbolReference()), p.project(Assignments.builder().putIdentity(a0).putIdentity(a1).build(), p.values(a0, a1))), p.values(b0, b1), new JoinNode.EquiJoinClause(a1, b1)));
Session session = testSessionBuilder().build();
Optional<PlanNode> rewritten = pushProjectionThroughJoin(PLANNER_CONTEXT, planNode, noLookup(), idAllocator, session, createTestingTypeAnalyzer(PLANNER_CONTEXT), p.getTypes());
assertTrue(rewritten.isPresent());
assertPlan(session, dummyMetadata(), createTestingFunctionManager(), node -> unknown(), new Plan(rewritten.get(), p.getTypes(), empty()), noLookup(), join(INNER, ImmutableList.of(aliases -> new JoinNode.EquiJoinClause(new Symbol("a1"), new Symbol("b1"))), strictProject(ImmutableMap.of("a3", expression("-(+a0)"), "a1", expression("a1")), strictProject(ImmutableMap.of("a0", expression("a0"), "a1", expression("a1")), PlanMatchPattern.values("a0", "a1"))), strictProject(ImmutableMap.of("b2", expression("+b1"), "b1", expression("b1")), PlanMatchPattern.values("b0", "b1"))).withExactOutputs("a3", "b2"));
}
Aggregations