ahmedabu98 commented on code in PR #38876:
URL: https://github.com/apache/beam/pull/38876#discussion_r3383266217


##########
sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/IcebergUtils.java:
##########
@@ -631,6 +633,51 @@ private static Object getLogicalTypeValue(Object 
icebergValue, Schema.FieldType
     return icebergValue;
   }
 
+  /** Serializes a table identifier without losing dots or other special 
characters in each part. */
+  public static String tableIdentifierToString(TableIdentifier 
tableIdentifier) {
+    TableIdentifier identifier = checkArgumentNotNull(tableIdentifier);
+    return requiresJsonTableIdentifier(identifier)
+        ? TableIdentifierParser.toJson(identifier)
+        : identifier.toString();
+  }
+
+  /** Parses either Iceberg's JSON table identifier representation or the 
legacy dotted form. */
+  public static TableIdentifier parseTableIdentifier(String table) {
+    if (startsWithJsonObject(table)) {
+      return TableIdentifierParser.fromJson(table);
+    }
+
+    return TableIdentifier.parse(table);
+  }
+
+  private static boolean startsWithJsonObject(@Nullable String value) {
+    if (value == null) {
+      return false;
+    }
+
+    for (int i = 0; i < value.length(); i++) {
+      if (!Character.isWhitespace(value.charAt(i))) {
+        return value.charAt(i) == '{';
+      }
+    }
+
+    return false;
+  }

Review Comment:
   Done



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