Search in sources :

Example 6 with PlanNodeIdAllocator

use of com.facebook.presto.spi.plan.PlanNodeIdAllocator in project presto by prestodb.

the class TestValidateAggregationsWithDefaultValues method setup.

@BeforeClass
public void setup() {
    metadata = getQueryRunner().getMetadata();
    builder = new PlanBuilder(TEST_SESSION, new PlanNodeIdAllocator(), metadata);
    ConnectorId connectorId = getCurrentConnectorId();
    TpchTableHandle nationTpchTableHandle = new TpchTableHandle("nation", 1.0);
    TableHandle nationTableHandle = new TableHandle(connectorId, nationTpchTableHandle, TestingTransactionHandle.create(), Optional.of(new TpchTableLayoutHandle(nationTpchTableHandle, TupleDomain.all())));
    TpchColumnHandle nationkeyColumnHandle = new TpchColumnHandle("nationkey", BIGINT);
    variable = builder.variable("nationkey");
    tableScanNode = builder.tableScan(nationTableHandle, ImmutableList.of(variable), ImmutableMap.of(variable, nationkeyColumnHandle));
}
Also used : PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) TpchColumnHandle(com.facebook.presto.tpch.TpchColumnHandle) TableHandle(com.facebook.presto.spi.TableHandle) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) TpchTableLayoutHandle(com.facebook.presto.tpch.TpchTableLayoutHandle) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) ConnectorId(com.facebook.presto.spi.ConnectorId) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) BeforeClass(org.testng.annotations.BeforeClass)

Example 7 with PlanNodeIdAllocator

use of com.facebook.presto.spi.plan.PlanNodeIdAllocator in project presto by prestodb.

the class TestSchedulingOrderVisitor method testIndexJoinOrder.

@Test
public void testIndexJoinOrder() {
    PlanBuilder planBuilder = new PlanBuilder(TEST_SESSION, new PlanNodeIdAllocator(), METADATA);
    TableScanNode a = planBuilder.tableScan(emptyList(), emptyMap());
    TableScanNode b = planBuilder.tableScan(emptyList(), emptyMap());
    List<PlanNodeId> order = scheduleOrder(planBuilder.indexJoin(IndexJoinNode.Type.INNER, a, b));
    assertEquals(order, ImmutableList.of(b.getId(), a.getId()));
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) TableScanNode(com.facebook.presto.spi.plan.TableScanNode) PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) Test(org.testng.annotations.Test)

Example 8 with PlanNodeIdAllocator

use of com.facebook.presto.spi.plan.PlanNodeIdAllocator in project presto by prestodb.

the class TestPlanRemoteProjections method testRemoteOnly.

@Test
void testRemoteOnly() {
    PlanBuilder planBuilder = new PlanBuilder(TEST_SESSION, new PlanNodeIdAllocator(), getMetadata());
    PlanRemotePojections rule = new PlanRemotePojections(getFunctionAndTypeManager());
    List<ProjectionContext> rewritten = rule.planRemoteAssignments(Assignments.builder().put(planBuilder.variable("a"), planBuilder.rowExpression("unittest.memory.remote_foo()")).put(planBuilder.variable("b"), planBuilder.rowExpression("unittest.memory.remote_foo(unittest.memory.remote_foo())")).build(), new PlanVariableAllocator(planBuilder.getTypes().allVariables()));
    assertEquals(rewritten.size(), 2);
    assertEquals(rewritten.get(1).getProjections().size(), 2);
}
Also used : ProjectionContext(com.facebook.presto.sql.planner.iterative.rule.PlanRemotePojections.ProjectionContext) PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) PlanVariableAllocator(com.facebook.presto.sql.planner.PlanVariableAllocator) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) Test(org.testng.annotations.Test)

Example 9 with PlanNodeIdAllocator

use of com.facebook.presto.spi.plan.PlanNodeIdAllocator in project presto by prestodb.

the class TestPlanRemoteProjections method testSpecialForm.

@Test
void testSpecialForm() {
    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("unittest.memory.remote_foo(x, y + unittest.memory.remote_foo(x))")).put(planBuilder.variable("b"), planBuilder.rowExpression("x IS NULL OR y IS NULL")).put(planBuilder.variable("c"), planBuilder.rowExpression("IF(abs(unittest.memory.remote_foo()) > 0, x, y)")).put(planBuilder.variable("d"), planBuilder.rowExpression("unittest.memory.remote_foo(x + y, abs(x))")).put(planBuilder.variable("e"), planBuilder.rowExpression("TRUE OR FALSE")).build(), new PlanVariableAllocator(planBuilder.getTypes().allVariables()));
    assertEquals(rewritten.size(), 4);
    assertEquals(rewritten.get(3).getProjections().size(), 5);
}
Also used : ProjectionContext(com.facebook.presto.sql.planner.iterative.rule.PlanRemotePojections.ProjectionContext) PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) PlanVariableAllocator(com.facebook.presto.sql.planner.PlanVariableAllocator) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) Test(org.testng.annotations.Test)

Example 10 with PlanNodeIdAllocator

use of com.facebook.presto.spi.plan.PlanNodeIdAllocator in project presto by prestodb.

the class TestCardinalityExtractorPlanVisitor method testLimitOnTopOfValues.

@Test
public void testLimitOnTopOfValues() {
    PlanBuilder planBuilder = new PlanBuilder(TEST_SESSION, new PlanNodeIdAllocator(), dummyMetadata());
    assertEquals(extractCardinality(planBuilder.limit(3, planBuilder.values(emptyList(), ImmutableList.of(emptyList())))), Range.singleton(1L));
    assertEquals(extractCardinality(planBuilder.limit(3, planBuilder.values(emptyList(), ImmutableList.of(emptyList(), emptyList(), emptyList(), emptyList())))), Range.singleton(3L));
}
Also used : PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) Test(org.testng.annotations.Test)

Aggregations

PlanNodeIdAllocator (com.facebook.presto.spi.plan.PlanNodeIdAllocator)22 PlanBuilder (com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder)14 Test (org.testng.annotations.Test)9 PlanVariableAllocator (com.facebook.presto.sql.planner.PlanVariableAllocator)7 PlanNode (com.facebook.presto.spi.plan.PlanNode)5 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)5 TableScanNode (com.facebook.presto.spi.plan.TableScanNode)4 ProjectionContext (com.facebook.presto.sql.planner.iterative.rule.PlanRemotePojections.ProjectionContext)4 Session (com.facebook.presto.Session)3 LogicalRowExpressions (com.facebook.presto.expressions.LogicalRowExpressions)3 ConnectorId (com.facebook.presto.spi.ConnectorId)3 TableHandle (com.facebook.presto.spi.TableHandle)3 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)3 TpchColumnHandle (com.facebook.presto.tpch.TpchColumnHandle)3 TpchTableHandle (com.facebook.presto.tpch.TpchTableHandle)3 BeforeClass (org.testng.annotations.BeforeClass)3 Capture (com.facebook.presto.matching.Capture)2 Capture.newCapture (com.facebook.presto.matching.Capture.newCapture)2 Captures (com.facebook.presto.matching.Captures)2 Pattern (com.facebook.presto.matching.Pattern)2