Search in sources :

Example 11 with INNER

use of io.prestosql.spi.plan.JoinNode.Type.INNER in project hetu-core by openlookeng.

the class TestValidateAggregationsWithDefaultValues method testWithPartialAggregationBelowJoin.

@Test
public void testWithPartialAggregationBelowJoin() {
    Symbol symbolObj = new Symbol("symbol");
    PlanNode root = builder.aggregation(af -> af.step(FINAL).groupingSets(groupingSets(ImmutableList.of(symbolObj), 2, ImmutableSet.of(0))).source(builder.join(INNER, builder.exchange(e -> e.type(REPARTITION).scope(LOCAL).fixedHashDistributionParitioningScheme(ImmutableList.of(symbolObj), ImmutableList.of(symbolObj)).addInputsSet(symbolObj).addSource(builder.aggregation(ap -> ap.step(PARTIAL).groupingSets(groupingSets(ImmutableList.of(symbolObj), 2, ImmutableSet.of(0))).source(tableScanNode)))), builder.values())));
    validatePlan(root, true);
}
Also used : TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) TypeProvider(io.prestosql.sql.planner.TypeProvider) Test(org.testng.annotations.Test) SqlParser(io.prestosql.sql.parser.SqlParser) TableHandle(io.prestosql.spi.metadata.TableHandle) PARTIAL(io.prestosql.spi.plan.AggregationNode.Step.PARTIAL) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer) REMOTE(io.prestosql.sql.planner.plan.ExchangeNode.Scope.REMOTE) WarningCollector(io.prestosql.execution.warnings.WarningCollector) ImmutableList(com.google.common.collect.ImmutableList) REPARTITION(io.prestosql.sql.planner.plan.ExchangeNode.Type.REPARTITION) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) Symbol(io.prestosql.spi.plan.Symbol) BasePlanTest(io.prestosql.sql.planner.assertions.BasePlanTest) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) BeforeClass(org.testng.annotations.BeforeClass) CatalogName(io.prestosql.spi.connector.CatalogName) TableScanNode(io.prestosql.spi.plan.TableScanNode) PlanNode(io.prestosql.spi.plan.PlanNode) FINAL(io.prestosql.spi.plan.AggregationNode.Step.FINAL) Metadata(io.prestosql.metadata.Metadata) AggregationNode.groupingSets(io.prestosql.spi.plan.AggregationNode.groupingSets) TestingTransactionHandle(io.prestosql.testing.TestingTransactionHandle) LOCAL(io.prestosql.sql.planner.plan.ExchangeNode.Scope.LOCAL) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) INNER(io.prestosql.spi.plan.JoinNode.Type.INNER) Optional(java.util.Optional) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) PlanNode(io.prestosql.spi.plan.PlanNode) Symbol(io.prestosql.spi.plan.Symbol) Test(org.testng.annotations.Test) BasePlanTest(io.prestosql.sql.planner.assertions.BasePlanTest)

Example 12 with INNER

use of io.prestosql.spi.plan.JoinNode.Type.INNER in project hetu-core by openlookeng.

the class TestReorderJoins method testReplicatedScalarJoinEvenWhereSessionRequiresRepartitioned.

@Test
public void testReplicatedScalarJoinEvenWhereSessionRequiresRepartitioned() {
    PlanMatchPattern expectedPlan = join(INNER, ImmutableList.of(equiJoinClause("A1", "B1")), Optional.empty(), Optional.of(REPLICATED), values(ImmutableMap.of("A1", 0)), values(ImmutableMap.of("B1", 0)));
    PlanNodeStatsEstimate valuesA = PlanNodeStatsEstimate.builder().setOutputRowCount(10000).addSymbolStatistics(ImmutableMap.of(new Symbol("A1"), new SymbolStatsEstimate(0, 100, 0, 640000, 100))).build();
    PlanNodeStatsEstimate valuesB = PlanNodeStatsEstimate.builder().setOutputRowCount(10000).addSymbolStatistics(ImmutableMap.of(new Symbol("B1"), new SymbolStatsEstimate(0, 100, 0, 640000, 100))).build();
    assertReorderJoins().setSystemProperty(JOIN_DISTRIBUTION_TYPE, JoinDistributionType.PARTITIONED.name()).on(p -> p.join(INNER, // matches isAtMostScalar
    p.values(new PlanNodeId("valuesA"), p.symbol("A1")), p.values(new PlanNodeId("valuesB"), ImmutableList.of(p.symbol("B1")), TWO_ROWS), ImmutableList.of(new EquiJoinClause(p.symbol("A1"), p.symbol("B1"))), ImmutableList.of(p.symbol("A1"), p.symbol("B1")), Optional.empty())).overrideStats("valuesA", valuesA).overrideStats("valuesB", valuesB).matches(expectedPlan);
    assertReorderJoins().setSystemProperty(JOIN_DISTRIBUTION_TYPE, JoinDistributionType.PARTITIONED.name()).on(p -> p.join(INNER, p.values(new PlanNodeId("valuesB"), ImmutableList.of(p.symbol("B1")), TWO_ROWS), // matches isAtMostScalar
    p.values(new PlanNodeId("valuesA"), p.symbol("A1")), ImmutableList.of(new EquiJoinClause(p.symbol("A1"), p.symbol("B1"))), ImmutableList.of(p.symbol("A1"), p.symbol("B1")), Optional.empty())).overrideStats("valuesA", valuesA).overrideStats("valuesB", valuesB).matches(expectedPlan);
}
Also used : SymbolStatsEstimate(io.prestosql.cost.SymbolStatsEstimate) REPLICATED(io.prestosql.spi.plan.JoinNode.DistributionType.REPLICATED) EquiJoinClause(io.prestosql.spi.plan.JoinNode.EquiJoinClause) PlanMatchPattern.equiJoinClause(io.prestosql.sql.planner.assertions.PlanMatchPattern.equiJoinClause) QualifiedName(io.prestosql.sql.tree.QualifiedName) BROADCAST(io.prestosql.sql.analyzer.FeaturesConfig.JoinDistributionType.BROADCAST) JoinDistributionType(io.prestosql.sql.analyzer.FeaturesConfig.JoinDistributionType) Test(org.testng.annotations.Test) PARTITIONED(io.prestosql.spi.plan.JoinNode.DistributionType.PARTITIONED) LESS_THAN(io.prestosql.spi.function.OperatorType.LESS_THAN) JOIN_REORDERING_STRATEGY(io.prestosql.SystemSessionProperties.JOIN_REORDERING_STRATEGY) PlanMatchPattern.values(io.prestosql.sql.planner.assertions.PlanMatchPattern.values) ImmutableList(com.google.common.collect.ImmutableList) Expressions.call(io.prestosql.sql.relational.Expressions.call) OperatorType(io.prestosql.spi.function.OperatorType) JoinReorderingStrategy(io.prestosql.sql.analyzer.FeaturesConfig.JoinReorderingStrategy) BOOLEAN(io.prestosql.spi.type.BooleanType.BOOLEAN) Type(io.prestosql.spi.type.Type) RuleAssert(io.prestosql.sql.planner.iterative.rule.test.RuleAssert) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) Symbol(io.prestosql.spi.plan.Symbol) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) AfterClass(org.testng.annotations.AfterClass) EQUAL(io.prestosql.spi.function.OperatorType.EQUAL) PlanMatchPattern.join(io.prestosql.sql.planner.assertions.PlanMatchPattern.join) PlanNodeStatsEstimate(io.prestosql.cost.PlanNodeStatsEstimate) ImmutableMap(com.google.common.collect.ImmutableMap) PlanMatchPattern(io.prestosql.sql.planner.assertions.PlanMatchPattern) BeforeClass(org.testng.annotations.BeforeClass) FunctionAndTypeManager.qualifyObjectName(io.prestosql.metadata.FunctionAndTypeManager.qualifyObjectName) CostComparator(io.prestosql.cost.CostComparator) AUTOMATIC(io.prestosql.sql.analyzer.FeaturesConfig.JoinDistributionType.AUTOMATIC) Expressions.variable(io.prestosql.sql.relational.Expressions.variable) List(java.util.List) Closeables.closeAllRuntimeException(io.airlift.testing.Closeables.closeAllRuntimeException) FunctionResolution(io.prestosql.sql.relational.FunctionResolution) VarcharType.createUnboundedVarcharType(io.prestosql.spi.type.VarcharType.createUnboundedVarcharType) RowExpression(io.prestosql.spi.relation.RowExpression) INNER(io.prestosql.spi.plan.JoinNode.Type.INNER) Optional(java.util.Optional) JOIN_MAX_BROADCAST_TABLE_SIZE(io.prestosql.SystemSessionProperties.JOIN_MAX_BROADCAST_TABLE_SIZE) RuleTester(io.prestosql.sql.planner.iterative.rule.test.RuleTester) JOIN_DISTRIBUTION_TYPE(io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) PlanNodeStatsEstimate(io.prestosql.cost.PlanNodeStatsEstimate) Symbol(io.prestosql.spi.plan.Symbol) EquiJoinClause(io.prestosql.spi.plan.JoinNode.EquiJoinClause) PlanMatchPattern(io.prestosql.sql.planner.assertions.PlanMatchPattern) SymbolStatsEstimate(io.prestosql.cost.SymbolStatsEstimate) Test(org.testng.annotations.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)12 ImmutableMap (com.google.common.collect.ImmutableMap)12 INNER (io.prestosql.spi.plan.JoinNode.Type.INNER)12 Symbol (io.prestosql.spi.plan.Symbol)12 Optional (java.util.Optional)12 BIGINT (io.prestosql.spi.type.BigintType.BIGINT)10 Test (org.testng.annotations.Test)10 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)8 JOIN_DISTRIBUTION_TYPE (io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE)7 JOIN_MAX_BROADCAST_TABLE_SIZE (io.prestosql.SystemSessionProperties.JOIN_MAX_BROADCAST_TABLE_SIZE)7 CostComparator (io.prestosql.cost.CostComparator)7 PlanNodeStatsEstimate (io.prestosql.cost.PlanNodeStatsEstimate)7 SymbolStatsEstimate (io.prestosql.cost.SymbolStatsEstimate)7 PARTITIONED (io.prestosql.spi.plan.JoinNode.DistributionType.PARTITIONED)7 REPLICATED (io.prestosql.spi.plan.JoinNode.DistributionType.REPLICATED)7 VarcharType.createUnboundedVarcharType (io.prestosql.spi.type.VarcharType.createUnboundedVarcharType)7 JoinDistributionType (io.prestosql.sql.analyzer.FeaturesConfig.JoinDistributionType)7 PlanMatchPattern.equiJoinClause (io.prestosql.sql.planner.assertions.PlanMatchPattern.equiJoinClause)7 PlanMatchPattern.join (io.prestosql.sql.planner.assertions.PlanMatchPattern.join)7 PlanMatchPattern.values (io.prestosql.sql.planner.assertions.PlanMatchPattern.values)7