Search in sources :

Example 6 with ExpectedValueProvider

use of com.facebook.presto.sql.planner.assertions.ExpectedValueProvider in project presto by prestodb.

the class TestPinotPlanOptimizer method testUnsupportedPredicatePushdown.

@Test
public void testUnsupportedPredicatePushdown() {
    Map<String, ExpectedValueProvider<FunctionCall>> aggregationsSecond = ImmutableMap.of("count", PlanMatchPattern.functionCall("count", false, ImmutableList.of()));
    PlanBuilder planBuilder = createPlanBuilder(defaultSessionHolder);
    PlanNode limit = limit(planBuilder, 50L, tableScan(planBuilder, pinotTable, regionId, city, fare, secondsSinceEpoch));
    PlanNode originalPlan = planBuilder.aggregation(builder -> builder.source(limit).globalGrouping().addAggregation(new VariableReferenceExpression(Optional.empty(), "count", BIGINT), getRowExpression("count(*)", defaultSessionHolder)));
    PlanNode optimized = getOptimizedPlan(planBuilder, originalPlan);
    PlanMatchPattern tableScanMatcher = PinotTableScanMatcher.match(pinotTable, Optional.of("SELECT regionId, city, fare, secondsSinceEpoch FROM hybrid LIMIT 50"), Optional.of(false), originalPlan.getOutputVariables(), useSqlSyntax());
    assertPlanMatch(optimized, aggregation(aggregationsSecond, tableScanMatcher), typeProvider);
}
Also used : ExpectedValueProvider(com.facebook.presto.sql.planner.assertions.ExpectedValueProvider) PlanNode(com.facebook.presto.spi.plan.PlanNode) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) PlanMatchPattern(com.facebook.presto.sql.planner.assertions.PlanMatchPattern) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) Test(org.testng.annotations.Test)

Aggregations

ExpectedValueProvider (com.facebook.presto.sql.planner.assertions.ExpectedValueProvider)6 Test (org.testng.annotations.Test)6 PlanMatchPattern (com.facebook.presto.sql.planner.assertions.PlanMatchPattern)5 Optional (java.util.Optional)5 ImmutableList (com.google.common.collect.ImmutableList)4 List (java.util.List)4 Language (org.intellij.lang.annotations.Language)3 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)2 BasePlanTest (com.facebook.presto.sql.planner.assertions.BasePlanTest)2 PlanMatchPattern.functionCall (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.functionCall)2 PlanMatchPattern.specification (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.specification)2 PlanMatchPattern.window (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.window)2 WindowNode (com.facebook.presto.sql.planner.plan.WindowNode)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Session (com.facebook.presto.Session)1 SortOrder (com.facebook.presto.common.block.SortOrder)1 BIGINT (com.facebook.presto.common.type.BigintType.BIGINT)1 DOUBLE (com.facebook.presto.common.type.DoubleType.DOUBLE)1 MetadataManager.createTestMetadataManager (com.facebook.presto.metadata.MetadataManager.createTestMetadataManager)1 FunctionHandle (com.facebook.presto.spi.function.FunctionHandle)1