Source:
<code>private static Optional<ConditionAnalysis> analyzeCondition(final RexNode condition, final RelDataType leftRowType) { final List<RexNode> subConditions = decomposeAnd(condition); final List<Pair<RexNode, RexInputRef>> equalitySubConditions = new ArrayList<>(); final List<RexLiteral> literalSubConditions = new ArrayList<>(); final int numLeftFields = leftRowType.getFieldCount(); for (RexNode subCondition : subConditions) { if (RexUtil.isLiteral(subCondition, true)) { <START> if (subCondition instanceof RexCall) { <END> RexCall call = (RexCall) subCondition; literalSubConditions.add((RexLiteral) call.operands.get(0)); } else { literalSubConditions.add((RexLiteral) subCondition); } continue; } if (!subCondition.isA(SqlKind.EQUALS)) { return Optional.empty(); } final List<RexNode> operands = ((RexCall) subCondition).getOperands(); Preconditions.checkState(operands.size() == 2, "Expected 2 operands, got[%,d]", operands.size()); if (isLeftExpression(operands.get(0), numLeftFields) && isRightInputRef(operands.get(1), numLeftFields)) { equalitySubConditions.add(Pair.of(operands.get(0), (RexInputRef) operands.get(1))); } else if (isRightInputRef(operands.get(0), numLeftFields) && isLeftExpression(operands.get(1), numLeftFields)) { equalitySubConditions.add(Pair.of(operands.get(1), (RexInputRef) operands.get(0))); } else { return Optional.empty(); } } return Optional.of(new ConditionAnalysis(numLeftFields, equalitySubConditions, literalSubConditions)); }</code><technical_language>A bit nicer do if (subCondition.isA(SqlKind.CAST)), more explicit for</technical_language>

Target:
private static Optional<ConditionAnalysis> analyzeCondition(final RexNode condition, final RelDataType leftRowType) { final List<RexNode> subConditions = decomposeAnd(condition); final List<Pair<RexNode, RexInputRef>> equalitySubConditions = new ArrayList<>(); final List<RexLiteral> literalSubConditions = new ArrayList<>(); final int numLeftFields = leftRowType.getFieldCount(); for (RexNode subCondition : subConditions) { if (RexUtil.isLiteral(subCondition, true)) { if (subCondition.isA(SqlKind.CAST)) { RexCall call = (RexCall) subCondition; if (call.getType().getSqlTypeName().equals(call.getOperands().get(0).getType().getSqlTypeName())) { literalSubConditions.add((RexLiteral) call.getOperands().get(0)); } else { return Optional.empty(); } } else { literalSubConditions.add((RexLiteral) subCondition); } continue; } if (!subCondition.isA(SqlKind.EQUALS)) { return Optional.empty(); } final List<RexNode> operands = ((RexCall) subCondition).getOperands(); Preconditions.checkState(operands.size() == 2, "Expected 2 operands, got[%,d]", operands.size()); if (isLeftExpression(operands.get(0), numLeftFields) && isRightInputRef(operands.get(1), numLeftFields)) { equalitySubConditions.add(Pair.of(operands.get(0), (RexInputRef) operands.get(1))); } else if (isRightInputRef(operands.get(0), numLeftFields) && isLeftExpression(operands.get(1), numLeftFields)) { equalitySubConditions.add(Pair.of(operands.get(1), (RexInputRef) operands.get(0))); } else { return Optional.empty(); } } return Optional.of(new ConditionAnalysis(numLeftFields, equalitySubConditions, literalSubConditions)); }