Search in sources :

Example 1 with PARTIAL_AGGREGATION_STRATEGY

use of com.facebook.presto.SystemSessionProperties.PARTIAL_AGGREGATION_STRATEGY in project presto by prestodb.

the class TestPushPartialAggregationThroughExchange method testPartialAggregationEnabledWhenNotConfident.

@Test
public void testPartialAggregationEnabledWhenNotConfident() {
    tester().assertThat(new PushPartialAggregationThroughExchange(getFunctionManager())).setSystemProperty(PARTIAL_AGGREGATION_STRATEGY, "AUTOMATIC").on(p -> {
        VariableReferenceExpression a = p.variable("a", DOUBLE);
        VariableReferenceExpression b = p.variable("b", DOUBLE);
        return p.aggregation(ab -> ab.source(p.exchange(e -> e.addSource(p.values(new PlanNodeId("values"), a, b)).addInputsSet(a, b).singleDistributionPartitioningScheme(a, b))).addAggregation(p.variable("SUM", DOUBLE), expression("SUM(a)"), ImmutableList.of(DOUBLE)).singleGroupingSet(b).step(PARTIAL));
    }).overrideStats("values", PlanNodeStatsEstimate.builder().setOutputRowCount(1000).addVariableStatistics(variable("b", DOUBLE), new VariableStatsEstimate(0, 100, 0, 8, 800)).setConfident(false).build()).matches(exchange(project(aggregation(ImmutableMap.of("SUM", functionCall("sum", ImmutableList.of("a"))), PARTIAL, values("a", "b")))));
}
Also used : PARTIAL(com.facebook.presto.spi.plan.AggregationNode.Step.PARTIAL) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) PlanNodeStatsEstimate(com.facebook.presto.cost.PlanNodeStatsEstimate) PlanMatchPattern.project(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.project) ImmutableMap(com.google.common.collect.ImmutableMap) DOUBLE(com.facebook.presto.common.type.DoubleType.DOUBLE) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) Test(org.testng.annotations.Test) PlanMatchPattern.exchange(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.exchange) SINGLE(com.facebook.presto.spi.plan.AggregationNode.Step.SINGLE) BaseRuleTest(com.facebook.presto.sql.planner.iterative.rule.test.BaseRuleTest) ImmutableList(com.google.common.collect.ImmutableList) PlanMatchPattern.values(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.values) Expressions.variable(com.facebook.presto.sql.relational.Expressions.variable) VariableStatsEstimate(com.facebook.presto.cost.VariableStatsEstimate) PlanBuilder.expression(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder.expression) PlanMatchPattern.functionCall(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.functionCall) PARTIAL_AGGREGATION_STRATEGY(com.facebook.presto.SystemSessionProperties.PARTIAL_AGGREGATION_STRATEGY) PlanMatchPattern.aggregation(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.aggregation) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) VariableStatsEstimate(com.facebook.presto.cost.VariableStatsEstimate) Test(org.testng.annotations.Test) BaseRuleTest(com.facebook.presto.sql.planner.iterative.rule.test.BaseRuleTest)

Example 2 with PARTIAL_AGGREGATION_STRATEGY

use of com.facebook.presto.SystemSessionProperties.PARTIAL_AGGREGATION_STRATEGY in project presto by prestodb.

the class TestPushPartialAggregationThroughExchange method testNoPartialAggregationWhenReductionBelowThreshold.

@Test
public void testNoPartialAggregationWhenReductionBelowThreshold() {
    tester().assertThat(new PushPartialAggregationThroughExchange(getFunctionManager())).setSystemProperty(PARTIAL_AGGREGATION_STRATEGY, "AUTOMATIC").on(p -> {
        VariableReferenceExpression a = p.variable("a", DOUBLE);
        VariableReferenceExpression b = p.variable("b", DOUBLE);
        return p.aggregation(ab -> ab.source(p.exchange(e -> e.addSource(p.values(new PlanNodeId("values"), a, b)).addInputsSet(a, b).singleDistributionPartitioningScheme(a, b))).addAggregation(p.variable("SUM", DOUBLE), expression("SUM(a)"), ImmutableList.of(DOUBLE)).singleGroupingSet(b).step(SINGLE));
    }).overrideStats("values", PlanNodeStatsEstimate.builder().setOutputRowCount(1000).addVariableStatistics(variable("b", DOUBLE), new VariableStatsEstimate(0, 100, 0, 8, 800)).setConfident(true).build()).doesNotFire();
}
Also used : PARTIAL(com.facebook.presto.spi.plan.AggregationNode.Step.PARTIAL) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) PlanNodeStatsEstimate(com.facebook.presto.cost.PlanNodeStatsEstimate) PlanMatchPattern.project(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.project) ImmutableMap(com.google.common.collect.ImmutableMap) DOUBLE(com.facebook.presto.common.type.DoubleType.DOUBLE) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) Test(org.testng.annotations.Test) PlanMatchPattern.exchange(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.exchange) SINGLE(com.facebook.presto.spi.plan.AggregationNode.Step.SINGLE) BaseRuleTest(com.facebook.presto.sql.planner.iterative.rule.test.BaseRuleTest) ImmutableList(com.google.common.collect.ImmutableList) PlanMatchPattern.values(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.values) Expressions.variable(com.facebook.presto.sql.relational.Expressions.variable) VariableStatsEstimate(com.facebook.presto.cost.VariableStatsEstimate) PlanBuilder.expression(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder.expression) PlanMatchPattern.functionCall(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.functionCall) PARTIAL_AGGREGATION_STRATEGY(com.facebook.presto.SystemSessionProperties.PARTIAL_AGGREGATION_STRATEGY) PlanMatchPattern.aggregation(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.aggregation) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) VariableStatsEstimate(com.facebook.presto.cost.VariableStatsEstimate) Test(org.testng.annotations.Test) BaseRuleTest(com.facebook.presto.sql.planner.iterative.rule.test.BaseRuleTest)

Aggregations

PARTIAL_AGGREGATION_STRATEGY (com.facebook.presto.SystemSessionProperties.PARTIAL_AGGREGATION_STRATEGY)2 DOUBLE (com.facebook.presto.common.type.DoubleType.DOUBLE)2 PlanNodeStatsEstimate (com.facebook.presto.cost.PlanNodeStatsEstimate)2 VariableStatsEstimate (com.facebook.presto.cost.VariableStatsEstimate)2 PARTIAL (com.facebook.presto.spi.plan.AggregationNode.Step.PARTIAL)2 SINGLE (com.facebook.presto.spi.plan.AggregationNode.Step.SINGLE)2 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)2 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)2 PlanMatchPattern.aggregation (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.aggregation)2 PlanMatchPattern.exchange (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.exchange)2 PlanMatchPattern.functionCall (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.functionCall)2 PlanMatchPattern.project (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.project)2 PlanMatchPattern.values (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.values)2 BaseRuleTest (com.facebook.presto.sql.planner.iterative.rule.test.BaseRuleTest)2 PlanBuilder.expression (com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder.expression)2 Expressions.variable (com.facebook.presto.sql.relational.Expressions.variable)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Test (org.testng.annotations.Test)2