use of io.trino.sql.tree.ComparisonExpression.Operator.IS_DISTINCT_FROM in project trino by trinodb.
the class JoinMatcher method matchDynamicFilters.
private boolean matchDynamicFilters(JoinNode joinNode, SymbolAliases symbolAliases) {
if (expectedDynamicFilter.isEmpty()) {
return true;
}
Set<DynamicFilterId> dynamicFilterIds = joinNode.getDynamicFilters().keySet();
List<DynamicFilters.Descriptor> descriptors = searchFrom(joinNode.getLeft()).where(FilterNode.class::isInstance).findAll().stream().flatMap(filterNode -> extractExpressions(filterNode).stream()).flatMap(expression -> extractDynamicFilters(expression).getDynamicConjuncts().stream()).filter(descriptor -> dynamicFilterIds.contains(descriptor.getId())).collect(toImmutableList());
Map<DynamicFilterId, Symbol> idToBuildSymbolMap = joinNode.getDynamicFilters();
Set<Expression> actual = new HashSet<>();
for (DynamicFilters.Descriptor descriptor : descriptors) {
Expression probe = descriptor.getInput();
Symbol build = idToBuildSymbolMap.get(descriptor.getId());
if (build == null) {
return false;
}
Expression expression;
if (descriptor.isNullAllowed()) {
expression = new NotExpression(new ComparisonExpression(IS_DISTINCT_FROM, probe, build.toSymbolReference()));
} else {
expression = new ComparisonExpression(descriptor.getOperator(), probe, build.toSymbolReference());
}
actual.add(expression);
}
Set<Expression> expected = expectedDynamicFilter.get().stream().map(pattern -> pattern.getExpression(symbolAliases)).collect(toImmutableSet());
return expected.equals(actual);
}
Aggregations