Skip to content

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

Merged
merged 6 commits into from
Apr 17, 2025

Conversation

liamzwbao
Copy link
Contributor

@liamzwbao liamzwbao commented Apr 2, 2025

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:

  • Fix Polaris API including namespaceExists, dropNamespace, listTables, listViews

Comment on lines 403 to 406
Assertions.assertThat(catalog().namespaceExists(Namespace.empty())).isTrue();
Assertions.assertThat(catalog().listNamespaces())
.contains(NS)
.doesNotContain(Namespace.empty());
Copy link
Contributor

@dimas-b dimas-b Apr 2, 2025

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

@liamzwbao liamzwbao requested review from ebyhr and dimas-b April 2, 2025 22:57
@liamzwbao liamzwbao force-pushed the issue-1272-test-empty-ns branch from 3e9f4bb to df8486b Compare April 4, 2025 01:28
Copy link
Contributor

@dimas-b dimas-b left a 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.

@@ -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);
Copy link
Contributor

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.

@liamzwbao liamzwbao force-pushed the issue-1272-test-empty-ns branch from df8486b to 7012aeb Compare April 6, 2025 15:38
Copy link
Contributor Author

@liamzwbao liamzwbao left a 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.

@liamzwbao liamzwbao requested a review from dimas-b April 6, 2025 15:48
@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Apr 7, 2025
@eric-maynard eric-maynard merged commit df6e3d6 into apache:main Apr 17, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board Apr 17, 2025
@liamzwbao liamzwbao deleted the issue-1272-test-empty-ns branch April 17, 2025 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unblock test listNamespacesWithEmptyNamespace
4 participants