Search in sources :

Example 31 with DynamicFilterId

use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.

the class TestRemoveUnsupportedDynamicFilters method testRemoveUnsupportedCast.

@Test
public void testRemoveUnsupportedCast() {
    // Use lineitem with DOUBLE orderkey to simulate the case of implicit casts
    // Dynamic filter is removed because there isn't an injective mapping from bigint -> double
    Symbol lineitemDoubleOrderKeySymbol = builder.symbol("LINEITEM_DOUBLE_OK", DOUBLE);
    PlanNode root = builder.output(ImmutableList.of(), ImmutableList.of(), builder.join(INNER, builder.filter(createDynamicFilterExpression(TEST_SESSION, metadata, new DynamicFilterId("DF"), BIGINT, expression("CAST(LINEITEM_DOUBLE_OK AS BIGINT)")), builder.tableScan(lineitemTableHandle, ImmutableList.of(lineitemDoubleOrderKeySymbol), ImmutableMap.of(lineitemDoubleOrderKeySymbol, new TpchColumnHandle("orderkey", DOUBLE)))), ordersTableScanNode, ImmutableList.of(new JoinNode.EquiJoinClause(lineitemDoubleOrderKeySymbol, ordersOrderKeySymbol)), ImmutableList.of(lineitemDoubleOrderKeySymbol), ImmutableList.of(ordersOrderKeySymbol), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(new DynamicFilterId("DF"), ordersOrderKeySymbol)));
    assertPlan(removeUnsupportedDynamicFilters(root), output(join(INNER, ImmutableList.of(equiJoinClause("LINEITEM_DOUBLE_OK", "ORDERS_OK")), ImmutableMap.of(), tableScan("lineitem", ImmutableMap.of("LINEITEM_DOUBLE_OK", "orderkey")), tableScan("orders", ImmutableMap.of("ORDERS_OK", "orderkey")))));
}
Also used : PlanNode(io.trino.sql.planner.plan.PlanNode) TpchColumnHandle(io.trino.plugin.tpch.TpchColumnHandle) Symbol(io.trino.sql.planner.Symbol) SpatialJoinNode(io.trino.sql.planner.plan.SpatialJoinNode) JoinNode(io.trino.sql.planner.plan.JoinNode) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) Test(org.testng.annotations.Test) BasePlanTest(io.trino.sql.planner.assertions.BasePlanTest)

Example 32 with DynamicFilterId

use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.

the class TestRemoveUnsupportedDynamicFilters method testUnconsumedDynamicFilterInSemiJoin.

@Test
public void testUnconsumedDynamicFilterInSemiJoin() {
    PlanNode root = builder.semiJoin(builder.filter(expression("ORDERS_OK > 0"), ordersTableScanNode), lineitemTableScanNode, ordersOrderKeySymbol, lineitemOrderKeySymbol, new Symbol("SEMIJOIN_OUTPUT"), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(new DynamicFilterId("DF")));
    assertPlan(removeUnsupportedDynamicFilters(root), semiJoin("ORDERS_OK", "LINEITEM_OK", "SEMIJOIN_OUTPUT", false, filter(expression("ORDERS_OK > 0"), tableScan("orders", ImmutableMap.of("ORDERS_OK", "orderkey"))), tableScan("lineitem", ImmutableMap.of("LINEITEM_OK", "orderkey"))));
}
Also used : PlanNode(io.trino.sql.planner.plan.PlanNode) Symbol(io.trino.sql.planner.Symbol) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) Test(org.testng.annotations.Test) BasePlanTest(io.trino.sql.planner.assertions.BasePlanTest)

Example 33 with DynamicFilterId

use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.

the class TestDynamicFiltersChecker method testUnconsumedDynamicFilterInSemiJoin.

@Test
public void testUnconsumedDynamicFilterInSemiJoin() {
    PlanNode root = builder.semiJoin(builder.filter(expression("ORDERS_OK > 0"), ordersTableScanNode), lineitemTableScanNode, ordersOrderKeySymbol, lineitemOrderKeySymbol, new Symbol("SEMIJOIN_OUTPUT"), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(new DynamicFilterId("DF")));
    assertThatThrownBy(() -> validatePlan(root)).isInstanceOf(VerifyException.class).hasMessage("The dynamic filter DF present in semi-join was not consumed by it's source side.");
}
Also used : PlanNode(io.trino.sql.planner.plan.PlanNode) VerifyException(com.google.common.base.VerifyException) Symbol(io.trino.sql.planner.Symbol) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) Test(org.testng.annotations.Test) BasePlanTest(io.trino.sql.planner.assertions.BasePlanTest)

Example 34 with DynamicFilterId

use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.

the class TestDynamicFiltersChecker method testUnconsumedDynamicFilterInJoin.

@Test
public void testUnconsumedDynamicFilterInJoin() {
    PlanNode root = builder.join(INNER, builder.filter(expression("ORDERS_OK > 0"), ordersTableScanNode), lineitemTableScanNode, ImmutableList.of(new JoinNode.EquiJoinClause(ordersOrderKeySymbol, lineitemOrderKeySymbol)), ImmutableList.of(ordersOrderKeySymbol), ImmutableList.of(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(new DynamicFilterId("DF"), lineitemOrderKeySymbol));
    assertThatThrownBy(() -> validatePlan(root)).isInstanceOf(VerifyException.class).hasMessageMatching("Dynamic filters \\[DF\\] present in join were not fully consumed by it's probe side.");
}
Also used : PlanNode(io.trino.sql.planner.plan.PlanNode) VerifyException(com.google.common.base.VerifyException) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) Test(org.testng.annotations.Test) BasePlanTest(io.trino.sql.planner.assertions.BasePlanTest)

Example 35 with DynamicFilterId

use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.

the class TestDynamicFiltersChecker method testDynamicFilterConsumedOnFilteringSourceSideInSemiJoin.

@Test
public void testDynamicFilterConsumedOnFilteringSourceSideInSemiJoin() {
    PlanNode root = builder.semiJoin(builder.filter(combineConjuncts(metadata, expression("ORDERS_OK > 0"), createDynamicFilterExpression(TEST_SESSION, metadata, new DynamicFilterId("DF"), BIGINT, lineitemOrderKeySymbol.toSymbolReference())), ordersTableScanNode), builder.filter(combineConjuncts(metadata, expression("LINEITEM_OK > 0"), createDynamicFilterExpression(TEST_SESSION, metadata, new DynamicFilterId("DF"), BIGINT, lineitemOrderKeySymbol.toSymbolReference())), lineitemTableScanNode), ordersOrderKeySymbol, lineitemOrderKeySymbol, new Symbol("SEMIJOIN_OUTPUT"), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(new DynamicFilterId("DF")));
    assertThatThrownBy(() -> validatePlan(root)).isInstanceOf(VerifyException.class).hasMessage("The dynamic filter DF present in semi-join was consumed by it's filtering source side.");
}
Also used : PlanNode(io.trino.sql.planner.plan.PlanNode) VerifyException(com.google.common.base.VerifyException) Symbol(io.trino.sql.planner.Symbol) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) Test(org.testng.annotations.Test) BasePlanTest(io.trino.sql.planner.assertions.BasePlanTest)

Aggregations

DynamicFilterId (io.trino.sql.planner.plan.DynamicFilterId)85 Test (org.testng.annotations.Test)73 PlanNode (io.trino.sql.planner.plan.PlanNode)32 BasePlanTest (io.trino.sql.planner.assertions.BasePlanTest)31 Symbol (io.trino.sql.planner.Symbol)29 TupleDomain (io.trino.spi.predicate.TupleDomain)26 DynamicFilter (io.trino.spi.connector.DynamicFilter)24 ColumnHandle (io.trino.spi.connector.ColumnHandle)21 TestingColumnHandle (io.trino.spi.connector.TestingColumnHandle)20 JoinNode (io.trino.sql.planner.plan.JoinNode)19 Domain (io.trino.spi.predicate.Domain)18 QueryId (io.trino.spi.QueryId)17 StageId (io.trino.execution.StageId)16 TaskId (io.trino.execution.TaskId)15 Page (io.trino.spi.Page)15 Map (java.util.Map)15 ImmutableMap (com.google.common.collect.ImmutableMap)14 Expression (io.trino.sql.tree.Expression)13 VerifyException (com.google.common.base.VerifyException)11 SymbolAllocator (io.trino.sql.planner.SymbolAllocator)11