Copilot commented on code in PR #4508:
URL: https://github.com/apache/polaris/pull/4508#discussion_r3273940908
##########
polaris-core/src/main/java/org/apache/polaris/core/rest/NamespaceUtils.java:
##########
@@ -35,6 +35,19 @@ public final class NamespaceUtils {
*/
public static final String DEFAULT_NAMESPACE_SEPARATOR = "\u001f";
+ /**
+ * The default namespace separator, percent-encoded to "%1F".
+ *
+ * <p>This is the same encoded separator declared in Iceberg's {@link
+ * org.apache.iceberg.rest.RESTUtil} class, but it's package-private there
and cannot be
+ * referenced.
+ *
+ * <p>This value is also exposed in {@link
+ *
org.apache.iceberg.rest.RESTCatalogProperties#NAMESPACE_SEPARATOR_DEFAULT} –
but here we avoid
+ * referencing that field directly since we don't own it.
+ */
+ public static final String DEFAULT_NAMESPACE_SEPARATOR_ENCODED = "%1F";
Review Comment:
`DEFAULT_NAMESPACE_SEPARATOR_ENCODED` is hard-coded to "%1F" even though
Iceberg exposes the default via
`RESTCatalogProperties.NAMESPACE_SEPARATOR_DEFAULT`. To avoid Polaris drifting
from Iceberg if the default ever changes (or differs by version), consider
deriving this value from the Iceberg constant instead of duplicating it.
##########
polaris-core/src/main/java/org/apache/polaris/core/rest/PolarisResourcePaths.java:
##########
@@ -43,27 +49,46 @@ public class PolarisResourcePaths {
public static final String V1_APPLICABLE_POLICIES =
"/polaris/v1/{prefix}/applicable-policies";
private final String prefix;
+ private final String namespaceSeparatorEncoded;
- public PolarisResourcePaths(String prefix) {
+ public PolarisResourcePaths(String prefix, String namespaceSeparatorEncoded)
{
this.prefix = prefix;
+ this.namespaceSeparatorEncoded = namespaceSeparatorEncoded;
}
public static PolarisResourcePaths forCatalogProperties(Map<String, String>
properties) {
- return new PolarisResourcePaths(properties.get(PREFIX));
+ String namespaceSeparatorEncoded =
+ properties.getOrDefault(
+ RESTCatalogProperties.NAMESPACE_SEPARATOR,
+ RESTCatalogProperties.NAMESPACE_SEPARATOR_DEFAULT);
+ if
(!namespaceSeparatorEncoded.equals(RESTCatalogProperties.NAMESPACE_SEPARATOR_DEFAULT))
{
+ LOGGER.warn("Using non-default namespace separator '{}'",
namespaceSeparatorEncoded);
+ }
+ return new PolarisResourcePaths(properties.get(PREFIX),
namespaceSeparatorEncoded);
Review Comment:
`forCatalogProperties` currently accepts and uses a non-default
`RESTCatalogProperties.NAMESPACE_SEPARATOR` value (only logging a warning).
Since Polaris endpoints are parsed using
`NamespaceUtils.DEFAULT_NAMESPACE_SEPARATOR` and the service config advertises
the default separator, generating client paths with a different separator will
produce URLs the server won't understand. Consider forcing the default
separator here (or failing fast) instead of honoring a non-default value.
--
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]