-
Notifications
You must be signed in to change notification settings - Fork 220
Unblock test listNamespacesWithEmptyNamespace
#1289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
...kus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/IcebergCatalogTest.java
Outdated
Show resolved
Hide resolved
...kus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/IcebergCatalogTest.java
Outdated
Show resolved
Hide resolved
Assertions.assertThat(catalog().namespaceExists(Namespace.empty())).isTrue(); | ||
Assertions.assertThat(catalog().listNamespaces()) | ||
.contains(NS) | ||
.doesNotContain(Namespace.empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a bug to me. The test clearly indicates that the empty namespace exists, but is not returned when all namespaces are listed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reason is that Namespace.empty()
represents the root namespace in Polaris and is created implicitly. When we call listNamespaces
without any arg, it returns namespaces under the root—i.e., under Namespace.empty()
. In this case, we only created NS
, so it's the only one listed. Since creating an "empty" namespace isn’t something we officially support I guess, there’s no empty namespace under the root empty namespace.
That said, I’m happy to clarify what behavior we actually want here and fix it if it turns out to be a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One interesting behavior is that we can drop the empty namespace using catalog().dropNamespace(Namespace.empty())
. But after doing that, we can’t create any new namespaces because it fails, saying the parent namespace doesn't exist. Even worse, we also can’t recreate the empty namespace itself since it's explicitly blocked here.
I think we should consider aligning the behavior between creating and dropping the empty namespace anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, catalog().namespaceExists(Namespace.empty())
should not be true
(as the Iceberg tests expects).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checked the RESTSessionCatalog
implementation in Iceberg, seems like it will throw exception for empty namespaces. Fix the behavior in Polaris to match how RESTCatalog
handles empty namespaces in Iceberg.
3e9f4bb
to
df8486b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @liamzwbao ! These changes LGTM. Just a couple minor comments.
...kus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/IcebergCatalogTest.java
Outdated
Show resolved
Hide resolved
@@ -462,7 +462,7 @@ public boolean dropTable(TableIdentifier tableIdentifier, boolean purge) { | |||
|
|||
@Override | |||
public List<TableIdentifier> listTables(Namespace namespace) { | |||
if (!namespaceExists(namespace) && !namespace.isEmpty()) { | |||
if (!namespaceExists(namespace)) { | |||
throw new NoSuchNamespaceException( | |||
"Cannot list tables for namespace. Namespace does not exist: %s", namespace); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add quotes around %s
(same for views)? The empty namespace will result in an awkward message otherwise.
...kus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/IcebergCatalogTest.java
Outdated
Show resolved
Hide resolved
df8486b
to
7012aeb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dimas-b Thanks for your review! I have addressed the comments and blocked dropping empty namespace to align with creating empty namespace.
This PR fixes #1272
In Polaris, the empty namespace implicitly exists by default, see link. However, the superclass test assumes that the empty namespace does not exist initially, which causes the test to fail as expected in Polaris. This test was originally introduced in apache/iceberg#9890.
Changes in this PR:
namespaceExists
,dropNamespace
,listTables
,listViews