use of io.trino.sql.planner.assertions.PlanMatchPattern.DynamicFilterPattern in project trino by trinodb.
the class TestDynamicFilter method testIsNotDistinctFromJoin.
@Test
public void testIsNotDistinctFromJoin() {
assertPlan("SELECT o.orderkey FROM orders o, lineitem l WHERE l.orderkey IS NOT DISTINCT FROM o.orderkey", anyTree(filter("O_ORDERKEY IS NOT DISTINCT FROM L_ORDERKEY", join(INNER, ImmutableList.of(), ImmutableList.of(new DynamicFilterPattern("O_ORDERKEY", EQUAL, "L_ORDERKEY", true)), filter(TRUE_LITERAL, tableScan("orders", ImmutableMap.of("O_ORDERKEY", "orderkey"))), exchange(tableScan("lineitem", ImmutableMap.of("L_ORDERKEY", "orderkey")))))));
// Dynamic filter is not supported for IS DISTINCT FROM
assertPlan("SELECT o.orderkey FROM orders o, lineitem l WHERE l.orderkey IS DISTINCT FROM o.orderkey", anyTree(filter("O_ORDERKEY IS DISTINCT FROM L_ORDERKEY", join(INNER, ImmutableList.of(), ImmutableList.of(), tableScan("orders", ImmutableMap.of("O_ORDERKEY", "orderkey")), exchange(tableScan("lineitem", ImmutableMap.of("L_ORDERKEY", "orderkey")))))));
// extendedprice and totalprice are of DOUBLE type, dynamic filter is not supported with IS NOT DISTINCT FROM clause on DOUBLE or REAL types
assertPlan("SELECT o.orderkey FROM orders o, lineitem l WHERE l.extendedprice IS NOT DISTINCT FROM o.totalprice", anyTree(filter("O_TOTALPRICE IS NOT DISTINCT FROM L_EXTENDEDPRICE", join(INNER, ImmutableList.of(), ImmutableList.of(), tableScan("orders", ImmutableMap.of("O_TOTALPRICE", "totalprice")), exchange(tableScan("lineitem", ImmutableMap.of("L_EXTENDEDPRICE", "extendedprice")))))));
}
use of io.trino.sql.planner.assertions.PlanMatchPattern.DynamicFilterPattern in project trino by trinodb.
the class TestDynamicFilter method testCrossJoinBetweenDF.
@Test
public void testCrossJoinBetweenDF() {
assertPlan("SELECT o.orderkey FROM orders o, lineitem l WHERE o.orderkey BETWEEN l.orderkey AND l.partkey", anyTree(filter("O_ORDERKEY BETWEEN L_ORDERKEY AND L_PARTKEY", join(INNER, ImmutableList.of(), ImmutableList.of(new DynamicFilterPattern("O_ORDERKEY", GREATER_THAN_OR_EQUAL, "L_ORDERKEY"), new DynamicFilterPattern("O_ORDERKEY", LESS_THAN_OR_EQUAL, "L_PARTKEY")), filter(TRUE_LITERAL, tableScan("orders", ImmutableMap.of("O_ORDERKEY", "orderkey"))), exchange(tableScan("lineitem", ImmutableMap.of("L_ORDERKEY", "orderkey", "L_PARTKEY", "partkey")))))));
assertPlan("SELECT o.orderkey FROM orders o, lineitem l WHERE o.orderkey BETWEEN l.orderkey AND l.partkey - 1", anyTree(filter("O_ORDERKEY BETWEEN L_ORDERKEY AND L_PARTKEY - BIGINT '1'", join(INNER, ImmutableList.of(), ImmutableList.of(new DynamicFilterPattern("O_ORDERKEY", GREATER_THAN_OR_EQUAL, "L_ORDERKEY")), filter(TRUE_LITERAL, tableScan("orders", ImmutableMap.of("O_ORDERKEY", "orderkey"))), exchange(tableScan("lineitem", ImmutableMap.of("L_ORDERKEY", "orderkey", "L_PARTKEY", "partkey")))))));
assertPlan("SELECT o.orderkey FROM orders o, lineitem l WHERE o.orderkey BETWEEN l.orderkey + 1 AND l.partkey", anyTree(filter("O_ORDERKEY BETWEEN L_ORDERKEY + BIGINT '1' AND L_PARTKEY", join(INNER, ImmutableList.of(), ImmutableList.of(new DynamicFilterPattern("O_ORDERKEY", LESS_THAN_OR_EQUAL, "L_PARTKEY")), filter(TRUE_LITERAL, tableScan("orders", ImmutableMap.of("O_ORDERKEY", "orderkey"))), exchange(tableScan("lineitem", ImmutableMap.of("L_ORDERKEY", "orderkey", "L_PARTKEY", "partkey")))))));
}
Aggregations