diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java index 5297ec1cb21c..702714b253b7 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java @@ -1284,7 +1284,9 @@ public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, Con Location location = Location.of(transaction.table().location()); try { // S3 Tables internally assigns a unique location for each table - 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())) { TrinoFileSystem fileSystem = fileSystemFactory.create(session.getIdentity(), transaction.table().io().properties()); if (!replace && fileSystem.listFiles(location).hasNext()) { throw new TrinoException(ICEBERG_FILESYSTEM_ERROR, format("" +