use of com.facebook.presto.spi.plan.TableScanNode in project presto by prestodb.
the class TestPinotPlanOptimizer method testPartialPredicatePushdown.
@Test
public void testPartialPredicatePushdown() {
PlanBuilder planBuilder = createPlanBuilder(defaultSessionHolder);
TableScanNode tableScanNode = tableScan(planBuilder, pinotTable, regionId, city, fare, secondsSinceEpoch);
FilterNode filter = filter(planBuilder, tableScanNode, getRowExpression("lower(substr(city, 0, 3)) = 'del' AND fare > 100", defaultSessionHolder));
PlanNode originalPlan = limit(planBuilder, 50L, filter);
PlanNode optimized = getOptimizedPlan(planBuilder, originalPlan);
PlanMatchPattern tableScanMatcher = PinotTableScanMatcher.match(pinotTable, Optional.of("SELECT regionId, city, fare, secondsSinceEpoch FROM hybrid__TABLE_NAME_SUFFIX_TEMPLATE__ WHERE \\(fare > 100\\).*"), Optional.of(true), filter.getOutputVariables(), useSqlSyntax());
assertPlanMatch(optimized, PlanMatchPattern.limit(50L, PlanMatchPattern.filter("lower(substr(city, 0, 3)) = 'del'", tableScanMatcher)), typeProvider);
}
use of com.facebook.presto.spi.plan.TableScanNode in project presto by prestodb.
the class TestPinotQueryGenerator method testAggregationWithOrderByPushDownInTopN.
@Test(expectedExceptions = NoSuchElementException.class)
public void testAggregationWithOrderByPushDownInTopN() {
PlanBuilder planBuilder = createPlanBuilder(defaultSessionHolder);
TableScanNode tableScanNode = tableScan(planBuilder, pinotTable, city, fare);
AggregationNode agg = planBuilder.aggregation(aggBuilder -> aggBuilder.source(tableScanNode).singleGroupingSet(variable("city")).addAggregation(planBuilder.variable("agg"), getRowExpression("sum(fare)", defaultSessionHolder)));
TopNNode topN = new TopNNode(Optional.empty(), planBuilder.getIdAllocator().getNextId(), agg, 50L, new OrderingScheme(ImmutableList.of(new Ordering(variable("city"), SortOrder.DESC_NULLS_FIRST))), TopNNode.Step.FINAL);
testPinotQuery(pinotConfig, topN, "", defaultSessionHolder, ImmutableMap.of());
}
use of com.facebook.presto.spi.plan.TableScanNode in project presto by prestodb.
the class TestPinotQueryGenerator method testSimpleSelectWithTopN.
@Test
public void testSimpleSelectWithTopN() {
pinotConfig.setPushdownTopNBrokerQueries(true);
SessionHolder sessionHolder = new SessionHolder(pinotConfig);
PlanBuilder planBuilder = createPlanBuilder(new SessionHolder(pinotConfig));
TableScanNode tableScanNode = tableScan(planBuilder, pinotTable, regionId, city, fare);
TopNNode topNFare = topN(planBuilder, 50L, ImmutableList.of("fare"), ImmutableList.of(false), tableScanNode);
testPinotQuery(pinotConfig, topNFare, "SELECT regionId, city, fare FROM realtimeOnly ORDER BY fare DESC LIMIT 50", sessionHolder, ImmutableMap.of());
TopNNode topnFareAndCity = topN(planBuilder, 50L, ImmutableList.of("fare", "city"), ImmutableList.of(true, false), tableScanNode);
testPinotQuery(pinotConfig, topnFareAndCity, "SELECT regionId, city, fare FROM realtimeOnly ORDER BY fare, city DESC LIMIT 50", sessionHolder, ImmutableMap.of());
ProjectNode projectNode = project(planBuilder, topnFareAndCity, ImmutableList.of("regionid", "city"));
testPinotQuery(pinotConfig, projectNode, "SELECT regionId, city FROM realtimeOnly ORDER BY fare, city DESC LIMIT 50", sessionHolder, ImmutableMap.of());
}
use of com.facebook.presto.spi.plan.TableScanNode in project presto by prestodb.
the class TestPinotQueryGeneratorSql method testAggregationWithGroupBy.
@Test
public void testAggregationWithGroupBy() {
PlanBuilder planBuilder = createPlanBuilder(defaultSessionHolder);
TableScanNode tableScanNode = tableScan(planBuilder, pinotTable, regionId, city, fare);
AggregationNode aggregationNode = planBuilder.aggregation(aggregationNodeBuilder -> aggregationNodeBuilder.source(tableScanNode).singleGroupingSet(variable("city"), variable("regionid")).addAggregation(planBuilder.variable("sum_fare"), getRowExpression("sum(fare)", defaultSessionHolder)).addAggregation(planBuilder.variable("count_regionid"), getRowExpression("count(regionid)", defaultSessionHolder)));
testPinotQuery(pinotConfig, aggregationNode, ImmutableList.of("SELECT city, regionId, sum(fare), count(regionId) FROM realtimeOnly GROUP BY city, regionId LIMIT 10000", "SELECT city, regionId, count(regionId), sum(fare) FROM realtimeOnly GROUP BY city, regionId LIMIT 10000"), defaultSessionHolder, ImmutableMap.of());
ProjectNode project = planBuilder.project(Assignments.builder().put(variable("count_regionid"), variable("count_regionid")).put(variable("city"), variable("city")).put(variable("regionid"), variable("regionid")).put(variable("sum_fare"), variable("sum_fare")).build(), aggregationNode);
testPinotQuery(pinotConfig, project, "SELECT city, regionId, count(regionId), sum(fare) FROM realtimeOnly GROUP BY city, regionId LIMIT 10000", defaultSessionHolder, ImmutableMap.of());
project = planBuilder.project(Assignments.builder().put(variable("count_regionid"), variable("count_regionid")).put(variable("regionid"), variable("regionid")).put(variable("sum_fare"), variable("sum_fare")).build(), aggregationNode);
testPinotQuery(pinotConfig, project, "SELECT city, regionId, count(regionId), sum(fare) FROM realtimeOnly GROUP BY city, regionId LIMIT 10000", defaultSessionHolder, ImmutableMap.of());
project = planBuilder.project(Assignments.builder().put(variable("count_regionid"), variable("count_regionid")).put(variable("city"), variable("city")).put(variable("sum_fare"), variable("sum_fare")).build(), aggregationNode);
testPinotQuery(pinotConfig, project, "SELECT city, regionId, count(regionId), sum(fare) FROM realtimeOnly GROUP BY city, regionId LIMIT 10000", defaultSessionHolder, ImmutableMap.of());
project = planBuilder.project(Assignments.builder().put(variable("sum_fare"), variable("sum_fare")).put(variable("count_regionid"), variable("count_regionid")).build(), aggregationNode);
testPinotQuery(pinotConfig, project, "SELECT city, regionId, sum(fare), count(regionId) FROM realtimeOnly GROUP BY city, regionId LIMIT 10000", defaultSessionHolder, ImmutableMap.of());
}
use of com.facebook.presto.spi.plan.TableScanNode in project presto by prestodb.
the class TestPinotQueryGeneratorSql method testDistinctSelection.
@Override
@Test
public void testDistinctSelection() {
PlanBuilder planBuilder = createPlanBuilder(defaultSessionHolder);
TableScanNode tableScanNode = tableScan(planBuilder, pinotTable, regionId, secondsSinceEpoch, city, fare);
AggregationNode aggregationNode = planBuilder.aggregation(aggBuilder -> aggBuilder.source(tableScanNode).singleGroupingSet(variable("regionid")));
testPinotQuery(pinotConfig, aggregationNode, "SELECT regionId FROM realtimeOnly GROUP BY regionId LIMIT 10000", defaultSessionHolder, ImmutableMap.of());
aggregationNode = planBuilder.aggregation(aggBuilder -> aggBuilder.source(tableScanNode).singleGroupingSet(variable("city"), variable("regionid")));
testPinotQuery(pinotConfig, aggregationNode, "SELECT city, regionId FROM realtimeOnly GROUP BY city, regionId LIMIT 10000", defaultSessionHolder, ImmutableMap.of());
}
Aggregations