Search in sources :

Example 1 with REPARTITION

use of com.facebook.presto.sql.planner.plan.ExchangeNode.Type.REPARTITION in project presto by prestodb.

the class TestValidateAggregationsWithDefaultValues method testWithPartialAggregationBelowJoin.

@Test
public void testWithPartialAggregationBelowJoin() {
    PlanNode root = builder.aggregation(af -> af.step(FINAL).groupingSets(groupingSets(ImmutableList.of(variable), 2, ImmutableSet.of(0))).source(builder.join(INNER, builder.exchange(e -> e.type(REPARTITION).scope(LOCAL).fixedHashDistributionParitioningScheme(ImmutableList.of(variable), ImmutableList.of(variable)).addInputsSet(variable).addSource(builder.aggregation(ap -> ap.step(PARTIAL).groupingSets(groupingSets(ImmutableList.of(variable), 2, ImmutableSet.of(0))).source(tableScanNode)))), builder.values())));
    validatePlan(root, true);
}
Also used : WarningCollector(com.facebook.presto.spi.WarningCollector) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) Test(org.testng.annotations.Test) TpchTableLayoutHandle(com.facebook.presto.tpch.TpchTableLayoutHandle) TEST_SESSION(com.facebook.presto.SessionTestUtils.TEST_SESSION) ImmutableList(com.google.common.collect.ImmutableList) LOCAL(com.facebook.presto.sql.planner.plan.ExchangeNode.Scope.LOCAL) REPARTITION(com.facebook.presto.sql.planner.plan.ExchangeNode.Type.REPARTITION) FINAL(com.facebook.presto.spi.plan.AggregationNode.Step.FINAL) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) TableHandle(com.facebook.presto.spi.TableHandle) PARTIAL(com.facebook.presto.spi.plan.AggregationNode.Step.PARTIAL) BIGINT(com.facebook.presto.common.type.BigintType.BIGINT) ImmutableSet(com.google.common.collect.ImmutableSet) PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) ImmutableMap(com.google.common.collect.ImmutableMap) BeforeClass(org.testng.annotations.BeforeClass) TestingTransactionHandle(com.facebook.presto.testing.TestingTransactionHandle) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) SqlParser(com.facebook.presto.sql.parser.SqlParser) REMOTE_STREAMING(com.facebook.presto.sql.planner.plan.ExchangeNode.Scope.REMOTE_STREAMING) PlanNode(com.facebook.presto.spi.plan.PlanNode) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) AggregationNode.groupingSets(com.facebook.presto.spi.plan.AggregationNode.groupingSets) TpchColumnHandle(com.facebook.presto.tpch.TpchColumnHandle) TableScanNode(com.facebook.presto.spi.plan.TableScanNode) Optional(java.util.Optional) ConnectorId(com.facebook.presto.spi.ConnectorId) Metadata(com.facebook.presto.metadata.Metadata) INNER(com.facebook.presto.sql.planner.plan.JoinNode.Type.INNER) PlanNode(com.facebook.presto.spi.plan.PlanNode) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Example 2 with REPARTITION

use of com.facebook.presto.sql.planner.plan.ExchangeNode.Type.REPARTITION in project presto by prestodb.

the class TestAddExchangesPlans method assertPlanWithMergePartitionStrategy.

private void assertPlanWithMergePartitionStrategy(String sql, String partitionMergingStrategy, int remoteRepartitionExchangeCount, PlanMatchPattern pattern) {
    Session session = Session.builder(this.getQueryRunner().getDefaultSession()).setSystemProperty(AGGREGATION_PARTITIONING_MERGING_STRATEGY, partitionMergingStrategy).setSystemProperty(TASK_CONCURRENCY, "2").build();
    BiConsumer<Plan, Integer> validateMultipleRemoteRepartitionExchange = (plan, count) -> assertEquals(searchFrom(plan.getRoot()).where(node -> node instanceof ExchangeNode && ((ExchangeNode) node).getScope() == REMOTE_STREAMING && ((ExchangeNode) node).getType() == REPARTITION).count(), count.intValue());
    assertPlanWithSession(sql, session, false, pattern, plan -> validateMultipleRemoteRepartitionExchange.accept(plan, remoteRepartitionExchangeCount));
}
Also used : ALL(com.facebook.presto.execution.QueryManagerConfig.ExchangeMaterializationStrategy.ALL) AggregationNode(com.facebook.presto.spi.plan.AggregationNode) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) PlanMatchPattern.anyTree(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.anyTree) GroupIdNode(com.facebook.presto.sql.planner.plan.GroupIdNode) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) SINGLE(com.facebook.presto.spi.plan.AggregationNode.Step.SINGLE) TestingSession(com.facebook.presto.testing.TestingSession) PlanMatchPattern(com.facebook.presto.sql.planner.assertions.PlanMatchPattern) PlanMatchPattern.join(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.join) PlanMatchPattern.singleGroupingSet(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.singleGroupingSet) AGGREGATION_PARTITIONING_MERGING_STRATEGY(com.facebook.presto.SystemSessionProperties.AGGREGATION_PARTITIONING_MERGING_STRATEGY) ImmutableList(com.google.common.collect.ImmutableList) PREFER_EXACT_PARTITIONING(com.facebook.presto.sql.analyzer.FeaturesConfig.PartitioningPrecisionStrategy.PREFER_EXACT_PARTITIONING) LOCAL(com.facebook.presto.sql.planner.plan.ExchangeNode.Scope.LOCAL) REPARTITION(com.facebook.presto.sql.planner.plan.ExchangeNode.Type.REPARTITION) PlanMatchPattern.equiJoinClause(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.equiJoinClause) BiConsumer(java.util.function.BiConsumer) Plan(com.facebook.presto.sql.planner.Plan) PlanMatchPattern.aggregation(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.aggregation) PlanNodeSearcher.searchFrom(com.facebook.presto.sql.planner.optimizations.PlanNodeSearcher.searchFrom) FunctionCall(com.facebook.presto.sql.tree.FunctionCall) EXCHANGE_MATERIALIZATION_STRATEGY(com.facebook.presto.SystemSessionProperties.EXCHANGE_MATERIALIZATION_STRATEGY) ImmutableMap(com.google.common.collect.ImmutableMap) PlanMatchPattern.semiJoin(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.semiJoin) Session(com.facebook.presto.Session) ELIMINATE_CROSS_JOINS(com.facebook.presto.sql.analyzer.FeaturesConfig.JoinReorderingStrategy.ELIMINATE_CROSS_JOINS) PlanMatchPattern.tableScan(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.tableScan) PlanMatchPattern.anySymbol(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.anySymbol) PlanMatchPattern.exchange(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.exchange) JOIN_DISTRIBUTION_TYPE(com.facebook.presto.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE) USE_STREAMING_EXCHANGE_FOR_MARK_DISTINCT(com.facebook.presto.SystemSessionProperties.USE_STREAMING_EXCHANGE_FOR_MARK_DISTINCT) PARTITIONING_PRECISION_STRATEGY(com.facebook.presto.SystemSessionProperties.PARTITIONING_PRECISION_STRATEGY) TASK_CONCURRENCY(com.facebook.presto.SystemSessionProperties.TASK_CONCURRENCY) PARTITIONED(com.facebook.presto.sql.analyzer.FeaturesConfig.JoinDistributionType.PARTITIONED) REMOTE_STREAMING(com.facebook.presto.sql.planner.plan.ExchangeNode.Scope.REMOTE_STREAMING) JOIN_REORDERING_STRATEGY(com.facebook.presto.SystemSessionProperties.JOIN_REORDERING_STRATEGY) REMOTE_MATERIALIZED(com.facebook.presto.sql.planner.plan.ExchangeNode.Scope.REMOTE_MATERIALIZED) Optional(java.util.Optional) PlanMatchPattern.values(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.values) ExpectedValueProvider(com.facebook.presto.sql.planner.assertions.ExpectedValueProvider) ExchangeNode(com.facebook.presto.sql.planner.plan.ExchangeNode) PlanMatchPattern.node(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.node) INNER(com.facebook.presto.sql.planner.plan.JoinNode.Type.INNER) ExchangeNode(com.facebook.presto.sql.planner.plan.ExchangeNode) Plan(com.facebook.presto.sql.planner.Plan) TestingSession(com.facebook.presto.testing.TestingSession) Session(com.facebook.presto.Session)

Aggregations

BasePlanTest (com.facebook.presto.sql.planner.assertions.BasePlanTest)2 LOCAL (com.facebook.presto.sql.planner.plan.ExchangeNode.Scope.LOCAL)2 REMOTE_STREAMING (com.facebook.presto.sql.planner.plan.ExchangeNode.Scope.REMOTE_STREAMING)2 REPARTITION (com.facebook.presto.sql.planner.plan.ExchangeNode.Type.REPARTITION)2 INNER (com.facebook.presto.sql.planner.plan.JoinNode.Type.INNER)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Optional (java.util.Optional)2 Test (org.testng.annotations.Test)2 Session (com.facebook.presto.Session)1 TEST_SESSION (com.facebook.presto.SessionTestUtils.TEST_SESSION)1 AGGREGATION_PARTITIONING_MERGING_STRATEGY (com.facebook.presto.SystemSessionProperties.AGGREGATION_PARTITIONING_MERGING_STRATEGY)1 EXCHANGE_MATERIALIZATION_STRATEGY (com.facebook.presto.SystemSessionProperties.EXCHANGE_MATERIALIZATION_STRATEGY)1 JOIN_DISTRIBUTION_TYPE (com.facebook.presto.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE)1 JOIN_REORDERING_STRATEGY (com.facebook.presto.SystemSessionProperties.JOIN_REORDERING_STRATEGY)1 PARTITIONING_PRECISION_STRATEGY (com.facebook.presto.SystemSessionProperties.PARTITIONING_PRECISION_STRATEGY)1 TASK_CONCURRENCY (com.facebook.presto.SystemSessionProperties.TASK_CONCURRENCY)1 USE_STREAMING_EXCHANGE_FOR_MARK_DISTINCT (com.facebook.presto.SystemSessionProperties.USE_STREAMING_EXCHANGE_FOR_MARK_DISTINCT)1 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)1 BIGINT (com.facebook.presto.common.type.BigintType.BIGINT)1