Search in sources :

Example 1 with PlanSymbolAllocator

use of io.prestosql.sql.planner.PlanSymbolAllocator in project hetu-core by openlookeng.

the class TestWindowNode method setUp.

@BeforeClass
public void setUp() {
    planSymbolAllocator = new PlanSymbolAllocator();
    columnA = planSymbolAllocator.newSymbol("a", BIGINT);
    columnB = planSymbolAllocator.newSymbol("b", BIGINT);
    columnC = planSymbolAllocator.newSymbol("c", BIGINT);
    sourceNode = new ValuesNode(newId(), ImmutableList.of(columnA, columnB, columnC), ImmutableList.of());
}
Also used : ValuesNode(io.prestosql.spi.plan.ValuesNode) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with PlanSymbolAllocator

use of io.prestosql.sql.planner.PlanSymbolAllocator in project hetu-core by openlookeng.

the class TestExternalFunctionPushDownChecker method setup.

@BeforeClass
public void setup() {
    planSymbolAllocator = new PlanSymbolAllocator();
    columnA = planSymbolAllocator.newSymbol("a", DOUBLE);
    columnB = planSymbolAllocator.newSymbol("b", DOUBLE);
    sumCall = call("sum", SUM, DOUBLE, ImmutableList.of(VariableReferenceSymbolConverter.toVariableReference(columnA, DOUBLE)));
    externalFooCall1 = new CallExpression("jdbc.v1.foo", EXTERNAL_FOO, DOUBLE, ImmutableList.of());
    externalFooCall2 = new CallExpression("jdbc.v1.foo2", EXTERNAL_FOO, DOUBLE, ImmutableList.of());
    metadata = getQueryRunner().getMetadata();
    builder = new PlanBuilder(new PlanNodeIdAllocator(), metadata);
}
Also used : PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator) CallExpression(io.prestosql.spi.relation.CallExpression) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with PlanSymbolAllocator

use of io.prestosql.sql.planner.PlanSymbolAllocator in project hetu-core by openlookeng.

the class TestSimplifyExpressions method assertSimplifies.

private static void assertSimplifies(String expression, String expected) {
    Expression actualExpression = rewriteIdentifiersToSymbolReferences(SQL_PARSER.createExpression(expression));
    Expression expectedExpression = rewriteIdentifiersToSymbolReferences(SQL_PARSER.createExpression(expected));
    Expression rewritten = rewrite(actualExpression, TEST_SESSION, new PlanSymbolAllocator(booleanSymbolTypeMapFor(actualExpression)), METADATA, LITERAL_ENCODER, new TypeAnalyzer(SQL_PARSER, METADATA));
    assertEquals(normalize(rewritten), normalize(expectedExpression));
}
Also used : LogicalBinaryExpression(io.prestosql.sql.tree.LogicalBinaryExpression) ExpressionUtils.binaryExpression(io.prestosql.sql.ExpressionUtils.binaryExpression) Expression(io.prestosql.sql.tree.Expression) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer)

Example 4 with PlanSymbolAllocator

use of io.prestosql.sql.planner.PlanSymbolAllocator in project hetu-core by openlookeng.

the class RuleAssert method applyRule.

private RuleApplication applyRule() {
    PlanSymbolAllocator planSymbolAllocator = new PlanSymbolAllocator(types.allTypes());
    Memo memo = new Memo(idAllocator, plan);
    Lookup lookup = Lookup.from(planNode -> Stream.of(memo.resolve(planNode)));
    PlanNode memoRoot = memo.getNode(memo.getRootGroup());
    return inTransaction(session -> applyRule(rule, memoRoot, ruleContext(statsCalculator, costCalculator, planSymbolAllocator, memo, lookup, session)));
}
Also used : PlanNode(io.prestosql.spi.plan.PlanNode) Lookup(io.prestosql.sql.planner.iterative.Lookup) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator) Memo(io.prestosql.sql.planner.iterative.Memo)

Example 5 with PlanSymbolAllocator

use of io.prestosql.sql.planner.PlanSymbolAllocator in project hetu-core by openlookeng.

the class TestJoinEnumerator method createContext.

private Rule.Context createContext() {
    PlanNodeIdAllocator planNodeIdAllocator = new PlanNodeIdAllocator();
    Map<Symbol, Type> symbols = new HashMap<>();
    symbols.put(new Symbol("A1"), BIGINT);
    symbols.put(new Symbol("B1"), BIGINT);
    PlanSymbolAllocator planSymbolAllocator = new PlanSymbolAllocator(symbols);
    CachingStatsProvider statsProvider = new CachingStatsProvider(queryRunner.getStatsCalculator(), Optional.empty(), noLookup(), queryRunner.getDefaultSession(), planSymbolAllocator.getTypes());
    CachingCostProvider costProvider = new CachingCostProvider(queryRunner.getCostCalculator(), statsProvider, Optional.empty(), queryRunner.getDefaultSession(), planSymbolAllocator.getTypes());
    return new Rule.Context() {

        @Override
        public Lookup getLookup() {
            return noLookup();
        }

        @Override
        public PlanNodeIdAllocator getIdAllocator() {
            return planNodeIdAllocator;
        }

        @Override
        public PlanSymbolAllocator getSymbolAllocator() {
            return planSymbolAllocator;
        }

        @Override
        public Session getSession() {
            return queryRunner.getDefaultSession();
        }

        @Override
        public StatsProvider getStatsProvider() {
            return statsProvider;
        }

        @Override
        public CostProvider getCostProvider() {
            return costProvider;
        }

        @Override
        public void checkTimeoutNotExhausted() {
        }

        @Override
        public WarningCollector getWarningCollector() {
            return WarningCollector.NOOP;
        }
    };
}
Also used : Type(io.prestosql.spi.type.Type) CachingStatsProvider(io.prestosql.cost.CachingStatsProvider) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) HashMap(java.util.HashMap) Symbol(io.prestosql.spi.plan.Symbol) CachingCostProvider(io.prestosql.cost.CachingCostProvider) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator)

Aggregations

PlanSymbolAllocator (io.prestosql.sql.planner.PlanSymbolAllocator)15 Symbol (io.prestosql.spi.plan.Symbol)10 PlanNodeIdAllocator (io.prestosql.spi.plan.PlanNodeIdAllocator)6 ImmutableMap (com.google.common.collect.ImmutableMap)4 Session (io.prestosql.Session)4 TableHandle (io.prestosql.spi.metadata.TableHandle)4 PlanNode (io.prestosql.spi.plan.PlanNode)4 TableScanNode (io.prestosql.spi.plan.TableScanNode)4 RowExpression (io.prestosql.spi.relation.RowExpression)4 Type (io.prestosql.spi.type.Type)4 TypeAnalyzer (io.prestosql.sql.planner.TypeAnalyzer)4 Expression (io.prestosql.sql.tree.Expression)4 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)3 Capture (io.prestosql.matching.Capture)3 Capture.newCapture (io.prestosql.matching.Capture.newCapture)3 Captures (io.prestosql.matching.Captures)3 Pattern (io.prestosql.matching.Pattern)3 Metadata (io.prestosql.metadata.Metadata)3 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)3