raminqaf commented on code in PR #29310:
URL: https://github.com/apache/flink/pull/29310#discussion_r4122896422


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/casting/VariantToStringCastRule.java:
##########
@@ -99,10 +101,12 @@ public String generateExpression(
             LogicalType inputLogicalType,
             LogicalType targetLogicalType) {
         if (context.isPrinting()) {
-            // Printing renders every variant as JSON, so a scalar string 
shows quoted rather than
-            // extracted as the cast below would. toJson returns a String, so 
it needs the wrap that
-            // toStringValue applies itself.
-            return staticCall(BINARY_STRING_DATA_FROM_STRING(), 
methodCall(inputTerm, "toJson"));
+            // Created inline because expression rules cannot declare class 
fields.
+            final String formatter =
+                    constructorCall(
+                            SqlStringVariantFormatter.class, 
context.getSessionTimeZoneTerm());
+            return staticCall(
+                    BINARY_STRING_DATA_FROM_STRING(), methodCall(formatter, 
"format", inputTerm));

Review Comment:
   Removed class entirely. Changed `toDisplayString` -> `toPrintString` and 
made it public



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