Skip to content

Commit cd1965d

Browse files
jakelong95ebyhr
authored andcommitted
Add support for object store file layout in Iceberg
1 parent bb190a0 commit cd1965d

File tree

14 files changed

+299
-34
lines changed

14 files changed

+299
-34
lines changed

docs/src/main/sphinx/connector/iceberg.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ implementation is used:
198198
- Set to `false` to disable in-memory caching of metadata files on the
199199
coordinator. This cache is not used when `fs.cache.enabled` is set to true.
200200
- `true`
201+
* - `iceberg.object-store.enabled`
202+
- Set to `true` to enable Iceberg's [object store file layout](https://iceberg.apache.org/docs/latest/aws/#object-store-file-layout).
203+
Enabling the object store file layout appends a deterministic hash directly
204+
after the data write path.
205+
- `false`
201206
* - `iceberg.expire-snapshots.min-retention`
202207
- Minimal retention period for the
203208
[`expire_snapshot` command](iceberg-expire-snapshots).
@@ -807,6 +812,8 @@ The following table properties can be updated after a table is created:
807812
- `format_version`
808813
- `partitioning`
809814
- `sorted_by`
815+
- `object_store_enabled`
816+
- `data_location`
810817

811818
For example, to update a table from v1 of the Iceberg specification to v2:
812819

@@ -869,6 +876,10 @@ connector using a {doc}`WITH </sql/create-table-as>` clause.
869876
- Comma-separated list of columns to use for Parquet bloom filter. It improves
870877
the performance of queries using Equality and IN predicates when reading
871878
Parquet files. Requires Parquet format. Defaults to `[]`.
879+
* - `object_store_enabled`
880+
- Whether Iceberg's [object store file layout](https://iceberg.apache.org/docs/latest/aws/#object-store-file-layout) is enabled.
881+
* - `data_location`
882+
- Optionally specifies the file system location URI for the table's data files
872883
* - `extra_properties`
873884
- Additional properties added to a Iceberg table. The properties are not used by Trino,
874885
and are available in the `$properties` metadata table.

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergConfig.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public class IcebergConfig
9191
private List<String> allowedExtraProperties = ImmutableList.of();
9292
private boolean incrementalRefreshEnabled = true;
9393
private boolean metadataCacheEnabled = true;
94+
private boolean objectStoreEnabled;
9495

9596
public CatalogType getCatalogType()
9697
{
@@ -519,4 +520,17 @@ public IcebergConfig setMetadataCacheEnabled(boolean metadataCacheEnabled)
519520
this.metadataCacheEnabled = metadataCacheEnabled;
520521
return this;
521522
}
523+
524+
public boolean isObjectStoreEnabled()
525+
{
526+
return objectStoreEnabled;
527+
}
528+
529+
@Config("iceberg.object-store.enabled")
530+
@ConfigDescription("Enable the Iceberg object store file layout")
531+
public IcebergConfig setObjectStoreEnabled(boolean objectStoreEnabled)
532+
{
533+
this.objectStoreEnabled = objectStoreEnabled;
534+
return this;
535+
}
522536
}

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,11 @@
267267
import static io.trino.plugin.iceberg.IcebergTableName.isIcebergTableName;
268268
import static io.trino.plugin.iceberg.IcebergTableName.isMaterializedViewStorage;
269269
import static io.trino.plugin.iceberg.IcebergTableName.tableNameFrom;
270+
import static io.trino.plugin.iceberg.IcebergTableProperties.DATA_LOCATION_PROPERTY;
270271
import static io.trino.plugin.iceberg.IcebergTableProperties.EXTRA_PROPERTIES_PROPERTY;
271272
import static io.trino.plugin.iceberg.IcebergTableProperties.FILE_FORMAT_PROPERTY;
272273
import static io.trino.plugin.iceberg.IcebergTableProperties.FORMAT_VERSION_PROPERTY;
274+
import static io.trino.plugin.iceberg.IcebergTableProperties.OBJECT_STORE_ENABLED_PROPERTY;
273275
import static io.trino.plugin.iceberg.IcebergTableProperties.PARTITIONING_PROPERTY;
274276
import static io.trino.plugin.iceberg.IcebergTableProperties.SORTED_BY_PROPERTY;
275277
import static io.trino.plugin.iceberg.IcebergTableProperties.getPartitioning;
@@ -357,6 +359,8 @@
357359
import static org.apache.iceberg.TableProperties.DELETE_ISOLATION_LEVEL;
358360
import static org.apache.iceberg.TableProperties.DELETE_ISOLATION_LEVEL_DEFAULT;
359361
import static org.apache.iceberg.TableProperties.FORMAT_VERSION;
362+
import static org.apache.iceberg.TableProperties.OBJECT_STORE_ENABLED;
363+
import static org.apache.iceberg.TableProperties.WRITE_DATA_LOCATION;
360364
import static org.apache.iceberg.TableProperties.WRITE_LOCATION_PROVIDER_IMPL;
361365
import static org.apache.iceberg.expressions.Expressions.alwaysTrue;
362366
import static org.apache.iceberg.types.TypeUtil.indexParents;
@@ -376,6 +380,8 @@ public class IcebergMetadata
376380
.add(EXTRA_PROPERTIES_PROPERTY)
377381
.add(FILE_FORMAT_PROPERTY)
378382
.add(FORMAT_VERSION_PROPERTY)
383+
.add(OBJECT_STORE_ENABLED_PROPERTY)
384+
.add(DATA_LOCATION_PROPERTY)
379385
.add(PARTITIONING_PROPERTY)
380386
.add(SORTED_BY_PROPERTY)
381387
.build();
@@ -2153,6 +2159,24 @@ public void setTableProperties(ConnectorSession session, ConnectorTableHandle ta
21532159
updateProperties.set(FORMAT_VERSION, Integer.toString(formatVersion));
21542160
}
21552161

2162+
if (properties.containsKey(OBJECT_STORE_ENABLED_PROPERTY)) {
2163+
boolean objectStoreEnabled = (boolean) properties.get(OBJECT_STORE_ENABLED_PROPERTY)
2164+
.orElseThrow(() -> new IllegalArgumentException("The object_store_enabled property cannot be empty"));
2165+
updateProperties.set(OBJECT_STORE_ENABLED, Boolean.toString(objectStoreEnabled));
2166+
}
2167+
2168+
if (properties.containsKey(DATA_LOCATION_PROPERTY)) {
2169+
String dataLocation = (String) properties.get(DATA_LOCATION_PROPERTY)
2170+
.orElseThrow(() -> new IllegalArgumentException("The data_location property cannot be empty"));
2171+
boolean objectStoreEnabled = (boolean) properties.getOrDefault(
2172+
OBJECT_STORE_ENABLED_PROPERTY,
2173+
Optional.of(Boolean.parseBoolean(icebergTable.properties().get(OBJECT_STORE_ENABLED)))).orElseThrow();
2174+
if (!objectStoreEnabled) {
2175+
throw new TrinoException(INVALID_TABLE_PROPERTY, "Data location can only be set when object store is enabled");
2176+
}
2177+
updateProperties.set(WRITE_DATA_LOCATION, dataLocation);
2178+
}
2179+
21562180
try {
21572181
updateProperties.commit();
21582182
}

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergTableProperties.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import static io.trino.plugin.iceberg.IcebergConfig.FORMAT_VERSION_SUPPORT_MAX;
3636
import static io.trino.plugin.iceberg.IcebergConfig.FORMAT_VERSION_SUPPORT_MIN;
3737
import static io.trino.spi.StandardErrorCode.INVALID_TABLE_PROPERTY;
38+
import static io.trino.spi.session.PropertyMetadata.booleanProperty;
3839
import static io.trino.spi.session.PropertyMetadata.doubleProperty;
3940
import static io.trino.spi.session.PropertyMetadata.enumProperty;
4041
import static io.trino.spi.session.PropertyMetadata.integerProperty;
@@ -58,6 +59,8 @@ public class IcebergTableProperties
5859
public static final String ORC_BLOOM_FILTER_COLUMNS_PROPERTY = "orc_bloom_filter_columns";
5960
public static final String ORC_BLOOM_FILTER_FPP_PROPERTY = "orc_bloom_filter_fpp";
6061
public static final String PARQUET_BLOOM_FILTER_COLUMNS_PROPERTY = "parquet_bloom_filter_columns";
62+
public static final String OBJECT_STORE_ENABLED_PROPERTY = "object_store_enabled";
63+
public static final String DATA_LOCATION_PROPERTY = "data_location";
6164
public static final String EXTRA_PROPERTIES_PROPERTY = "extra_properties";
6265

6366
public static final Set<String> SUPPORTED_PROPERTIES = ImmutableSet.<String>builder()
@@ -68,6 +71,8 @@ public class IcebergTableProperties
6871
.add(FORMAT_VERSION_PROPERTY)
6972
.add(ORC_BLOOM_FILTER_COLUMNS_PROPERTY)
7073
.add(ORC_BLOOM_FILTER_FPP_PROPERTY)
74+
.add(OBJECT_STORE_ENABLED_PROPERTY)
75+
.add(DATA_LOCATION_PROPERTY)
7176
.add(EXTRA_PROPERTIES_PROPERTY)
7277
.add(PARQUET_BLOOM_FILTER_COLUMNS_PROPERTY)
7378
.build();
@@ -175,6 +180,16 @@ public IcebergTableProperties(
175180
.collect(toImmutableMap(entry -> entry.getKey().toLowerCase(ENGLISH), Map.Entry::getValue));
176181
},
177182
value -> value))
183+
.add(booleanProperty(
184+
OBJECT_STORE_ENABLED_PROPERTY,
185+
"Set to true to enable Iceberg object store file layout",
186+
icebergConfig.isObjectStoreEnabled(),
187+
false))
188+
.add(stringProperty(
189+
DATA_LOCATION_PROPERTY,
190+
"File system location URI for the table's data files",
191+
null,
192+
false))
178193
.build();
179194

180195
checkState(SUPPORTED_PROPERTIES.containsAll(tableProperties.stream()
@@ -249,6 +264,16 @@ public static List<String> getParquetBloomFilterColumns(Map<String, Object> tabl
249264
return parquetBloomFilterColumns == null ? ImmutableList.of() : ImmutableList.copyOf(parquetBloomFilterColumns);
250265
}
251266

267+
public static boolean getObjectStoreEnabled(Map<String, Object> tableProperties)
268+
{
269+
return (Boolean) tableProperties.get(OBJECT_STORE_ENABLED_PROPERTY);
270+
}
271+
272+
public static Optional<String> getDataLocation(Map<String, Object> tableProperties)
273+
{
274+
return Optional.ofNullable((String) tableProperties.get(DATA_LOCATION_PROPERTY));
275+
}
276+
252277
public static Optional<Map<String, String>> getExtraProperties(Map<String, Object> tableProperties)
253278
{
254279
return Optional.ofNullable((Map<String, String>) tableProperties.get(EXTRA_PROPERTIES_PROPERTY));

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@
119119
import static io.trino.plugin.iceberg.IcebergErrorCode.ICEBERG_FILESYSTEM_ERROR;
120120
import static io.trino.plugin.iceberg.IcebergErrorCode.ICEBERG_INVALID_METADATA;
121121
import static io.trino.plugin.iceberg.IcebergErrorCode.ICEBERG_INVALID_PARTITION_VALUE;
122+
import static io.trino.plugin.iceberg.IcebergTableProperties.DATA_LOCATION_PROPERTY;
122123
import static io.trino.plugin.iceberg.IcebergTableProperties.FILE_FORMAT_PROPERTY;
123124
import static io.trino.plugin.iceberg.IcebergTableProperties.FORMAT_VERSION_PROPERTY;
124125
import static io.trino.plugin.iceberg.IcebergTableProperties.LOCATION_PROPERTY;
126+
import static io.trino.plugin.iceberg.IcebergTableProperties.OBJECT_STORE_ENABLED_PROPERTY;
125127
import static io.trino.plugin.iceberg.IcebergTableProperties.ORC_BLOOM_FILTER_COLUMNS_PROPERTY;
126128
import static io.trino.plugin.iceberg.IcebergTableProperties.ORC_BLOOM_FILTER_FPP_PROPERTY;
127129
import static io.trino.plugin.iceberg.IcebergTableProperties.PARQUET_BLOOM_FILTER_COLUMNS_PROPERTY;
@@ -159,6 +161,7 @@
159161
import static io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_TZ_MICROS;
160162
import static io.trino.spi.type.Timestamps.PICOSECONDS_PER_MICROSECOND;
161163
import static io.trino.spi.type.UuidType.javaUuidToTrinoUuid;
164+
import static java.lang.Boolean.parseBoolean;
162165
import static java.lang.Double.parseDouble;
163166
import static java.lang.Float.floatToRawIntBits;
164167
import static java.lang.Float.parseFloat;
@@ -173,13 +176,11 @@
173176
import static org.apache.iceberg.TableProperties.FORMAT_VERSION;
174177
import static org.apache.iceberg.TableProperties.OBJECT_STORE_ENABLED;
175178
import static org.apache.iceberg.TableProperties.OBJECT_STORE_ENABLED_DEFAULT;
176-
import static org.apache.iceberg.TableProperties.OBJECT_STORE_PATH;
177179
import static org.apache.iceberg.TableProperties.ORC_BLOOM_FILTER_COLUMNS;
178180
import static org.apache.iceberg.TableProperties.ORC_BLOOM_FILTER_FPP;
179181
import static org.apache.iceberg.TableProperties.PARQUET_BLOOM_FILTER_COLUMN_ENABLED_PREFIX;
180182
import static org.apache.iceberg.TableProperties.WRITE_DATA_LOCATION;
181183
import static org.apache.iceberg.TableProperties.WRITE_LOCATION_PROVIDER_IMPL;
182-
import static org.apache.iceberg.TableProperties.WRITE_METADATA_LOCATION;
183184
import static org.apache.iceberg.types.Type.TypeID.BINARY;
184185
import static org.apache.iceberg.types.Type.TypeID.FIXED;
185186
import static org.apache.iceberg.util.LocationUtil.stripTrailingSlash;
@@ -334,6 +335,13 @@ public static Map<String, Object> getIcebergTableProperties(Table icebergTable)
334335
properties.put(PARQUET_BLOOM_FILTER_COLUMNS_PROPERTY, ImmutableList.copyOf(parquetBloomFilterColumns));
335336
}
336337

338+
if (parseBoolean(icebergTable.properties().getOrDefault(OBJECT_STORE_ENABLED, "false"))) {
339+
properties.put(OBJECT_STORE_ENABLED_PROPERTY, true);
340+
}
341+
342+
Optional<String> dataLocation = Optional.ofNullable(icebergTable.properties().get(WRITE_DATA_LOCATION));
343+
dataLocation.ifPresent(location -> properties.put(DATA_LOCATION_PROPERTY, location));
344+
337345
return properties.buildOrThrow();
338346
}
339347

@@ -842,6 +850,18 @@ public static Map<String, String> createTableProperties(ConnectorTableMetadata t
842850
propertiesBuilder.put(DEFAULT_FILE_FORMAT, fileFormat.toIceberg().toString());
843851
propertiesBuilder.put(FORMAT_VERSION, Integer.toString(IcebergTableProperties.getFormatVersion(tableMetadata.getProperties())));
844852

853+
boolean objectStoreEnabled = IcebergTableProperties.getObjectStoreEnabled(tableMetadata.getProperties());
854+
if (objectStoreEnabled) {
855+
propertiesBuilder.put(OBJECT_STORE_ENABLED, "true");
856+
}
857+
Optional<String> dataLocation = IcebergTableProperties.getDataLocation(tableMetadata.getProperties());
858+
dataLocation.ifPresent(location -> {
859+
if (!objectStoreEnabled) {
860+
throw new TrinoException(INVALID_TABLE_PROPERTY, "Data location can only be set when object store is enabled");
861+
}
862+
propertiesBuilder.put(WRITE_DATA_LOCATION, location);
863+
});
864+
845865
// iceberg ORC format bloom filter properties used by create table
846866
List<String> orcBloomFilterColumns = IcebergTableProperties.getOrcBloomFilterColumns(tableMetadata.getProperties());
847867
if (!orcBloomFilterColumns.isEmpty()) {
@@ -965,17 +985,6 @@ public static long getSnapshotIdAsOfTime(Table table, long epochMillis)
965985
.snapshotId();
966986
}
967987

968-
public static void validateTableCanBeDropped(Table table)
969-
{
970-
// TODO: support path override in Iceberg table creation: https://github.com/trinodb/trino/issues/8861
971-
if (table.properties().containsKey(OBJECT_STORE_PATH) ||
972-
table.properties().containsKey("write.folder-storage.path") || // Removed from Iceberg as of 0.14.0, but preserved for backward compatibility
973-
table.properties().containsKey(WRITE_METADATA_LOCATION) ||
974-
table.properties().containsKey(WRITE_DATA_LOCATION)) {
975-
throw new TrinoException(NOT_SUPPORTED, "Table contains Iceberg path override properties and cannot be dropped from Trino: " + table.name());
976-
}
977-
}
978-
979988
private static void checkFormatForProperty(FileFormat actualStorageFormat, FileFormat expectedStorageFormat, String propertyName)
980989
{
981990
if (actualStorageFormat != expectedStorageFormat) {

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/TrinoGlueCatalog.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@
149149
import static io.trino.plugin.iceberg.IcebergUtil.getIcebergTableWithMetadata;
150150
import static io.trino.plugin.iceberg.IcebergUtil.getTableComment;
151151
import static io.trino.plugin.iceberg.IcebergUtil.quotedTableName;
152-
import static io.trino.plugin.iceberg.IcebergUtil.validateTableCanBeDropped;
153152
import static io.trino.plugin.iceberg.TableType.MATERIALIZED_VIEW_STORAGE;
154153
import static io.trino.plugin.iceberg.TrinoMetricsReporter.TRINO_METRICS_REPORTER;
155154
import static io.trino.plugin.iceberg.catalog.glue.GlueIcebergUtil.getMaterializedViewTableInput;
@@ -674,7 +673,6 @@ private Optional<List<ColumnMetadata>> getCachedColumnMetadata(com.amazonaws.ser
674673
public void dropTable(ConnectorSession session, SchemaTableName schemaTableName)
675674
{
676675
BaseTable table = (BaseTable) loadTable(session, schemaTableName);
677-
validateTableCanBeDropped(table);
678676
try {
679677
deleteTable(schemaTableName.getSchemaName(), schemaTableName.getTableName());
680678
}

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/TrinoHiveCatalog.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
import static io.trino.plugin.iceberg.IcebergUtil.getIcebergTableWithMetadata;
104104
import static io.trino.plugin.iceberg.IcebergUtil.loadIcebergTable;
105105
import static io.trino.plugin.iceberg.IcebergUtil.quotedTableName;
106-
import static io.trino.plugin.iceberg.IcebergUtil.validateTableCanBeDropped;
107106
import static io.trino.plugin.iceberg.TableType.MATERIALIZED_VIEW_STORAGE;
108107
import static io.trino.plugin.iceberg.TrinoMetricsReporter.TRINO_METRICS_REPORTER;
109108
import static io.trino.plugin.iceberg.catalog.AbstractIcebergTableOperations.ICEBERG_METASTORE_STORAGE_FORMAT;
@@ -385,7 +384,6 @@ public void dropTable(ConnectorSession session, SchemaTableName schemaTableName)
385384
{
386385
BaseTable table = (BaseTable) loadTable(session, schemaTableName);
387386
TableMetadata metadata = table.operations().current();
388-
validateTableCanBeDropped(table);
389387

390388
io.trino.metastore.Table metastoreTable = metastore.getTable(schemaTableName.getSchemaName(), schemaTableName.getTableName())
391389
.orElseThrow(() -> new TableNotFoundException(schemaTableName));

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/jdbc/TrinoJdbcCatalog.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
import static io.trino.plugin.iceberg.IcebergSchemaProperties.LOCATION_PROPERTY;
8282
import static io.trino.plugin.iceberg.IcebergUtil.getIcebergTableWithMetadata;
8383
import static io.trino.plugin.iceberg.IcebergUtil.loadIcebergTable;
84-
import static io.trino.plugin.iceberg.IcebergUtil.validateTableCanBeDropped;
8584
import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED;
8685
import static java.lang.String.format;
8786
import static java.util.Locale.ENGLISH;
@@ -319,7 +318,6 @@ public void unregisterTable(ConnectorSession session, SchemaTableName tableName)
319318
public void dropTable(ConnectorSession session, SchemaTableName schemaTableName)
320319
{
321320
BaseTable table = (BaseTable) loadTable(session, schemaTableName);
322-
validateTableCanBeDropped(table);
323321

324322
jdbcCatalog.dropTable(toIdentifier(schemaTableName), false);
325323
try {

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/nessie/TrinoNessieCatalog.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
import static io.trino.plugin.iceberg.IcebergSchemaProperties.LOCATION_PROPERTY;
6565
import static io.trino.plugin.iceberg.IcebergUtil.getIcebergTableWithMetadata;
6666
import static io.trino.plugin.iceberg.IcebergUtil.quotedTableName;
67-
import static io.trino.plugin.iceberg.IcebergUtil.validateTableCanBeDropped;
6867
import static io.trino.plugin.iceberg.catalog.nessie.IcebergNessieUtil.toIdentifier;
6968
import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED;
7069
import static io.trino.spi.connector.SchemaTableName.schemaTableName;
@@ -232,8 +231,7 @@ public Map<SchemaTableName, List<ColumnMetadata>> tryGetColumnMetadata(Connector
232231
@Override
233232
public void dropTable(ConnectorSession session, SchemaTableName schemaTableName)
234233
{
235-
BaseTable table = (BaseTable) loadTable(session, schemaTableName);
236-
validateTableCanBeDropped(table);
234+
loadTable(session, schemaTableName);
237235
nessieClient.dropTable(toIdentifier(schemaTableName), true);
238236
// The table folder may be referenced by other branches. Therefore, dropping the table should not delete the data.
239237
// Nessie GC tool can be used to clean up the expired data.

plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8536,6 +8536,34 @@ public void testSetIllegalExtraPropertyKey()
85368536
}
85378537
}
85388538

8539+
@Test
8540+
public void testObjectStoreEnabledAndDataLocation()
8541+
throws Exception
8542+
{
8543+
String tableName = "test_object_store_enabled_data_location" + randomNameSuffix();
8544+
assertUpdate("CREATE TABLE " + tableName + " WITH (object_store_enabled = true, data_location = 'local:///data-location/xyz') AS SELECT 1 AS val", 1);
8545+
8546+
Location tableLocation = Location.of(getTableLocation(tableName));
8547+
assertThat(fileSystem.directoryExists(tableLocation).get()).isTrue();
8548+
8549+
String filePath = (String) computeScalar("SELECT file_path FROM \"" + tableName + "$files\"");
8550+
Location dataFileLocation = Location.of(filePath);
8551+
assertThat(fileSystem.newInputFile(dataFileLocation).exists()).isTrue();
8552+
assertThat(filePath).matches("local:///data-location/xyz/.{6}/tpch/%s.*".formatted(tableName));
8553+
8554+
assertUpdate("DROP TABLE " + tableName);
8555+
assertThat(fileSystem.newInputFile(dataFileLocation).exists()).isFalse();
8556+
assertThat(fileSystem.newInputFile(tableLocation).exists()).isFalse();
8557+
}
8558+
8559+
@Test
8560+
public void testCreateTableWithDataLocationButObjectStoreDisabled()
8561+
{
8562+
assertQueryFails(
8563+
"CREATE TABLE test_data_location WITH (data_location = 'local:///data-location/xyz') AS SELECT 1 AS val",
8564+
"Data location can only be set when object store is enabled");
8565+
}
8566+
85398567
@Override
85408568
protected Optional<SetColumnTypeSetup> filterSetColumnTypesDataProvider(SetColumnTypeSetup setup)
85418569
{

0 commit comments

Comments
 (0)