Skip to content
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

Prevent table creation on non-empty location for Iceberg tables #12626

Merged

Conversation

mdesmet
Copy link
Contributor

@mdesmet mdesmet commented Jun 1, 2022

Description

Is this change a fix, improvement, new feature, refactoring, or other?

Fix

Is this a change to the core query engine, a connector, client library, or the SPI interfaces? (be specific)

Change to Iceberg connector

How would you describe this change to a non-technical end user or system administrator?

Related issues, pull requests, and links

Documentation

( ) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.

Release notes

( ) No release notes entries required.
( ) Release notes entries required with the following suggested text:

# Section
* Fix some things. ({issue}`issuenumber`)

HdfsContext hdfsContext = new HdfsContext(session);
try {
FileSystem fileSystem = hdfsEnvironment.getFileSystem(hdfsContext, new Path(location));
if (fileSystem.exists(new Path(location))) {
Copy link
Member

Choose a reason for hiding this comment

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

If the directory exists, but is empty. Should we allow it? That seems reasonable to me

Copy link
Member

Choose a reason for hiding this comment

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

That can be useful and indeed is safe to do.

(except for concurrency, which we need to ignore anyway)

@mdesmet mdesmet force-pushed the bug/prevent-table-creation-on-non-empty-path branch from ac8aa17 to 4ca1941 Compare June 7, 2022 11:17
@github-actions github-actions bot added the docs label Jun 7, 2022
retryMode);
}
catch (IOException e) {
throw new TrinoException(ICEBERG_FILESYSTEM_ERROR, "Failed getting FileSystem: " + location, e);
Copy link
Member

Choose a reason for hiding this comment

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

it's not only hdfsEnvironment.getFileSystem( what can throw IOE.
change message to

"Failed checking new table's location: " + location

Comment on lines 574 to 575
throw new TrinoException(ICEBERG_FILESYSTEM_ERROR, "Cannot create a table on a non-empty location: " + location + ", " +
"set 'iceberg.unique-table-location=true' in your Iceberg catalog properties to use unique table locations for every table.");
Copy link
Member

Choose a reason for hiding this comment

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

use format

Suggested change
throw new TrinoException(ICEBERG_FILESYSTEM_ERROR, "Cannot create a table on a non-empty location: " + location + ", " +
"set 'iceberg.unique-table-location=true' in your Iceberg catalog properties to use unique table locations for every table.");
throw new TrinoException(ICEBERG_FILESYSTEM_ERROR, format(
"Cannot create a table on a non-empty location: %s, set 'iceberg.unique-table-location=true' in your Iceberg catalog properties " +
"to use unique table locations for every table.",
location));

@mdesmet mdesmet force-pushed the bug/prevent-table-creation-on-non-empty-path branch from 971bdd0 to 512e4bf Compare June 8, 2022 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Iceberg CREATE TABLE statement allows to create a table on a location already used by another Iceberg table
4 participants