rohangarg commented on a change in pull request #11434:
URL: https://github.com/apache/druid/pull/11434#discussion_r668824638
##########
File path:
sql/src/main/java/org/apache/druid/sql/calcite/rule/FilterJoinExcludePushToChildRule.java
##########
@@ -292,4 +298,42 @@ private static boolean classifyFilters(List<RexNode>
filters,
// Did anything change?
return !filtersToRemove.isEmpty();
}
+
+ private void removeRedundantIsNotNullFilters(List<RexNode> joinFilters,
JoinRelType joinType)
+ {
+ if (joinType != JoinRelType.INNER) {
+ return; // only works for inner joins
+ }
+
+ ImmutableList.Builder<RexNode> isNotNullFiltersBuilder =
ImmutableList.builder();
+ ImmutableList.Builder<Pair<RexNode, RexNode>>
equalityFiltersOperandBuilder = ImmutableList.builder();
+
+ for (RexNode joinFilter : joinFilters) {
+ List<RexNode> operands = ((RexCall) joinFilter).getOperands();
+ if (joinFilter.isA(SqlKind.IS_NOT_NULL)) {
+ isNotNullFiltersBuilder.add(joinFilter);
+ }
+ if (joinFilter.isA(SqlKind.EQUALS) && operands.size() == 2) {
+ equalityFiltersOperandBuilder.add(new Pair<>(operands.get(0),
operands.get(1)));
Review comment:
Yes, I too think that it should never be null. But for safety, I've
added null checks to the operands. I think we wouldn't want to compare the
is-null-filter to an equals filter which contains a null operand. Also, I've
added checks for `RexCall` object since in the original calcite rule too, there
is no assumption that the filter would always be an object of RexCall. They too
do an instance check before casting.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]