Search in sources :

Example 1 with PlanNode

use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.

the class TestPruneCrossJoinColumns method buildProjectedCrossJoin.

private static PlanNode buildProjectedCrossJoin(PlanBuilder p, Predicate<Symbol> projectionFilter) {
    Symbol leftValue = p.symbol("leftValue");
    Symbol rightValue = p.symbol("rightValue");
    List<Symbol> outputs = ImmutableList.of(leftValue, rightValue);
    return p.project(Assignments.copyOf(outputs.stream().filter(projectionFilter).collect(Collectors.toMap(v -> v, v -> p.variable(v.getName())))), p.join(JoinNode.Type.INNER, p.values(leftValue), p.values(rightValue), ImmutableList.of(), outputs, Optional.empty(), Optional.empty(), Optional.empty()));
}
Also used : Symbol(io.prestosql.spi.plan.Symbol) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) PlanMatchPattern.join(io.prestosql.sql.planner.assertions.PlanMatchPattern.join) ImmutableMap(com.google.common.collect.ImmutableMap) Assignments(io.prestosql.spi.plan.Assignments) PlanMatchPattern.strictProject(io.prestosql.sql.planner.assertions.PlanMatchPattern.strictProject) Predicate(java.util.function.Predicate) PlanMatchPattern(io.prestosql.sql.planner.assertions.PlanMatchPattern) Test(org.testng.annotations.Test) PlanNode(io.prestosql.spi.plan.PlanNode) Collectors(java.util.stream.Collectors) List(java.util.List) PlanMatchPattern.values(io.prestosql.sql.planner.assertions.PlanMatchPattern.values) ImmutableList(com.google.common.collect.ImmutableList) Predicates(com.google.common.base.Predicates) Optional(java.util.Optional) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) JoinNode(io.prestosql.spi.plan.JoinNode) Symbol(io.prestosql.spi.plan.Symbol)

Example 2 with PlanNode

use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.

the class TestPruneIndexSourceColumns method buildProjectedIndexSource.

private static PlanNode buildProjectedIndexSource(PlanBuilder p, Predicate<Symbol> projectionFilter) {
    Symbol orderkey = p.symbol("orderkey", INTEGER);
    Symbol custkey = p.symbol("custkey", INTEGER);
    Symbol totalprice = p.symbol("totalprice", DOUBLE);
    ColumnHandle orderkeyHandle = new TpchColumnHandle(orderkey.getName(), INTEGER);
    ColumnHandle custkeyHandle = new TpchColumnHandle(custkey.getName(), INTEGER);
    ColumnHandle totalpriceHandle = new TpchColumnHandle(totalprice.getName(), DOUBLE);
    return p.project(Assignments.copyOf(ImmutableList.of(orderkey, custkey, totalprice).stream().filter(projectionFilter).collect(Collectors.toMap(v -> v, v -> p.variable(v.getName())))), p.indexSource(new TableHandle(new CatalogName("local"), new TpchTableHandle("orders", TINY_SCALE_FACTOR), TpchTransactionHandle.INSTANCE, Optional.empty()), ImmutableSet.of(orderkey, custkey), ImmutableList.of(orderkey, custkey, totalprice), ImmutableMap.of(orderkey, orderkeyHandle, custkey, custkeyHandle, totalprice, totalpriceHandle), TupleDomain.fromFixedValues(ImmutableMap.of(totalpriceHandle, asNull(DOUBLE)))));
}
Also used : BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) Test(org.testng.annotations.Test) INTEGER(io.prestosql.spi.type.IntegerType.INTEGER) TableHandle(io.prestosql.spi.metadata.TableHandle) ImmutableList(com.google.common.collect.ImmutableList) Predicates(com.google.common.base.Predicates) DOUBLE(io.prestosql.spi.type.DoubleType.DOUBLE) TpchTransactionHandle(io.prestosql.plugin.tpch.TpchTransactionHandle) PlanMatchPattern.expression(io.prestosql.sql.planner.assertions.PlanMatchPattern.expression) Symbol(io.prestosql.spi.plan.Symbol) TINY_SCALE_FACTOR(io.prestosql.plugin.tpch.TpchMetadata.TINY_SCALE_FACTOR) PlanMatchPattern.constrainedIndexSource(io.prestosql.sql.planner.assertions.PlanMatchPattern.constrainedIndexSource) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Assignments(io.prestosql.spi.plan.Assignments) PlanMatchPattern.strictProject(io.prestosql.sql.planner.assertions.PlanMatchPattern.strictProject) Predicate(java.util.function.Predicate) TupleDomain(io.prestosql.spi.predicate.TupleDomain) CatalogName(io.prestosql.spi.connector.CatalogName) PlanNode(io.prestosql.spi.plan.PlanNode) Collectors(java.util.stream.Collectors) NullableValue.asNull(io.prestosql.spi.predicate.NullableValue.asNull) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Domain(io.prestosql.spi.predicate.Domain) Optional(java.util.Optional) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) Symbol(io.prestosql.spi.plan.Symbol) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TableHandle(io.prestosql.spi.metadata.TableHandle) CatalogName(io.prestosql.spi.connector.CatalogName) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle)

Example 3 with PlanNode

use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.

the class TestExternalFunctionPushDownChecker method testWindowNode.

@Test
public void testWindowNode() {
    WindowNode.Frame frame = new WindowNode.Frame(Types.WindowFrameType.RANGE, UNBOUNDED_PRECEDING, Optional.empty(), CURRENT_ROW, Optional.empty(), Optional.empty(), Optional.empty());
    PlanNode root = builder.window(new WindowNode.Specification(ImmutableList.of(columnA), Optional.empty()), ImmutableMap.of(columnB, new WindowNode.Function(sumCall, ImmutableList.of(), frame)), builder.values(columnA));
    validatePlan(root);
}
Also used : WindowNode(io.prestosql.spi.plan.WindowNode) PlanNode(io.prestosql.spi.plan.PlanNode) Test(org.testng.annotations.Test) BasePlanTest(io.prestosql.sql.planner.assertions.BasePlanTest)

Example 4 with PlanNode

use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.

the class TestExternalFunctionPushDownChecker method testAggregationNodeWithExternalCall.

@Test(expectedExceptions = ExternalFunctionPushDownChecker.IllegalExternalFunctionUsageException.class, expectedExceptionsMessageRegExp = "The external function jdbc.v1.foo does not support to push down to data source for this query.")
public void testAggregationNodeWithExternalCall() {
    PlanNode root = builder.aggregation(a -> a.globalGrouping().addAggregation(columnA, externalFooCall1).source(builder.values(columnB)));
    validatePlan(root);
}
Also used : PlanNode(io.prestosql.spi.plan.PlanNode) Test(org.testng.annotations.Test) BasePlanTest(io.prestosql.sql.planner.assertions.BasePlanTest)

Example 5 with PlanNode

use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.

the class TestExternalFunctionPushDownChecker method testTableDeleteNode.

@Test
public void testTableDeleteNode() {
    PlanNode node = new TableDeleteNode(idAllocator.getNextId(), builder.values(), Optional.of(sumCall), tableHandle, ImmutableMap.of(), columnA);
    validatePlan(node);
}
Also used : TableDeleteNode(io.prestosql.sql.planner.plan.TableDeleteNode) PlanNode(io.prestosql.spi.plan.PlanNode) Test(org.testng.annotations.Test) BasePlanTest(io.prestosql.sql.planner.assertions.BasePlanTest)

Aggregations

PlanNode (io.prestosql.spi.plan.PlanNode)236 Symbol (io.prestosql.spi.plan.Symbol)95 Test (org.testng.annotations.Test)95 ImmutableList (com.google.common.collect.ImmutableList)49 RowExpression (io.prestosql.spi.relation.RowExpression)48 Expression (io.prestosql.sql.tree.Expression)46 ProjectNode (io.prestosql.spi.plan.ProjectNode)45 JoinNode (io.prestosql.spi.plan.JoinNode)42 Optional (java.util.Optional)42 OriginalExpressionUtils.castToRowExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression)41 TableScanNode (io.prestosql.spi.plan.TableScanNode)40 CallExpression (io.prestosql.spi.relation.CallExpression)38 List (java.util.List)38 ImmutableMap (com.google.common.collect.ImmutableMap)37 FilterNode (io.prestosql.spi.plan.FilterNode)37 Map (java.util.Map)35 BasePlanTest (io.prestosql.sql.planner.assertions.BasePlanTest)34 AggregationNode (io.prestosql.spi.plan.AggregationNode)33 Assignments (io.prestosql.spi.plan.Assignments)32 ComparisonExpression (io.prestosql.sql.tree.ComparisonExpression)32