snuyanzin commented on code in PR #27231:
URL: https://github.com/apache/flink/pull/27231#discussion_r2519845409


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/inference/TypeInferenceOperandChecker.java:
##########
@@ -240,10 +246,28 @@ private void insertImplicitCasts(SqlCallBinding 
callBinding, List<DataType> expe
 
     /** Adopted from {@link 
org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion}. */
     private SqlNode castTo(SqlNode node, RelDataType type) {
-        return SqlStdOperatorTable.CAST.createCall(
-                SqlParserPos.ZERO,
-                node,
-                
SqlTypeUtil.convertTypeToSpec(type).withNullable(type.isNullable()));
+        final SqlDataTypeSpec dataType;
+        if (type instanceof RawRelDataType) {
+            dataType = createRawDataTypeSpec((RawRelDataType) type);
+        } else {
+            dataType = 
SqlTypeUtil.convertTypeToSpec(type).withNullable(type.isNullable());
+        }
+
+        return SqlStdOperatorTable.CAST.createCall(SqlParserPos.ZERO, node, 
dataType);
+    }
+
+    private SqlDataTypeSpec createRawDataTypeSpec(RawRelDataType type) {
+        final RawType<?> rawType = type.getRawType();
+
+        SqlNode className =
+                SqlLiteral.createCharString(
+                        rawType.getOriginatingClass().getName(), 
SqlParserPos.ZERO);
+        SqlNode serializer =
+                SqlLiteral.createCharString(rawType.getSerializerString(), 
SqlParserPos.ZERO);
+
+        SqlTypeNameSpec rawSpec = new SqlRawTypeNameSpec(className, 
serializer, SqlParserPos.ZERO);
+
+        return new SqlDataTypeSpec(rawSpec, null, type.isNullable(), 
SqlParserPos.ZERO);

Review Comment:
   can we have test for that?



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