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


##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java:
##########
@@ -98,7 +103,21 @@ public RelDataType inferReturnType(SqlOperatorBinding 
opBinding) {
         assert opBinding.getOperandCount() == 2;
         RelDataType ret = opBinding.getOperandType(1);
         RelDataType firstType = opBinding.getOperandType(0);
-        ret = opBinding.getTypeFactory().createTypeWithNullability(ret, 
firstType.isNullable());
+
+        RelOptCluster relOptCluster =
+                ((FlinkCalciteSqlValidator) ((SqlCallBinding) 
opBinding).getValidator())
+                        .getRelOptCluster();
+        TableConfig tableConfig = 
ShortcutUtils.unwrapContext(relOptCluster).getTableConfig();
+        boolean legacyCastEnabled =
+                tableConfig
+                        
.get(ExecutionConfigOptions.TABLE_EXEC_LEGACY_CAST_BEHAVIOUR)
+                        .isEnabled();
+        ret =
+                opBinding
+                        .getTypeFactory()
+                        .createTypeWithNullability(
+                                ret, firstType.isNullable() || 
legacyCastEnabled);

Review Comment:
   added



##########
flink-table/flink-table-planner/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java:
##########
@@ -98,7 +103,21 @@ public RelDataType inferReturnType(SqlOperatorBinding 
opBinding) {
         assert opBinding.getOperandCount() == 2;
         RelDataType ret = opBinding.getOperandType(1);
         RelDataType firstType = opBinding.getOperandType(0);
-        ret = opBinding.getTypeFactory().createTypeWithNullability(ret, 
firstType.isNullable());
+
+        RelOptCluster relOptCluster =
+                ((FlinkCalciteSqlValidator) ((SqlCallBinding) 
opBinding).getValidator())

Review Comment:
   fixed



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