Search in sources :

Example 6 with SqlParser

use of com.facebook.presto.sql.parser.SqlParser in project presto by prestodb.

the class TestMergeWindows method assertUnitPlan.

private void assertUnitPlan(@Language("SQL") String sql, PlanMatchPattern pattern) {
    List<PlanOptimizer> optimizers = ImmutableList.of(new UnaliasSymbolReferences(getMetadata().getFunctionAndTypeManager()), new IterativeOptimizer(new RuleStatsRecorder(), getQueryRunner().getStatsCalculator(), getQueryRunner().getCostCalculator(), new TranslateExpressions(getQueryRunner().getMetadata(), new SqlParser()).rules()), new IterativeOptimizer(new RuleStatsRecorder(), getQueryRunner().getStatsCalculator(), getQueryRunner().getEstimatedExchangesCostCalculator(), ImmutableSet.<Rule<?>>builder().add(new RemoveRedundantIdentityProjections()).addAll(GatherAndMergeWindows.rules()).build()), new PruneUnreferencedOutputs());
    assertPlan(sql, pattern, optimizers);
}
Also used : RuleStatsRecorder(com.facebook.presto.sql.planner.RuleStatsRecorder) RemoveRedundantIdentityProjections(com.facebook.presto.sql.planner.iterative.rule.RemoveRedundantIdentityProjections) IterativeOptimizer(com.facebook.presto.sql.planner.iterative.IterativeOptimizer) SqlParser(com.facebook.presto.sql.parser.SqlParser) TranslateExpressions(com.facebook.presto.sql.planner.iterative.rule.TranslateExpressions)

Example 7 with SqlParser

use of com.facebook.presto.sql.parser.SqlParser in project presto by prestodb.

the class TestDynamicFiltersChecker method validatePlan.

private void validatePlan(PlanNode root) {
    getQueryRunner().inTransaction(session -> {
        // metadata.getCatalogHandle() registers the catalog for the transaction
        session.getCatalog().ifPresent(catalog -> metadata.getCatalogHandle(session, catalog));
        new DynamicFiltersChecker().validate(root, session, metadata, new SqlParser(), TypeProvider.empty(), WarningCollector.NOOP);
        return null;
    });
}
Also used : SqlParser(com.facebook.presto.sql.parser.SqlParser)

Example 8 with SqlParser

use of com.facebook.presto.sql.parser.SqlParser in project presto by prestodb.

the class AbstractTestQueryFramework method init.

@BeforeClass
public void init() throws Exception {
    queryRunner = createQueryRunner();
    expectedQueryRunner = createExpectedQueryRunner();
    sqlParser = new SqlParser();
}
Also used : SqlParser(com.facebook.presto.sql.parser.SqlParser) BeforeClass(org.testng.annotations.BeforeClass)

Example 9 with SqlParser

use of com.facebook.presto.sql.parser.SqlParser in project presto by prestodb.

the class RuntimeReorderJoinSides method derivePropertiesRecursively.

private StreamProperties derivePropertiesRecursively(PlanNode node, Metadata metadata, SqlParser parser, Context context) {
    PlanNode actual = context.getLookup().resolve(node);
    List<StreamProperties> inputProperties = actual.getSources().stream().map(source -> derivePropertiesRecursively(source, metadata, parser, context)).collect(toImmutableList());
    return StreamPropertyDerivations.deriveProperties(actual, inputProperties, metadata, context.getSession(), context.getVariableAllocator().getTypes(), parser);
}
Also used : ExchangeNode.systemPartitionedExchange(com.facebook.presto.sql.planner.plan.ExchangeNode.systemPartitionedExchange) Logger(com.facebook.airlift.log.Logger) StreamPropertyDerivations(com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations) Captures(com.facebook.presto.matching.Captures) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) StreamPreferredProperties.exactlyPartitionedOn(com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties.exactlyPartitionedOn) Patterns.join(com.facebook.presto.sql.planner.plan.Patterns.join) Pattern(com.facebook.presto.matching.Pattern) StreamPreferredProperties.fixedParallelism(com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties.fixedParallelism) LOCAL(com.facebook.presto.sql.planner.plan.ExchangeNode.Scope.LOCAL) Objects.requireNonNull(java.util.Objects.requireNonNull) SystemSessionProperties.isJoinSpillingEnabled(com.facebook.presto.SystemSessionProperties.isJoinSpillingEnabled) StreamPreferredProperties.singleStream(com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties.singleStream) SystemSessionProperties.getTaskConcurrency(com.facebook.presto.SystemSessionProperties.getTaskConcurrency) PlanNodeSearcher.searchFrom(com.facebook.presto.sql.planner.optimizations.PlanNodeSearcher.searchFrom) ExchangeNode.gatheringExchange(com.facebook.presto.sql.planner.plan.ExchangeNode.gatheringExchange) JoinNode(com.facebook.presto.sql.planner.plan.JoinNode) Rule(com.facebook.presto.sql.planner.iterative.Rule) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) StatsProvider(com.facebook.presto.cost.StatsProvider) String.format(java.lang.String.format) SqlParser(com.facebook.presto.sql.parser.SqlParser) StreamPreferredProperties.defaultParallelism(com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties.defaultParallelism) RIGHT(com.facebook.presto.sql.planner.plan.JoinNode.Type.RIGHT) SystemSessionProperties.isSpillEnabled(com.facebook.presto.SystemSessionProperties.isSpillEnabled) PlanNode(com.facebook.presto.spi.plan.PlanNode) List(java.util.List) REPLICATED(com.facebook.presto.sql.planner.plan.JoinNode.DistributionType.REPLICATED) LEFT(com.facebook.presto.sql.planner.plan.JoinNode.Type.LEFT) TableScanNode(com.facebook.presto.spi.plan.TableScanNode) StreamProperties(com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations.StreamProperties) StreamPreferredProperties(com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties) Optional(java.util.Optional) PARTITIONED(com.facebook.presto.sql.planner.plan.JoinNode.DistributionType.PARTITIONED) Metadata(com.facebook.presto.metadata.Metadata) ExchangeNode(com.facebook.presto.sql.planner.plan.ExchangeNode) PlanNode(com.facebook.presto.spi.plan.PlanNode) StreamProperties(com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations.StreamProperties)

Example 10 with SqlParser

use of com.facebook.presto.sql.parser.SqlParser in project presto by prestodb.

the class SimplifyExpressions method createRewrite.

private static ExpressionRewriter createRewrite(Metadata metadata, SqlParser sqlParser) {
    requireNonNull(metadata, "metadata is null");
    requireNonNull(sqlParser, "sqlParser is null");
    LiteralEncoder literalEncoder = new LiteralEncoder(metadata.getBlockEncodingSerde());
    return (expression, context) -> rewrite(expression, context.getSession(), context.getVariableAllocator(), metadata, literalEncoder, sqlParser);
}
Also used : WarningCollector(com.facebook.presto.spi.WarningCollector) SymbolReference(com.facebook.presto.sql.tree.SymbolReference) NoOpVariableResolver(com.facebook.presto.sql.planner.NoOpVariableResolver) ImmutableSet(com.google.common.collect.ImmutableSet) Collections.emptyList(java.util.Collections.emptyList) Session(com.facebook.presto.Session) Rule(com.facebook.presto.sql.planner.iterative.Rule) Set(java.util.Set) ExtractCommonPredicatesExpressionRewriter.extractCommonPredicates(com.facebook.presto.sql.planner.iterative.rule.ExtractCommonPredicatesExpressionRewriter.extractCommonPredicates) SqlParser(com.facebook.presto.sql.parser.SqlParser) NodeRef(com.facebook.presto.sql.tree.NodeRef) LiteralEncoder(com.facebook.presto.sql.planner.LiteralEncoder) Expression(com.facebook.presto.sql.tree.Expression) PushDownNegationsExpressionRewriter.pushDownNegations(com.facebook.presto.sql.planner.iterative.rule.PushDownNegationsExpressionRewriter.pushDownNegations) PlanVariableAllocator(com.facebook.presto.sql.planner.PlanVariableAllocator) ExpressionAnalyzer.getExpressionTypes(com.facebook.presto.sql.analyzer.ExpressionAnalyzer.getExpressionTypes) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) ExpressionInterpreter(com.facebook.presto.sql.planner.ExpressionInterpreter) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Type(com.facebook.presto.common.type.Type) Metadata(com.facebook.presto.metadata.Metadata) LiteralEncoder(com.facebook.presto.sql.planner.LiteralEncoder)

Aggregations

SqlParser (com.facebook.presto.sql.parser.SqlParser)38 Expression (com.facebook.presto.sql.tree.Expression)11 Test (org.testng.annotations.Test)11 Metadata (com.facebook.presto.metadata.Metadata)10 Optional (java.util.Optional)10 WarningCollector (com.facebook.presto.spi.WarningCollector)8 RowExpression (com.facebook.presto.spi.relation.RowExpression)8 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)8 TransactionManager (com.facebook.presto.transaction.TransactionManager)8 Session (com.facebook.presto.Session)7 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)7 List (java.util.List)7 Type (com.facebook.presto.common.type.Type)6 ImmutableList (com.google.common.collect.ImmutableList)6 AllowAllAccessControl (com.facebook.presto.security.AllowAllAccessControl)5 PlanVariableAllocator (com.facebook.presto.sql.planner.PlanVariableAllocator)5 Objects.requireNonNull (java.util.Objects.requireNonNull)5 TaskTestUtils.createQueryStateMachine (com.facebook.presto.execution.TaskTestUtils.createQueryStateMachine)4 PlanNode (com.facebook.presto.spi.plan.PlanNode)4 FeaturesConfig (com.facebook.presto.sql.analyzer.FeaturesConfig)4