hackergin commented on code in PR #24183:
URL: https://github.com/apache/flink/pull/24183#discussion_r1468373906


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/ExprCodeGenerator.scala:
##########
@@ -465,20 +467,38 @@ class ExprCodeGenerator(ctx: CodeGeneratorContext, 
nullableInput: Boolean)
         call.getOperands.get(1).asInstanceOf[RexLiteral])
     }
 
+    // replace default node with right type.
+    val operands = new util.ArrayList[RexNode](call.operands)
+
     // convert operands and help giving untyped NULL literals a type
-    val operands = call.getOperands.zipWithIndex.map {
+    val expressions = call.getOperands.zipWithIndex.map {
 
       // this helps e.g. for AS(null)
       // we might need to extend this logic in case some rules do not create 
typed NULLs
       case (operandLiteral: RexLiteral, 0)
           if operandLiteral.getType.getSqlTypeName == SqlTypeName.NULL &&
             call.getOperator.getReturnTypeInference == ReturnTypes.ARG0 =>
         generateNullLiteral(resultType)
-
+      case (rexCall: RexCall, i)
+          if (rexCall.getKind == SqlKind.DEFAULT && call.getOperator
+            .isInstanceOf[BridgingSqlFunction]) => {
+        val sqlFunction = call.getOperator.asInstanceOf[BridgingSqlFunction]
+        val typeInference = sqlFunction.getTypeInference
+        val typeFactory = sqlFunction.getTypeFactory
+        if (typeInference.getTypedArguments.isPresent) {
+          val dataType = 
typeInference.getTypedArguments.get().get(i).getLogicalType
+          operands.set(
+            i,
+            
rexCall.clone(typeFactory.createFieldTypeFromLogicalType(dataType), 
rexCall.operands))

Review Comment:
   Indeed, this is redundant. The type has already been corrected in the 
SqlToRel phase.



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

Reply via email to