use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestPinotQueryGenerator method testDistinctCountGroupByPushdown.
@Test
public void testDistinctCountGroupByPushdown() {
PlanNode justScan = buildPlan(planBuilder -> tableScan(planBuilder, pinotTable, regionId, secondsSinceEpoch, city, fare));
PlanNode distinctAggregation = buildPlan(planBuilder -> planBuilder.aggregation(aggBuilder -> aggBuilder.source(justScan).singleGroupingSet(variable("city"), variable("regionid"))));
testPinotQuery(planBuilder -> planBuilder.aggregation(aggBuilder -> aggBuilder.source(distinctAggregation).singleGroupingSet(variable("city")).addAggregation(variable("count_regionid"), getRowExpression("count(regionid)", defaultSessionHolder))), String.format("SELECT %s FROM realtimeOnly GROUP BY city %s 10000", getExpectedAggOutput("DISTINCTCOUNT(regionId)", "city"), getGroupByLimitKey()));
}
use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestPinotQueryGenerator method testDistinctCountPushdownWithVariableSuffix.
@Test
public void testDistinctCountPushdownWithVariableSuffix() {
Map<VariableReferenceExpression, PinotColumnHandle> columnHandleMap = ImmutableMap.of(new VariableReferenceExpression(Optional.empty(), "regionid_33", regionId.getDataType()), regionId);
PlanNode justScan = buildPlan(planBuilder -> tableScan(planBuilder, pinotTable, columnHandleMap));
PlanNode markDistinct = buildPlan(planBuilder -> markDistinct(planBuilder, variable("regionid$distinct_62"), ImmutableList.of(variable("regionid")), justScan));
PlanNode aggregate = buildPlan(planBuilder -> planBuilder.aggregation(aggBuilder -> aggBuilder.source(markDistinct).addAggregation(planBuilder.variable("count(regionid_33)"), getRowExpression("count(regionid_33)", defaultSessionHolder), Optional.empty(), Optional.empty(), false, Optional.of(variable("regionid$distinct_62"))).globalGrouping()));
testPinotQuery(new PinotConfig().setAllowMultipleAggregations(true), planBuilder -> planBuilder.limit(10, aggregate), "SELECT DISTINCTCOUNT(regionId) FROM realtimeOnly");
}
use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestRemoveUnsupportedDynamicFilters method removeUnsupportedDynamicFilters.
PlanNode removeUnsupportedDynamicFilters(PlanNode root) {
return getQueryRunner().inTransaction(session -> {
// metadata.getCatalogHandle() registers the catalog for the transaction
session.getCatalog().ifPresent(catalog -> metadata.getCatalogHandle(session, catalog));
PlanNode rewrittenPlan = new RemoveUnsupportedDynamicFilters(metadata.getFunctionAndTypeManager()).optimize(root, session, TypeProvider.empty(), new PlanVariableAllocator(), new PlanNodeIdAllocator(), WarningCollector.NOOP);
new DynamicFiltersChecker().validate(rewrittenPlan, session, metadata, new SqlParser(), TypeProvider.empty(), WarningCollector.NOOP);
return rewrittenPlan;
});
}
use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestRemoveUnsupportedDynamicFilters method testNestedDynamicFilterConjunctionRewrite.
@Test
public void testNestedDynamicFilterConjunctionRewrite() {
PlanNode root = builder.output(ImmutableList.of(), ImmutableList.of(), builder.join(INNER, ordersTableScanNode, builder.filter(logicalRowExpressions.combineDisjuncts(logicalRowExpressions.combineConjuncts(builder.rowExpression("LINEITEM_OK IS NULL"), createDynamicFilterExpression("DF", lineitemOrderKeyVariable, metadata.getFunctionAndTypeManager())), logicalRowExpressions.combineConjuncts(builder.rowExpression("LINEITEM_OK IS NOT NULL"), createDynamicFilterExpression("DF", lineitemOrderKeyVariable, metadata.getFunctionAndTypeManager()))), lineitemTableScanNode), ImmutableList.of(new JoinNode.EquiJoinClause(ordersOrderKeyVariable, lineitemOrderKeyVariable)), ImmutableList.of(ordersOrderKeyVariable), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of()));
assertPlan(removeUnsupportedDynamicFilters(root), output(join(INNER, ImmutableList.of(equiJoinClause("ORDERS_OK", "LINEITEM_OK")), tableScan("orders", ImmutableMap.of("ORDERS_OK", "orderkey")), filter(combineDisjuncts(ImmutableList.of(PlanBuilder.expression("LINEITEM_OK IS NULL"), PlanBuilder.expression("LINEITEM_OK IS NOT NULL"))), tableScan("lineitem", ImmutableMap.of("LINEITEM_OK", "orderkey"))))));
}
use of com.facebook.presto.spi.plan.PlanNode in project presto by prestodb.
the class TestRemoveUnsupportedDynamicFilters method testDynamicFilterConsumedOnBuildSide.
@Test
public void testDynamicFilterConsumedOnBuildSide() {
PlanNode root = builder.join(INNER, builder.filter(createDynamicFilterExpression("DF", ordersOrderKeyVariable, metadata.getFunctionAndTypeManager()), ordersTableScanNode), builder.filter(createDynamicFilterExpression("DF", ordersOrderKeyVariable, metadata.getFunctionAndTypeManager()), lineitemTableScanNode), ImmutableList.of(new JoinNode.EquiJoinClause(ordersOrderKeyVariable, lineitemOrderKeyVariable)), ImmutableList.of(ordersOrderKeyVariable), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of("DF", lineitemOrderKeyVariable));
PlanNode planNode = removeUnsupportedDynamicFilters(root);
assertTrue(planNode instanceof JoinNode);
JoinNode joinNode = (JoinNode) planNode;
assertEquals(joinNode.getDynamicFilters(), ImmutableMap.of("DF", lineitemOrderKeyVariable));
}
Aggregations