xuyangzhong commented on code in PR #25418:
URL: https://github.com/apache/flink/pull/25418#discussion_r1798730266


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/ExprCodeGenerator.scala:
##########
@@ -679,13 +679,15 @@ class ExprCodeGenerator(ctx: CodeGeneratorContext, 
nullableInput: Boolean)
 
       // casting
       case CAST =>
+        val legacyCastEnabled = ctx.tableConfig
+          .get(ExecutionConfigOptions.TABLE_EXEC_LEGACY_CAST_BEHAVIOUR)
+          .isEnabled
         generateCast(
           ctx,
           operands.head,
-          resultType,
-          nullOnFailure = ctx.tableConfig
-            .get(ExecutionConfigOptions.TABLE_EXEC_LEGACY_CAST_BEHAVIOUR)
-            .isEnabled)
+          if (legacyCastEnabled) resultType.copy(true) else resultType,

Review Comment:
   I think we should correct the nullable attributes when constructing the 
RelNode tree, rather than during code generation. The benefit of this approach 
is that downstream will be able to recognize changes in the nullable attributes 
of the corresponding types. Considering that the default value for 
TABLE_EXEC_LEGACY_CAST_BEHAVIOUR is false, the number of affected plans will 
not be significant. WDYT?



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to