Skip to content

Nessie: Fix drop/rename table with TableReference in identifier#5033

Merged
pvary merged 2 commits intoapache:masterfrom
ajantha-bhat:drop
Jun 23, 2022
Merged

Nessie: Fix drop/rename table with TableReference in identifier#5033
pvary merged 2 commits intoapache:masterfrom
ajantha-bhat:drop

Conversation

@ajantha-bhat
Copy link
Member

@ajantha-bhat ajantha-bhat commented Jun 14, 2022

From NessieCatalog (initialized to "main" branch),

load table works with TableReference (aka `tableName@branch` syntax),
catalog.loadTable(TableIdentifier.parse("db1.`table1.@branch1`")) -- works

but drop table will NOT work with TableReference,
catalog.dropTable(TableIdentifier.parse("db1.`table1.@branch1`")) -- return false.

Reason: For drop table, key used to look up Nessie backend will have table reference which is not an actual key in Nessie backend.

Fix: From TableIdentifier with TableReference, need to extract valid identifier to be used as a key for the drop table.

Note: Without this PR, the workaround is to re-Initialize (or create new) catalog with a specific branch and call drop table without a table reference.

Similar issue with renameTable() method also

@ajantha-bhat
Copy link
Member Author

cc: @nastra, @snazy

tableIdentifier = identifier;
}

NessieIcebergClient newClient = this.client.withReference(tableReference.getReference(), tableReference.getHash());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe inline this

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@nastra
Copy link
Contributor

nastra commented Jun 21, 2022

@RussellSpitzer could you merge this one please?

@Override
public boolean dropTable(TableIdentifier identifier, boolean purge) {
return client.dropTable(identifier, purge);
TableReference tableReference = parseTableReference(identifier);
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we have the same issue with renameTable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. I saw it during debugging. But forgot to handle.
Handled now.

@ajantha-bhat ajantha-bhat changed the title Nessie: Fix drop table with TableReference in identifier Nessie: Fix drop/rename table with TableReference in identifier Jun 21, 2022
@ajantha-bhat ajantha-bhat requested review from nastra and pvary June 21, 2022 13:45
Copy link
Contributor

@pvary pvary left a comment

Choose a reason for hiding this comment

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

+1 from me
I will give this some time, so if some want to chime in, they can comment, then if there are no more comments I will merge

@pvary pvary merged commit 7d3ed17 into apache:master Jun 23, 2022
@pvary
Copy link
Contributor

pvary commented Jun 23, 2022

Merged to master.
Thanks for the work @ajantha-bhat and @snazy and @nastra for the review!

@ajantha-bhat
Copy link
Member Author

ajantha-bhat commented Jun 23, 2022

@pvary : Thanks for the merge and review.

namrathamyske pushed a commit to namrathamyske/iceberg that referenced this pull request Jul 10, 2022
namrathamyske pushed a commit to namrathamyske/iceberg that referenced this pull request Jul 10, 2022
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.

4 participants