trushev commented on a change in pull request #17416:
URL: https://github.com/apache/flink/pull/17416#discussion_r725498056



##########
File path: 
flink-table/flink-table-common/src/main/java/org/apache/flink/table/utils/PartitionPathUtils.java
##########
@@ -113,19 +113,36 @@ private static String escapePathName(String path) {
             throw new TableException("Path should not be null or empty: " + 
path);
         }
 
-        StringBuilder sb = new StringBuilder();
+        StringBuilder sb = null;
         for (int i = 0; i < path.length(); i++) {
             char c = path.charAt(i);
             if (needsEscaping(c)) {
-                sb.append('%');
-                sb.append(String.format("%1$02X", (int) c));
-            } else {
+                if (sb == null) {
+                    sb = new StringBuilder(path.length() + 2);
+                    for (int j = 0; j < i; j++) {
+                        sb.append(path.charAt(j));
+                    }
+                }
+                escapeChar(c, sb);
+            } else if (sb != null) {
                 sb.append(c);
             }
         }

Review comment:
       It works correctly. I added several units that cover the scenarios of 
head, middle, tail, missing, and combined control characters




-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to