linorosa commented on code in PR #4135: URL: https://github.com/apache/calcite/pull/4135#discussion_r1913741526
########## core/src/main/java/org/apache/calcite/plan/RelOptUtil.java: ########## @@ -1747,40 +1747,46 @@ private static void splitJoinCondition( * and * {@link #splitJoinCondition(List, List, RexNode, List, List, List, List)}. * - * <p>If the given expr <code>call</code> is an expanded version of + * <p>If the given expr <code>rexCall</code> contains an expanded version of * {@code IS NOT DISTINCT FROM} function call, collapses it and return a * {@code IS NOT DISTINCT FROM} function call. * * <p>For example: {@code t1.key IS NOT DISTINCT FROM t2.key} - * can rewritten in expanded form as + * can be rewritten in expanded form as * {@code t1.key = t2.key OR (t1.key IS NULL AND t2.key IS NULL)}. * - * @param call Function expression to try collapsing + * @param rexCall Function expression to try collapsing * @param rexBuilder {@link RexBuilder} instance to create new {@link RexCall} instances. - * @return If the given function is an expanded IS NOT DISTINCT FROM function call, - * return a IS NOT DISTINCT FROM function call. Otherwise return the input - * function call as it is. + * @return A function that's semantically equivalent to the original, with all + * expanded IS NOT DISTINCT FROM function calls collapsed back into their + * original compact form. */ - public static RexCall collapseExpandedIsNotDistinctFromExpr(final RexCall call, + public static RexCall collapseExpandedIsNotDistinctFromExpr(final RexCall rexCall, final RexBuilder rexBuilder) { - switch (call.getKind()) { - case OR: - return doCollapseExpandedIsNotDistinctFromOrExpr(call, rexBuilder); + final RexShuttle shuttle = new RexShuttle() { + @Override public RexNode visitCall(RexCall call) { + SqlKind callKind = call.getKind(); + int operandCount = call.getOperands().size(); - case CASE: - return doCollapseExpandedIsNotDistinctFromCaseExpr(call, rexBuilder); + boolean isExpandedOrExpr = callKind == SqlKind.OR && operandCount == 2; Review Comment: yeah makes sense, I moved them back there -- 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: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org