Search in sources :

Example 21 with PlanNode

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

the class TestDynamicFiltersChecker method testUnconsumedDynamicFilterInJoin.

@Test(expectedExceptions = VerifyException.class, expectedExceptionsMessageRegExp = "Dynamic filters \\[DF\\] present in join were not fully consumed by its probe side," + " currentJoinDynamicFilters is: \\[DF\\], consumedProbeSide is: \\[\\]")
public void testUnconsumedDynamicFilterInJoin() {
    PlanNode root = builder.join(INNER, builder.filter(builder.rowExpression("ORDERS_OK > 0"), ordersTableScanNode), lineitemTableScanNode, ImmutableList.of(new JoinNode.EquiJoinClause(ordersOrderKeyVariable, lineitemOrderKeyVariable)), ImmutableList.of(ordersOrderKeyVariable), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of("DF", lineitemOrderKeyVariable));
    validatePlan(root);
}
Also used : PlanNode(com.facebook.presto.spi.plan.PlanNode) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Example 22 with PlanNode

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

the class TestDynamicFiltersChecker method testUnmatchedDynamicFilter.

@Test(expectedExceptions = VerifyException.class, expectedExceptionsMessageRegExp = "All consumed dynamic filters could not be matched with a join.")
public void testUnmatchedDynamicFilter() {
    PlanNode root = builder.output(ImmutableList.of(), ImmutableList.of(), builder.join(INNER, ordersTableScanNode, builder.filter(logicalRowExpressions.combineConjuncts(builder.rowExpression("LINEITEM_OK > 0"), createDynamicFilterExpression("DF", lineitemOrderKeyVariable, metadata.getFunctionAndTypeManager())), lineitemTableScanNode), ImmutableList.of(new JoinNode.EquiJoinClause(ordersOrderKeyVariable, lineitemOrderKeyVariable)), ImmutableList.of(ordersOrderKeyVariable), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of()));
    validatePlan(root);
}
Also used : PlanNode(com.facebook.presto.spi.plan.PlanNode) JoinNode(com.facebook.presto.sql.planner.plan.JoinNode) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Example 23 with PlanNode

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

the class TestValidateStreamingAggregations 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(session -> {
        // metadata.getCatalogHandle() registers the catalog for the transaction
        session.getCatalog().ifPresent(catalog -> metadata.getCatalogHandle(session, catalog));
        new ValidateStreamingAggregations().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 24 with PlanNode

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

the class TestValidateAggregationsWithDefaultValues method testGloballyDistributedFinalAggregationInTheSameStageAsPartialAggregation.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Final aggregation with default value not separated from partial aggregation by remote hash exchange")
public void testGloballyDistributedFinalAggregationInTheSameStageAsPartialAggregation() {
    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, false);
}
Also used : PlanNode(com.facebook.presto.spi.plan.PlanNode) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Example 25 with PlanNode

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

the class TestValidateAggregationsWithDefaultValues method testSingleThreadFinalAggregationInTheSameStageAsPartialAggregation.

@Test
public void testSingleThreadFinalAggregationInTheSameStageAsPartialAggregation() {
    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(builder.values()))));
    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)

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