use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestDynamicFiltersChecker method testUnsupportedDynamicFilterExpression.
@Test
public void testUnsupportedDynamicFilterExpression() {
PlanNode root = builder.output(ImmutableList.of(), ImmutableList.of(), builder.join(INNER, builder.filter(createDynamicFilterExpression(TEST_SESSION, metadata, new DynamicFilterId("DF"), BIGINT, expression("LINEITEM_OK + BIGINT'1'")), lineitemTableScanNode), ordersTableScanNode, ImmutableList.of(new JoinNode.EquiJoinClause(lineitemOrderKeySymbol, ordersOrderKeySymbol)), ImmutableList.of(lineitemOrderKeySymbol), ImmutableList.of(ordersOrderKeySymbol), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(new DynamicFilterId("DF"), ordersOrderKeySymbol)));
assertThatThrownBy(() -> validatePlan(root)).isInstanceOf(VerifyException.class).hasMessageMatching("Dynamic filter expression \\(\"LINEITEM_OK\" \\+ BIGINT '1'\\) must be a SymbolReference or a CAST of SymbolReference.");
}
use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestDynamicFiltersChecker method testUnmatchedNestedDynamicFilter.
@Test
public void testUnmatchedNestedDynamicFilter() {
PlanNode root = builder.output(ImmutableList.of(), ImmutableList.of(), builder.join(INNER, ordersTableScanNode, builder.filter(combineConjuncts(metadata, combineDisjuncts(metadata, expression("LINEITEM_OK IS NULL"), createDynamicFilterExpression(TEST_SESSION, metadata, new DynamicFilterId("DF"), BIGINT, lineitemOrderKeySymbol.toSymbolReference())), combineDisjuncts(metadata, expression("LINEITEM_OK IS NOT NULL"), createDynamicFilterExpression(TEST_SESSION, metadata, new DynamicFilterId("DF"), BIGINT, lineitemOrderKeySymbol.toSymbolReference()))), lineitemTableScanNode), ImmutableList.of(new JoinNode.EquiJoinClause(ordersOrderKeySymbol, lineitemOrderKeySymbol)), ImmutableList.of(ordersOrderKeySymbol), ImmutableList.of(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of()));
assertThatThrownBy(() -> validatePlan(root)).isInstanceOf(VerifyException.class).hasMessageMatching("All consumed dynamic filters could not be matched with a join/semi-join.");
}
use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class LocalDynamicFilterConsumer method create.
public static LocalDynamicFilterConsumer create(JoinNode planNode, List<Type> buildSourceTypes, int partitionCount, Set<DynamicFilterId> collectedFilters) {
checkArgument(!planNode.getDynamicFilters().isEmpty(), "Join node dynamicFilters is empty.");
checkArgument(!collectedFilters.isEmpty(), "Collected dynamic filters set is empty");
checkArgument(planNode.getDynamicFilters().keySet().containsAll(collectedFilters), "Collected dynamic filters set is not subset of join dynamic filters");
PlanNode buildNode = planNode.getRight();
Map<DynamicFilterId, Integer> buildChannels = planNode.getDynamicFilters().entrySet().stream().filter(entry -> collectedFilters.contains(entry.getKey())).collect(toImmutableMap(// Dynamic filter ID
Map.Entry::getKey, // Build-side channel index
entry -> {
Symbol buildSymbol = entry.getValue();
int buildChannelIndex = buildNode.getOutputSymbols().indexOf(buildSymbol);
verify(buildChannelIndex >= 0);
return buildChannelIndex;
}));
Map<DynamicFilterId, Type> filterBuildTypes = buildChannels.entrySet().stream().collect(toImmutableMap(Map.Entry::getKey, entry -> buildSourceTypes.get(entry.getValue())));
return new LocalDynamicFilterConsumer(buildChannels, filterBuildTypes, partitionCount);
}
use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestDynamicFilterSourceOperator method testCollectWithRealNaN.
@Test
public void testCollectWithRealNaN() {
BlockBuilder input = REAL.createBlockBuilder(null, 10);
REAL.writeLong(input, floatToRawIntBits(42.0f));
REAL.writeLong(input, floatToRawIntBits(Float.NaN));
OperatorFactory operatorFactory = createOperatorFactory(channel(0, REAL));
verifyPassthrough(createOperator(operatorFactory), ImmutableList.of(REAL), new Page(input.build()));
operatorFactory.noMoreOperators();
assertEquals(partitions.build(), ImmutableList.of(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("0"), Domain.multipleValues(REAL, ImmutableList.of((long) floatToRawIntBits(42.0f)))))));
}
use of io.trino.sql.planner.plan.DynamicFilterId in project trino by trinodb.
the class TestDynamicFilterSourceOperator method testCollectMultipleLargePages.
@Test
public void testCollectMultipleLargePages() {
int maxDistinctValues = 100;
Page page1 = new Page(createLongSequenceBlock(50, 151));
Page page2 = new Page(createLongSequenceBlock(0, 101));
Page page3 = new Page(createLongSequenceBlock(100, 201));
assertDynamicFilters(maxDistinctValues, ImmutableList.of(BIGINT), ImmutableList.of(page1, page2, page3), ImmutableList.of(TupleDomain.withColumnDomains(ImmutableMap.of(new DynamicFilterId("0"), Domain.create(ValueSet.ofRanges(range(BIGINT, 0L, true, 200L, true)), false)))));
}
Aggregations