snuyanzin commented on code in PR #27055:
URL: https://github.com/apache/flink/pull/27055#discussion_r2738677272
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/rules/logical/RemoveUnreachableCoalesceArgumentsRule.java:
##########
@@ -121,6 +130,57 @@ private int getFirstNonNullableArgumentIndex(RexCall call)
{
}
return -1;
}
+
+ private RexNode convertToCaseWhen(RexCall call) {
+ List<RexNode> operands = call.operands;
+
+ if (operands.size() == 1) {
+ return operands.get(0);
+ }
+
+ RexBuilder rexBuilder = this.rexBuilder;
+ ImmutableList.Builder<RexNode> caseArgs = ImmutableList.builder();
+
+ for (int i = 0; i < operands.size() - 1; i++) {
+ RexNode operand = operands.get(i);
+ RexNode isNotNullCheck =
+ rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL,
operand);
+ caseArgs.add(isNotNullCheck);
+ caseArgs.add(operand);
+ }
+
+ caseArgs.add(operands.get(operands.size() - 1));
+
+ return rexBuilder.makeCall(SqlStdOperatorTable.CASE,
caseArgs.build());
+ }
+
+ private boolean containsFunctionCalls(RexCall call) {
+ for (RexNode operand : call.operands) {
+ if (isFunctionCall(operand)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isFunctionCall(RexNode node) {
+ return node instanceof RexCall
+ && !isSimpleCast((RexCall) node)
+ && !isFieldReference(node)
+ && !isLiteral(node);
Review Comment:
should we replace it with
```java
if (!(node instanceof RexCall)) {
return false;
}
RexCall call = (RexCall) node;
SqlOperator operator = call.getOperator();
return operator instanceof SqlFunction && operator.getKind() != SqlKind.CAST;
```
?
--
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]