slinkydeveloper commented on a change in pull request #18063:
URL: https://github.com/apache/flink/pull/18063#discussion_r766568276



##########
File path: 
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/casting/ArrayToStringCastRule.java
##########
@@ -91,74 +121,98 @@ protected String generateCodeBlockInternal(
         context.declareClassField(
                 className(StringBuilder.class), builderTerm, 
constructorCall(StringBuilder.class));
 
-        return new CastRuleUtils.CodeWriter()
-                .stmt(methodCall(builderTerm, "setLength", 0))
-                .stmt(methodCall(builderTerm, "append", strLiteral("[")))
-                .forStmt(
-                        methodCall(inputTerm, "size"),
-                        (indexTerm, loopBodyWriter) -> {
-                            String elementTerm = newName("element");
-                            String elementIsNullTerm = 
newName("elementIsNull");
+        final String resultStringTerm = newName("resultString");
+        final int precision = LogicalTypeChecks.getLength(targetLogicalType);
 
-                            CastCodeBlock codeBlock =
-                                    CastRuleProvider.generateCodeBlock(
-                                            context,
-                                            elementTerm,
-                                            "false",
-                                            // Null check is done at the array 
access level
-                                            innerInputType.copy(false),
-                                            targetLogicalType);
+        return 
CharacterFamilyTrimmingAndPaddingCastRule.appendAndTrimStringIfNeeded(

Review comment:
       Because the logical step of doing the append and trim comes after the 
rest of the code here, can you assign the writer to a variable and invoke 
append and trim later?




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