Search in sources :

Example 26 with PlanNode

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

the class TestValidateAggregationsWithDefaultValues method testGloballyDistributedFinalAggregationSeparatedFromPartialAggregationByRemoteHashExchange.

@Test
public void testGloballyDistributedFinalAggregationSeparatedFromPartialAggregationByRemoteHashExchange() {
    PlanNode root = builder.aggregation(af -> af.step(FINAL).groupingSets(groupingSets(ImmutableList.of(variable), 2, ImmutableSet.of(0))).source(builder.exchange(e -> e.type(REPARTITION).scope(REMOTE_STREAMING).fixedHashDistributionParitioningScheme(ImmutableList.of(variable), ImmutableList.of(variable)).addInputsSet(variable).addSource(builder.aggregation(ap -> ap.step(PARTIAL).groupingSets(groupingSets(ImmutableList.of(variable), 2, ImmutableSet.of(0))).source(tableScanNode))))));
    validatePlan(root, false);
}
Also used : PlanNode(com.facebook.presto.spi.plan.PlanNode) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Example 27 with PlanNode

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

the class TestValidateAggregationsWithDefaultValues method testWithPartialAggregationBelowJoin.

@Test
public void testWithPartialAggregationBelowJoin() {
    PlanNode root = builder.aggregation(af -> af.step(FINAL).groupingSets(groupingSets(ImmutableList.of(variable), 2, ImmutableSet.of(0))).source(builder.join(INNER, builder.exchange(e -> e.type(REPARTITION).scope(LOCAL).fixedHashDistributionParitioningScheme(ImmutableList.of(variable), ImmutableList.of(variable)).addInputsSet(variable).addSource(builder.aggregation(ap -> ap.step(PARTIAL).groupingSets(groupingSets(ImmutableList.of(variable), 2, ImmutableSet.of(0))).source(tableScanNode)))), builder.values())));
    validatePlan(root, true);
}
Also used : WarningCollector(com.facebook.presto.spi.WarningCollector) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) Test(org.testng.annotations.Test) TpchTableLayoutHandle(com.facebook.presto.tpch.TpchTableLayoutHandle) TEST_SESSION(com.facebook.presto.SessionTestUtils.TEST_SESSION) ImmutableList(com.google.common.collect.ImmutableList) LOCAL(com.facebook.presto.sql.planner.plan.ExchangeNode.Scope.LOCAL) REPARTITION(com.facebook.presto.sql.planner.plan.ExchangeNode.Type.REPARTITION) FINAL(com.facebook.presto.spi.plan.AggregationNode.Step.FINAL) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) TableHandle(com.facebook.presto.spi.TableHandle) PARTIAL(com.facebook.presto.spi.plan.AggregationNode.Step.PARTIAL) BIGINT(com.facebook.presto.common.type.BigintType.BIGINT) ImmutableSet(com.google.common.collect.ImmutableSet) PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) ImmutableMap(com.google.common.collect.ImmutableMap) BeforeClass(org.testng.annotations.BeforeClass) TestingTransactionHandle(com.facebook.presto.testing.TestingTransactionHandle) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) SqlParser(com.facebook.presto.sql.parser.SqlParser) REMOTE_STREAMING(com.facebook.presto.sql.planner.plan.ExchangeNode.Scope.REMOTE_STREAMING) PlanNode(com.facebook.presto.spi.plan.PlanNode) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) AggregationNode.groupingSets(com.facebook.presto.spi.plan.AggregationNode.groupingSets) TpchColumnHandle(com.facebook.presto.tpch.TpchColumnHandle) TableScanNode(com.facebook.presto.spi.plan.TableScanNode) Optional(java.util.Optional) ConnectorId(com.facebook.presto.spi.ConnectorId) Metadata(com.facebook.presto.metadata.Metadata) INNER(com.facebook.presto.sql.planner.plan.JoinNode.Type.INNER) PlanNode(com.facebook.presto.spi.plan.PlanNode) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Example 28 with PlanNode

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

the class TestValidateAggregationsWithDefaultValues method testSingleNodeFinalAggregationInTheSameStageAsPartialAggregation.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Final aggregation with default value not separated from partial aggregation by local hash exchange")
public void testSingleNodeFinalAggregationInTheSameStageAsPartialAggregation() {
    PlanNode root = builder.aggregation(af -> af.step(FINAL).groupingSets(groupingSets(ImmutableList.of(variable), 2, ImmutableSet.of(0))).source(builder.aggregation(ap -> ap.step(PARTIAL).groupingSets(groupingSets(ImmutableList.of(variable), 2, ImmutableSet.of(0))).source(tableScanNode))));
    validatePlan(root, true);
}
Also used : PlanNode(com.facebook.presto.spi.plan.PlanNode) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Example 29 with PlanNode

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

the class TestValidateStreamingJoins method validatePlan.

private void validatePlan(Function<PlanBuilder, PlanNode> planProvider) {
    PlanBuilder builder = new PlanBuilder(TEST_SESSION, idAllocator, metadata);
    PlanNode planNode = planProvider.apply(builder);
    TypeProvider types = builder.getTypes();
    getQueryRunner().inTransaction(testSession, session -> {
        session.getCatalog().ifPresent(catalog -> metadata.getCatalogHandle(session, catalog));
        new ValidateStreamingJoins().validate(planNode, session, metadata, sqlParser, types, WarningCollector.NOOP);
        return null;
    });
}
Also used : PlanNode(com.facebook.presto.spi.plan.PlanNode) TypeProvider(com.facebook.presto.sql.planner.TypeProvider) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder)

Example 30 with PlanNode

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

the class TestVerifyOnlyOneOutputNode method testValidateFailed.

@Test(expectedExceptions = IllegalStateException.class)
public void testValidateFailed() {
    // random plan with 2 output nodes
    PlanNode root = new OutputNode(Optional.empty(), idAllocator.getNextId(), new ExplainAnalyzeNode(Optional.empty(), idAllocator.getNextId(), new OutputNode(Optional.empty(), idAllocator.getNextId(), new ProjectNode(idAllocator.getNextId(), new ValuesNode(Optional.empty(), idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of()), Assignments.of()), ImmutableList.of(), ImmutableList.of()), new VariableReferenceExpression(Optional.empty(), "a", BIGINT), false), ImmutableList.of(), ImmutableList.of());
    new VerifyOnlyOneOutputNode().validate(root, null, null, null, null, WarningCollector.NOOP);
}
Also used : ValuesNode(com.facebook.presto.spi.plan.ValuesNode) OutputNode(com.facebook.presto.sql.planner.plan.OutputNode) PlanNode(com.facebook.presto.spi.plan.PlanNode) ExplainAnalyzeNode(com.facebook.presto.sql.planner.plan.ExplainAnalyzeNode) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) ProjectNode(com.facebook.presto.spi.plan.ProjectNode) Test(org.testng.annotations.Test)

Aggregations

PlanNode (com.facebook.presto.spi.plan.PlanNode)228 Test (org.testng.annotations.Test)114 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)94 ImmutableList (com.google.common.collect.ImmutableList)56 RowExpression (com.facebook.presto.spi.relation.RowExpression)45 ImmutableMap (com.google.common.collect.ImmutableMap)44 PlanBuilder (com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder)42 TableScanNode (com.facebook.presto.spi.plan.TableScanNode)41 AggregationNode (com.facebook.presto.spi.plan.AggregationNode)40 ProjectNode (com.facebook.presto.spi.plan.ProjectNode)40 Map (java.util.Map)39 Optional (java.util.Optional)38 List (java.util.List)36 JoinNode (com.facebook.presto.sql.planner.plan.JoinNode)35 Set (java.util.Set)30 Assert.assertEquals (org.testng.Assert.assertEquals)23 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)22 OrderingScheme (com.facebook.presto.spi.plan.OrderingScheme)20 Function (java.util.function.Function)20 Metadata (com.facebook.presto.metadata.Metadata)19