Skip to content

Core: Prevent dropping namespace when it contains views#14456

Merged
nastra merged 3 commits into
apache:mainfrom
nastra:drop-nonempty-ns-with-views
Nov 3, 2025
Merged

Core: Prevent dropping namespace when it contains views#14456
nastra merged 3 commits into
apache:mainfrom
nastra:drop-nonempty-ns-with-views

Conversation

@nastra

@nastra nastra commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

fixes #14175

@github-actions github-actions Bot added the core label Oct 31, 2025
}

@Test
public void dropNonEmptyNamespace() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to add this test case to other view catalogs (or at least to Nessie and Hive catalog)? Or maybe to a base class for those tests?

@nastra nastra Oct 31, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nandorKollar this is already the base class and all the other view catalog implementations run this set of tests

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does drop namespace command support cascade?

@singhpk234 singhpk234 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch LGTM, though I have doubt on detecting namespace empty in case of nested-namespace

lets say i have a structure like this

      NS1 
    /   \    \ 
  T    V   NS2
             / \ 
            T V 

T is Table, V is view
NS1 and NS2 a namespace
we want to drop NS1
shouldn't in addition to this we check
GET /namespaces?parent=NS1

@nastra

nastra commented Oct 31, 2025

Copy link
Copy Markdown
Contributor Author

This patch LGTM, though I have doubt on detecting namespace empty in case of nested-namespace

lets say i have a structure like this

      NS1 
    /   \    \ 
  T    V   NS2
             / \ 
            T V 

T is Table, V is view NS1 and NS2 a namespace we want to drop NS1 shouldn't in addition to this we check GET /namespaces?parent=NS1

This is probably a good candidate to tackle in a separate PR

List<TableIdentifier> viewIdentifiers = listViews(namespace);
if (viewIdentifiers != null && !viewIdentifiers.isEmpty()) {
throw new NamespaceNotEmptyException(
"Namespace %s is not empty. %s views exist.", namespace, viewIdentifiers.size());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shall we align this with the previous error message Namespace %s is not empty. Contains %d view(s).?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@huaxingao

Copy link
Copy Markdown
Contributor

Shall we include this fix in 1.10.1?

@singhpk234 singhpk234 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, too thanks @nastra !

Comment thread core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java Outdated
Comment on lines +220 to +221
List<TableIdentifier> viewIdentifiers = listViews(namespace);
if (!viewIdentifiers.isEmpty()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curious, beside table and view, are there any other object can be inside namespace?
For instance: function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An Iceberg namespace can only hold tables/views. Functions/Procedures would only be relevant in the context of Spark and we have SparkCatalog that deals with those things

Co-authored-by: Prashant Singh <35593236+singhpk234@users.noreply.github.com>
@nastra nastra merged commit d6ac00c into apache:main Nov 3, 2025
42 checks passed
@nastra nastra deleted the drop-nonempty-ns-with-views branch November 3, 2025 08:10
@nastra

nastra commented Nov 3, 2025

Copy link
Copy Markdown
Contributor Author

thanks everyone for the reviews

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception raise when drop namespace, if there are views in it

6 participants