Skip to content

Conversation

twuebi
Copy link

@twuebi twuebi commented Sep 29, 2025

Description

This should fix #26742 where it's impossible to create a table on non-s3tables REST catalogs that don't return a namespace location.

Additional context and related issues

There are two separate conditions being used to determine if a table should be non-staged and if its location has to be empty. If the table is being created as non-staged, then the location won't be empty.

Release notes

(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

fix table creation on non-s3tables REST catalogs that don't specify namespace location
@cla-bot cla-bot bot added the cla-signed label Sep 29, 2025
@github-actions github-actions bot added the iceberg Iceberg connector label Sep 29, 2025
@twuebi twuebi added the bug Something isn't working label Sep 29, 2025
@@ -1301,18 +1281,21 @@ public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, Con
.orElseGet(() -> catalog.defaultTableLocation(session, tableMetadata.getTable()));
}
transaction = newCreateTableTransaction(catalog, tableMetadata, session, replace, tableLocation, allowedExtraProperties);

Copy link
Contributor

Choose a reason for hiding this comment

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

undo

Copy link
Author

Choose a reason for hiding this comment

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

undone

Copy link
Member

@ebyhr ebyhr left a comment

Choose a reason for hiding this comment

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

Is it possible to add a test?

@twuebi
Copy link
Author

twuebi commented Sep 30, 2025

Sure, could you point me in the correct direction @ebyhr?

I likely simply didn't see it, where is this behavior currently being tested?

I checked plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/rest but didn't see

if (!isS3Tables(location.toString())) {
// we create a non-staged table if tableLocation.isEmpty(), in that case, the table location will not be
// empty
if (!isS3Tables(location.toString()) && !(tableLocation != null && tableLocation.isEmpty())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what about non-zero length whitespaced string : " " or " " ?
should we also add tableLocation.isBlank() e.g.

if (!isS3Tables(location.toString()) && !(tableLocation != null && tableLocation.isEmpty() && tableLocation.isBlank())) {

Copy link
Author

Choose a reason for hiding this comment

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

Can add those, wondering if location should reject such invalid location strings?

Copy link
Author

Choose a reason for hiding this comment

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

TBH, this all looks a bit hacky, ideally, we'd know if a table's creation was staged or not and only verify the location's emptiness based on that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cla-signed iceberg Iceberg connector
Development

Successfully merging this pull request may close these issues.

[iceberg] non-staged table creation fails on non-s3-tables REST catalog
4 participants