julianhyde commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597161501


##########
core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java:
##########
@@ -418,6 +419,32 @@ private static RexNode convertNvl(SqlRexContext cx, 
SqlCall call) {
                 operand1)));
   }
 
+  /** Converts a call to the {@code NVL2} function. */
+  private static RexNode convertNvl2(SqlRexContext cx, SqlCall call) {
+    final RexBuilder rexBuilder = cx.getRexBuilder();
+    final RexNode operand0 =
+        cx.convertExpression(call.getOperandList().get(0));
+    final RexNode operand1 =
+        cx.convertExpression(call.getOperandList().get(1));
+    final RexNode operand2 =
+        cx.convertExpression(call.getOperandList().get(2));
+    final RelDataType type =
+        cx.getValidator().getValidatedNodeType(call);
+    // Preserve Operand Nullability

Review Comment:
   Why preserve operand nullability? Result is nullable iff either operand 1 or 
2 is nullable.
   
   A comment that you translate NVL2(x, y, z) to CASE WHEN x is NULL THEN y 
ELSE z END would make this method much easier to understand.
   
   Why convert operands one at a time? Use `convertOperands`.



-- 
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

Reply via email to