use of com.facebook.presto.pinot.PinotConfig in project presto by prestodb.
the class TestPinotQueryGenerator method testDistinctCountWithOtherAggregationGroupByPushdown.
@Test
public void testDistinctCountWithOtherAggregationGroupByPushdown() {
PlanNode justScan = buildPlan(planBuilder -> tableScan(planBuilder, pinotTable, regionId, secondsSinceEpoch, city, fare));
PlanNode markDistinct = buildPlan(planBuilder -> markDistinct(planBuilder, variable("regionid$distinct"), ImmutableList.of(variable("regionid")), justScan));
PlanNode aggregate = buildPlan(planBuilder -> planBuilder.aggregation(aggBuilder -> aggBuilder.source(markDistinct).singleGroupingSet(variable("city")).addAggregation(planBuilder.variable("agg"), getRowExpression("count(*)", defaultSessionHolder)).addAggregation(planBuilder.variable("count(regionid)"), getRowExpression("count(regionid)", defaultSessionHolder), Optional.empty(), Optional.empty(), false, Optional.of(variable("regionid$distinct")))));
String expectedPinotQuery;
if (aggregate.getOutputVariables().get(1).getName().equalsIgnoreCase("count(regionid)")) {
expectedPinotQuery = String.format("SELECT %s FROM realtimeOnly GROUP BY city %s 10000", getExpectedAggOutput("DISTINCTCOUNT(regionId), count(*)", "city"), getGroupByLimitKey());
} else {
expectedPinotQuery = String.format("SELECT %s FROM realtimeOnly GROUP BY city %s 10000", getExpectedAggOutput("count(*), DISTINCTCOUNT(regionId)", "city"), getGroupByLimitKey());
}
testPinotQuery(new PinotConfig().setAllowMultipleAggregations(true), aggregate, expectedPinotQuery);
}
use of com.facebook.presto.pinot.PinotConfig in project presto by prestodb.
the class TestPinotQueryGenerator method testApproxDistinctWithInvalidParameters.
@Test
public void testApproxDistinctWithInvalidParameters() {
PlanNode justScan = buildPlan(planBuilder -> tableScan(planBuilder, pinotTable, regionId, secondsSinceEpoch, city, fare));
PlanNode approxPlanNode = buildPlan(planBuilder -> planBuilder.aggregation(aggBuilder -> aggBuilder.source(justScan).singleGroupingSet(variable("city")).addAggregation(planBuilder.variable("agg"), getRowExpression("approx_distinct(fare, 0)", defaultSessionHolder))));
Optional<PinotQueryGenerator.PinotQueryGeneratorResult> generatedQuery = new PinotQueryGenerator(pinotConfig, functionAndTypeManager, functionAndTypeManager, standardFunctionResolution).generate(approxPlanNode, defaultSessionHolder.getConnectorSession());
assertFalse(generatedQuery.isPresent());
approxPlanNode = buildPlan(planBuilder -> planBuilder.aggregation(aggBuilder -> aggBuilder.source(justScan).singleGroupingSet(variable("city")).addAggregation(planBuilder.variable("agg"), getRowExpression("approx_distinct(fare, 0.004)", defaultSessionHolder))));
generatedQuery = new PinotQueryGenerator(pinotConfig, functionAndTypeManager, functionAndTypeManager, standardFunctionResolution).generate(approxPlanNode, defaultSessionHolder.getConnectorSession());
assertFalse(generatedQuery.isPresent());
approxPlanNode = buildPlan(planBuilder -> planBuilder.aggregation(aggBuilder -> aggBuilder.source(justScan).singleGroupingSet(variable("city")).addAggregation(planBuilder.variable("agg"), getRowExpression("approx_distinct(fare, 1)", defaultSessionHolder))));
generatedQuery = new PinotQueryGenerator(pinotConfig, functionAndTypeManager, functionAndTypeManager, standardFunctionResolution).generate(approxPlanNode, defaultSessionHolder.getConnectorSession());
assertFalse(generatedQuery.isPresent());
}
use of com.facebook.presto.pinot.PinotConfig in project presto by prestodb.
the class TestPinotQueryGenerator method testDistinctCountWithOtherAggregationPushdown.
@Test
public void testDistinctCountWithOtherAggregationPushdown() {
PlanNode justScan = buildPlan(planBuilder -> tableScan(planBuilder, pinotTable, regionId, secondsSinceEpoch, city, fare));
PlanNode markDistinct = buildPlan(planBuilder -> markDistinct(planBuilder, variable("regionid$distinct"), ImmutableList.of(variable("regionid")), justScan));
PlanNode aggregate = buildPlan(planBuilder -> planBuilder.aggregation(aggBuilder -> aggBuilder.source(markDistinct).addAggregation(planBuilder.variable("agg"), getRowExpression("count(*)", defaultSessionHolder)).addAggregation(planBuilder.variable("count(regionid)"), getRowExpression("count(regionid)", defaultSessionHolder), Optional.empty(), Optional.empty(), false, Optional.of(variable("regionid$distinct"))).globalGrouping()));
String expectedPinotQuery;
if (aggregate.getOutputVariables().get(0).getName().equalsIgnoreCase("count(regionid)")) {
expectedPinotQuery = "SELECT DISTINCTCOUNT(regionId), count(*) FROM realtimeOnly";
} else {
expectedPinotQuery = "SELECT count(*), DISTINCTCOUNT(regionId) FROM realtimeOnly";
}
testPinotQuery(new PinotConfig().setAllowMultipleAggregations(true), planBuilder -> planBuilder.limit(10, aggregate), expectedPinotQuery);
}
Aggregations