rdblue commented on code in PR #10877: URL: https://github.com/apache/iceberg/pull/10877#discussion_r1709885848
########## core/src/main/java/org/apache/iceberg/rest/RESTUtil.java: ########## @@ -215,8 +232,33 @@ public static String encodeNamespace(Namespace ns) { * @return a namespace */ public static Namespace decodeNamespace(String encodedNs) { - Preconditions.checkArgument(encodedNs != null, "Invalid namespace: null"); - String[] levels = Iterables.toArray(NAMESPACE_ESCAPED_SPLITTER.split(encodedNs), String.class); + return decodeNamespace(encodedNs, NAMESPACE_ESCAPED_SEPARATOR); + } + + /** + * Takes in a string representation of a namespace as used for a URL parameter and returns the + * corresponding namespace. + * + * <p>See also {@link #encodeNamespace} for generating correctly formatted URLs. + * + * @param encodedNamespace a namespace to decode + * @param namespaceSeparator The namespace separator to use for decoding. This should be the same + * separator that was used when calling {@link RESTUtil#encodeNamespace(Namespace, String)} + * @return a namespace + */ + public static Namespace decodeNamespace(String encodedNamespace, String namespaceSeparator) { + Preconditions.checkArgument(encodedNamespace != null, "Invalid namespace: null"); + Preconditions.checkArgument( + !Strings.isNullOrEmpty(namespaceSeparator), "Invalid namespace separator: null or empty"); + String[] levels; + + // for backwards compatibility Review Comment: This isn't necessary if the client sends a specific `separator` in query params, right? -- 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...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org