Search in sources :

Example 21 with SymbolStatsEstimate

use of io.trino.cost.SymbolStatsEstimate in project trino by trinodb.

the class TestDetermineSemiJoinDistributionType method testPartitionWhenRequiredBySession.

@Test
public void testPartitionWhenRequiredBySession() {
    // variable width so that average row size is respected
    Type symbolType = createUnboundedVarcharType();
    int aRows = 10_000;
    int bRows = 100;
    assertDetermineSemiJoinDistributionType().setSystemProperty(JOIN_DISTRIBUTION_TYPE, JoinDistributionType.PARTITIONED.name()).overrideStats("valuesA", PlanNodeStatsEstimate.builder().setOutputRowCount(aRows).addSymbolStatistics(ImmutableMap.of(new Symbol("A1"), new SymbolStatsEstimate(0, 100, 0, 6400, 100))).build()).overrideStats("valuesB", PlanNodeStatsEstimate.builder().setOutputRowCount(bRows).addSymbolStatistics(ImmutableMap.of(new Symbol("B1"), new SymbolStatsEstimate(0, 100, 0, 640000, 100))).build()).on(p -> {
        Symbol a1 = p.symbol("A1", symbolType);
        Symbol b1 = p.symbol("B1", symbolType);
        return p.semiJoin(p.values(new PlanNodeId("valuesA"), aRows, a1), p.values(new PlanNodeId("valuesB"), bRows, b1), a1, b1, p.symbol("output"), Optional.empty(), Optional.empty(), Optional.empty());
    }).matches(semiJoin("A1", "B1", "output", Optional.of(PARTITIONED), values(ImmutableMap.of("A1", 0)), values(ImmutableMap.of("B1", 0))));
}
Also used : PlanMatchPattern.semiJoin(io.trino.sql.planner.assertions.PlanMatchPattern.semiJoin) Type(io.trino.spi.type.Type) VarcharType.createUnboundedVarcharType(io.trino.spi.type.VarcharType.createUnboundedVarcharType) Test(org.testng.annotations.Test) PlanMatchPattern.filter(io.trino.sql.planner.assertions.PlanMatchPattern.filter) PARTITIONED(io.trino.sql.planner.plan.SemiJoinNode.DistributionType.PARTITIONED) RuleAssert(io.trino.sql.planner.iterative.rule.test.RuleAssert) PlanBuilder.expressions(io.trino.sql.planner.iterative.rule.test.PlanBuilder.expressions) ImmutableList(com.google.common.collect.ImmutableList) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) PlanNodeStatsEstimate(io.trino.cost.PlanNodeStatsEstimate) JOIN_MAX_BROADCAST_TABLE_SIZE(io.trino.SystemSessionProperties.JOIN_MAX_BROADCAST_TABLE_SIZE) TaskCountEstimator(io.trino.cost.TaskCountEstimator) Symbol(io.trino.sql.planner.Symbol) AfterClass(org.testng.annotations.AfterClass) SymbolStatsEstimate(io.trino.cost.SymbolStatsEstimate) RuleTester.defaultRuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester.defaultRuleTester) ImmutableMap(com.google.common.collect.ImmutableMap) BeforeClass(org.testng.annotations.BeforeClass) RuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester) PlanMatchPattern.values(io.trino.sql.planner.assertions.PlanMatchPattern.values) REPLICATED(io.trino.sql.planner.plan.SemiJoinNode.DistributionType.REPLICATED) TRUE_LITERAL(io.trino.sql.tree.BooleanLiteral.TRUE_LITERAL) JoinDistributionType(io.trino.sql.planner.OptimizerConfig.JoinDistributionType) CostComparator(io.trino.cost.CostComparator) BIGINT(io.trino.spi.type.BigintType.BIGINT) JOIN_DISTRIBUTION_TYPE(io.trino.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE) Optional(java.util.Optional) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Type(io.trino.spi.type.Type) VarcharType.createUnboundedVarcharType(io.trino.spi.type.VarcharType.createUnboundedVarcharType) JoinDistributionType(io.trino.sql.planner.OptimizerConfig.JoinDistributionType) Symbol(io.trino.sql.planner.Symbol) SymbolStatsEstimate(io.trino.cost.SymbolStatsEstimate) Test(org.testng.annotations.Test)

Aggregations

SymbolStatsEstimate (io.trino.cost.SymbolStatsEstimate)21 Symbol (io.trino.sql.planner.Symbol)21 Test (org.testng.annotations.Test)20 PlanNodeStatsEstimate (io.trino.cost.PlanNodeStatsEstimate)18 VarcharType.createUnboundedVarcharType (io.trino.spi.type.VarcharType.createUnboundedVarcharType)18 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)18 ImmutableList (com.google.common.collect.ImmutableList)16 ImmutableMap (com.google.common.collect.ImmutableMap)16 JoinDistributionType (io.trino.sql.planner.OptimizerConfig.JoinDistributionType)16 Optional (java.util.Optional)16 JOIN_DISTRIBUTION_TYPE (io.trino.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE)15 JOIN_MAX_BROADCAST_TABLE_SIZE (io.trino.SystemSessionProperties.JOIN_MAX_BROADCAST_TABLE_SIZE)15 CostComparator (io.trino.cost.CostComparator)15 PlanMatchPattern.values (io.trino.sql.planner.assertions.PlanMatchPattern.values)15 RuleAssert (io.trino.sql.planner.iterative.rule.test.RuleAssert)15 RuleTester (io.trino.sql.planner.iterative.rule.test.RuleTester)15 RuleTester.defaultRuleTester (io.trino.sql.planner.iterative.rule.test.RuleTester.defaultRuleTester)15 AfterClass (org.testng.annotations.AfterClass)15 BeforeClass (org.testng.annotations.BeforeClass)15 PlanMatchPattern.equiJoinClause (io.trino.sql.planner.assertions.PlanMatchPattern.equiJoinClause)12