Search in sources :

Example 6 with CostComparator

use of com.facebook.presto.cost.CostComparator in project presto by prestodb.

the class TestJoinEnumerator method testDoesNotCreateJoinWhenPartitionedOnCrossJoin.

@Test
public void testDoesNotCreateJoinWhenPartitionedOnCrossJoin() {
    PlanNodeIdAllocator idAllocator = new PlanNodeIdAllocator();
    PlanBuilder p = new PlanBuilder(TEST_SESSION, idAllocator, queryRunner.getMetadata());
    VariableReferenceExpression a1 = p.variable("A1");
    VariableReferenceExpression b1 = p.variable("B1");
    MultiJoinNode multiJoinNode = new MultiJoinNode(new LinkedHashSet<>(ImmutableList.of(p.values(a1), p.values(b1))), TRUE_CONSTANT, ImmutableList.of(a1, b1));
    JoinEnumerator joinEnumerator = new JoinEnumerator(new CostComparator(1, 1, 1), multiJoinNode.getFilter(), createContext(), determinismEvaluator, functionResolution, metadata);
    JoinEnumerationResult actual = joinEnumerator.createJoinAccordingToPartitioning(multiJoinNode.getSources(), multiJoinNode.getOutputVariables(), ImmutableSet.of(0));
    assertFalse(actual.getPlanNode().isPresent());
    assertEquals(actual.getCost(), PlanCostEstimate.infinite());
}
Also used : CostComparator(com.facebook.presto.cost.CostComparator) JoinEnumerator(com.facebook.presto.sql.planner.iterative.rule.ReorderJoins.JoinEnumerator) PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) JoinEnumerationResult(com.facebook.presto.sql.planner.iterative.rule.ReorderJoins.JoinEnumerationResult) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) MultiJoinNode(com.facebook.presto.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode) Test(org.testng.annotations.Test)

Example 7 with CostComparator

use of com.facebook.presto.cost.CostComparator in project presto by prestodb.

the class AbstractTestQueryFramework method getQueryExplainer.

private QueryExplainer getQueryExplainer() {
    Metadata metadata = queryRunner.getMetadata();
    FeaturesConfig featuresConfig = new FeaturesConfig().setOptimizeHashGeneration(true);
    boolean forceSingleNode = queryRunner.getNodeCount() == 1;
    TaskCountEstimator taskCountEstimator = new TaskCountEstimator(queryRunner::getNodeCount);
    CostCalculator costCalculator = new CostCalculatorUsingExchanges(taskCountEstimator);
    List<PlanOptimizer> optimizers = new PlanOptimizers(metadata, sqlParser, forceSingleNode, new MBeanExporter(new TestingMBeanServer()), queryRunner.getSplitManager(), queryRunner.getPlanOptimizerManager(), queryRunner.getPageSourceManager(), queryRunner.getStatsCalculator(), costCalculator, new CostCalculatorWithEstimatedExchanges(costCalculator, taskCountEstimator), new CostComparator(featuresConfig), taskCountEstimator, new PartitioningProviderManager()).getPlanningTimeOptimizers();
    return new QueryExplainer(optimizers, new PlanFragmenter(metadata, queryRunner.getNodePartitioningManager(), new QueryManagerConfig(), sqlParser, new FeaturesConfig()), metadata, queryRunner.getAccessControl(), sqlParser, queryRunner.getStatsCalculator(), costCalculator, ImmutableMap.of(), new PlanChecker(new FeaturesConfig(), false));
}
Also used : TaskCountEstimator(com.facebook.presto.cost.TaskCountEstimator) CostComparator(com.facebook.presto.cost.CostComparator) PlanOptimizer(com.facebook.presto.sql.planner.optimizations.PlanOptimizer) TestingMBeanServer(org.weakref.jmx.testing.TestingMBeanServer) QueryExplainer(com.facebook.presto.sql.analyzer.QueryExplainer) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) MBeanExporter(org.weakref.jmx.MBeanExporter) PartitioningProviderManager(com.facebook.presto.sql.planner.PartitioningProviderManager) Metadata(com.facebook.presto.metadata.Metadata) PlanFragmenter(com.facebook.presto.sql.planner.PlanFragmenter) CostCalculator(com.facebook.presto.cost.CostCalculator) PlanChecker(com.facebook.presto.sql.planner.sanity.PlanChecker) PlanOptimizers(com.facebook.presto.sql.planner.PlanOptimizers) QueryManagerConfig(com.facebook.presto.execution.QueryManagerConfig) CostCalculatorUsingExchanges(com.facebook.presto.cost.CostCalculatorUsingExchanges) CostCalculatorWithEstimatedExchanges(com.facebook.presto.cost.CostCalculatorWithEstimatedExchanges)

Aggregations

CostComparator (com.facebook.presto.cost.CostComparator)7 TaskCountEstimator (com.facebook.presto.cost.TaskCountEstimator)6 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)6 Test (org.testng.annotations.Test)6 JOIN_DISTRIBUTION_TYPE (com.facebook.presto.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE)5 JOIN_MAX_BROADCAST_TABLE_SIZE (com.facebook.presto.SystemSessionProperties.JOIN_MAX_BROADCAST_TABLE_SIZE)5 BIGINT (com.facebook.presto.common.type.BigintType.BIGINT)5 PlanNodeStatsEstimate (com.facebook.presto.cost.PlanNodeStatsEstimate)5 VariableStatsEstimate (com.facebook.presto.cost.VariableStatsEstimate)5 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)5 JoinDistributionType (com.facebook.presto.sql.analyzer.FeaturesConfig.JoinDistributionType)5 PlanMatchPattern.enforceSingleRow (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.enforceSingleRow)5 PlanMatchPattern.equiJoinClause (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.equiJoinClause)5 PlanMatchPattern.join (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.join)5 PlanMatchPattern.values (com.facebook.presto.sql.planner.assertions.PlanMatchPattern.values)5 PlanBuilder.castToRowExpression (com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder.castToRowExpression)5 PlanBuilder.constantExpressions (com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder.constantExpressions)5 RuleAssert (com.facebook.presto.sql.planner.iterative.rule.test.RuleAssert)5 RuleTester (com.facebook.presto.sql.planner.iterative.rule.test.RuleTester)5 JoinNode (com.facebook.presto.sql.planner.plan.JoinNode)5