use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestLocalDynamicFilterConsumer method testSimple.
@Test
public void testSimple() throws Exception {
LocalDynamicFilterConsumer filter = new LocalDynamicFilterConsumer(ImmutableMap.of(new DynamicFilterId("123"), 0), ImmutableMap.of(new DynamicFilterId("123"), INTEGER), 1);
assertEquals(filter.getBuildChannels(), ImmutableMap.of(new DynamicFilterId("123"), 0));
Consumer<TupleDomain<DynamicFilterId>> consumer = filter.getTupleDomainConsumer();
ListenableFuture<Map<DynamicFilterId, Domain>> result = filter.getDynamicFilterDomains();
assertFalse(result.isDone());
consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("123"), Domain.singleValue(INTEGER, 7L))));
assertEquals(result.get(), ImmutableMap.of(new DynamicFilterId("123"), Domain.singleValue(INTEGER, 7L)));
}
use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestLocalDynamicFilterConsumer method testAllDomain.
@Test
public void testAllDomain() throws Exception {
DynamicFilterId filter1 = new DynamicFilterId("123");
DynamicFilterId filter2 = new DynamicFilterId("124");
LocalDynamicFilterConsumer filter = new LocalDynamicFilterConsumer(ImmutableMap.of(filter1, 0, filter2, 1), ImmutableMap.of(filter1, INTEGER, filter2, INTEGER), 1);
Consumer<TupleDomain<DynamicFilterId>> consumer = filter.getTupleDomainConsumer();
ListenableFuture<Map<DynamicFilterId, Domain>> result = filter.getDynamicFilterDomains();
assertFalse(result.isDone());
consumer.accept(TupleDomain.withColumnDomains(ImmutableMap.of(filter1, Domain.all(INTEGER), filter2, Domain.singleValue(INTEGER, 1L))));
assertEquals(result.get(), ImmutableMap.of(filter1, Domain.all(INTEGER), filter2, Domain.singleValue(INTEGER, 1L)));
}
use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestDynamicFiltersChecker method testDynamicFilterConsumedOnBuildSide.
@Test
public void testDynamicFilterConsumedOnBuildSide() {
PlanNode root = builder.join(INNER, builder.filter(createDynamicFilterExpression(TEST_SESSION, metadata, new DynamicFilterId("DF"), BIGINT, ordersOrderKeySymbol.toSymbolReference()), ordersTableScanNode), builder.filter(createDynamicFilterExpression(TEST_SESSION, metadata, new DynamicFilterId("DF"), BIGINT, ordersOrderKeySymbol.toSymbolReference()), 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 consumed by it's build side.");
}
use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestDynamicFiltersChecker method testDynamicFilterNotAboveTableScan.
@Test
public void testDynamicFilterNotAboveTableScan() {
PlanNode root = builder.output(ImmutableList.of(), ImmutableList.of(), builder.join(INNER, builder.filter(combineConjuncts(metadata, expression("LINEITEM_OK > 0"), createDynamicFilterExpression(TEST_SESSION, metadata, new DynamicFilterId("DF"), BIGINT, ordersOrderKeySymbol.toSymbolReference())), builder.values(lineitemOrderKeySymbol)), ordersTableScanNode, ImmutableList.of(new JoinNode.EquiJoinClause(lineitemOrderKeySymbol, ordersOrderKeySymbol)), ImmutableList.of(), ImmutableList.of(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(new DynamicFilterId("DF"), ordersOrderKeySymbol)));
assertThatThrownBy(() -> validatePlan(root)).isInstanceOf(VerifyException.class).hasMessageMatching("Dynamic filters \\[Descriptor\\{id=DF, input=\"ORDERS_OK\", operator=EQUAL, nullAllowed=false\\}\\] present in filter predicate whose source is not a table scan.");
}
use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestDynamicFiltersChecker method testDynamicFilterNotAboveTableScanWithSemiJoin.
@Test
public void testDynamicFilterNotAboveTableScanWithSemiJoin() {
PlanNode root = builder.semiJoin(builder.filter(combineConjuncts(metadata, expression("ORDERS_OK > 0"), createDynamicFilterExpression(TEST_SESSION, metadata, new DynamicFilterId("DF"), BIGINT, ordersOrderKeySymbol.toSymbolReference())), builder.values(ordersOrderKeySymbol)), lineitemTableScanNode, ordersOrderKeySymbol, lineitemOrderKeySymbol, new Symbol("SEMIJOIN_OUTPUT"), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(new DynamicFilterId("DF")));
assertThatThrownBy(() -> validatePlan(root)).isInstanceOf(VerifyException.class).hasMessageMatching("Dynamic filters \\[Descriptor\\{id=DF, input=\"ORDERS_OK\", operator=EQUAL, nullAllowed=false\\}\\] present in filter predicate whose source is not a table scan.");
}
Aggregations