You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "snazy (via GitHub)" <gi...@apache.org> on 2024/09/26 15:55:15 UTC
[PR] Nessie: respect the nearest namespace's `location` property when creating a table or view [iceberg]
snazy opened a new pull request, #11215:
URL: https://github.com/apache/iceberg/pull/11215
The current implementation only respects the `location` property of the immediate parent, which leads to unexpected results when using nested namespaces.
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Nessie: respect the nearest namespace's `location` property when creating a table or view [iceberg]
Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #11215:
URL: https://github.com/apache/iceberg/pull/11215#discussion_r1777528160
##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java:
##########
@@ -358,6 +360,57 @@ private static void checkNamespaceIsValid(Namespace namespace) {
}
}
+ /**
+ * Resolves the "location" for a new table or view, respecting the "location" property of the
+ * "nearest" namespace.
+ */
+ public String locationForNewEntity(TableIdentifier table, String warehouseLocation)
+ throws NoSuchNamespaceException {
+
+ String location = warehouseLocation;
+ if (table.hasNamespace()) {
+ Namespace namespace = table.namespace();
+ checkNamespaceIsValid(namespace);
+
+ List<String> keyElements = List.of(namespace.levels());
+ int keyElementCount = keyElements.size();
+
+ List<ContentKey> keysInOrder = Lists.newArrayListWithCapacity(keyElementCount);
+ for (int i = 0; i < keyElementCount; i++) {
+ ContentKey key = ContentKey.of(keyElements.subList(0, i + 1));
+ keysInOrder.add(key);
+ }
+
+ try {
+ Map<ContentKey, Content> contentMap =
+ withReference(api.getContent()).keys(keysInOrder).get();
+ int index;
+ for (index = keysInOrder.size() - 1; index >= 0; index--) {
+ ContentKey key = keysInOrder.get(index);
+ String namespaceLocation =
+ unwrapNamespace(contentMap.get(key))
+ .map(org.projectnessie.model.Namespace::getProperties)
+ .map(p -> p.get("location"))
+ .orElse(null);
+ if (namespaceLocation != null) {
+ location = namespaceLocation;
+ break;
+ }
+ }
+ for (index++; index < keyElementCount; index++) {
+ location += "/" + keyElements.get(index);
Review Comment:
Updated the PR description
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Nessie: respect the nearest namespace's `location` property when creating a table or view [iceberg]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11215:
URL: https://github.com/apache/iceberg/pull/11215#issuecomment-2489805045
This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Nessie: respect the nearest namespace's `location` property when creating a table or view [iceberg]
Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on PR #11215:
URL: https://github.com/apache/iceberg/pull/11215#issuecomment-2497427646
Could an Iceberg committer please reopen and review this change?
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Nessie: respect the nearest namespace's `location` property when creating a table or view [iceberg]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11215:
URL: https://github.com/apache/iceberg/pull/11215#issuecomment-2475084336
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Nessie: respect the nearest namespace's `location` property when creating a table or view [iceberg]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #11215: Nessie: respect the nearest namespace's `location` property when creating a table or view
URL: https://github.com/apache/iceberg/pull/11215
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Nessie: respect the nearest namespace's `location` property when creating a table or view [iceberg]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #11215:
URL: https://github.com/apache/iceberg/pull/11215#discussion_r1777465009
##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java:
##########
@@ -358,6 +360,57 @@ private static void checkNamespaceIsValid(Namespace namespace) {
}
}
+ /**
+ * Resolves the "location" for a new table or view, respecting the "location" property of the
+ * "nearest" namespace.
+ */
+ public String locationForNewEntity(TableIdentifier table, String warehouseLocation)
+ throws NoSuchNamespaceException {
+
+ String location = warehouseLocation;
+ if (table.hasNamespace()) {
+ Namespace namespace = table.namespace();
+ checkNamespaceIsValid(namespace);
+
+ List<String> keyElements = List.of(namespace.levels());
+ int keyElementCount = keyElements.size();
+
+ List<ContentKey> keysInOrder = Lists.newArrayListWithCapacity(keyElementCount);
+ for (int i = 0; i < keyElementCount; i++) {
+ ContentKey key = ContentKey.of(keyElements.subList(0, i + 1));
+ keysInOrder.add(key);
+ }
+
+ try {
+ Map<ContentKey, Content> contentMap =
+ withReference(api.getContent()).keys(keysInOrder).get();
+ int index;
+ for (index = keysInOrder.size() - 1; index >= 0; index--) {
+ ContentKey key = keysInOrder.get(index);
+ String namespaceLocation =
+ unwrapNamespace(contentMap.get(key))
+ .map(org.projectnessie.model.Namespace::getProperties)
+ .map(p -> p.get("location"))
+ .orElse(null);
+ if (namespaceLocation != null) {
+ location = namespaceLocation;
+ break;
+ }
+ }
+ for (index++; index < keyElementCount; index++) {
+ location += "/" + keyElements.get(index);
Review Comment:
I believe this changes how base locations are constructed by default. Old code would use dots to join namespace elements, now we use slashes. Could you make a note of this in the commit message?
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org