dawidwys commented on code in PR #23829:
URL: https://github.com/apache/flink/pull/23829#discussion_r1409609082


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/expressions/ValueLiteralExpression.java:
##########
@@ -219,6 +222,83 @@ public String asSummaryString() {
         return stringifyValue(value);
     }
 
+    @Override
+    public String asSerializableString() {
+        if (value == null && 
!dataType.getLogicalType().is(LogicalTypeRoot.NULL)) {
+            return String.format(
+                    "CAST(NULL AS %s)",
+                    // casting does not support nullability
+                    
dataType.getLogicalType().copy(true).asSerializableString());
+        }
+        final LogicalType logicalType = dataType.getLogicalType();
+        switch (logicalType.getTypeRoot()) {
+            case TINYINT:
+                return String.format("CAST(%s AS TINYINT)", value);
+            case SMALLINT:
+                return String.format("CAST(%s AS SMALLINT)", value);
+            case BIGINT:
+                return String.format("CAST(%s AS BIGINT)", value);
+            case FLOAT:
+                return String.format("CAST(%s AS FLOAT)", value);
+            case DOUBLE:
+                return String.format("CAST(%s AS DOUBLE)", value);
+            case CHAR:
+            case VARCHAR:
+            case DECIMAL:
+            case INTEGER:
+                return stringifyValue(value);
+            case BOOLEAN:
+            case SYMBOL:

Review Comment:
   The problem with symbol is that it cannot be a top-level literal. It can 
only ever be an argument of a function, but in this PR we don't have the 
`CallExpression#asSerializableString` yet.
   
   I can extend the test with `lit("abc").isJson(JsonType.SCALAR)` in 
https://github.com/apache/flink/pull/23811



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