Skip to content

Commit fe57ea1

Browse files
committed
Add location propertiesfrom TableMetadata into Table entity internalProperties
1 parent 8ba112e commit fe57ea1

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,18 @@ private String newTableMetadataFilePath(TableMetadata meta, int newVersion) {
16571657

16581658
private static Map<String, String> buildTableMetadataPropertiesMap(TableMetadata metadata) {
16591659
Map<String, String> storedProperties = new HashMap<>();
1660+
// Location specific properties
16601661
storedProperties.put(IcebergTableLikeEntity.LOCATION, metadata.location());
1662+
if (metadata.properties().containsKey(TableProperties.WRITE_DATA_LOCATION)) {
1663+
storedProperties.put(
1664+
IcebergTableLikeEntity.USER_SPECIFIED_WRITE_DATA_LOCATION_KEY,
1665+
metadata.properties().get(TableProperties.WRITE_DATA_LOCATION));
1666+
}
1667+
if (metadata.properties().containsKey(TableProperties.WRITE_METADATA_LOCATION)) {
1668+
storedProperties.put(
1669+
IcebergTableLikeEntity.USER_SPECIFIED_WRITE_METADATA_LOCATION_KEY,
1670+
metadata.properties().get(TableProperties.WRITE_METADATA_LOCATION));
1671+
}
16611672
storedProperties.put(
16621673
IcebergTableLikeEntity.FORMAT_VERSION, String.valueOf(metadata.formatVersion()));
16631674
storedProperties.put(IcebergTableLikeEntity.TABLE_UUID, metadata.uuid());

runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/AbstractIcebergCatalogTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
import org.apache.iceberg.TableMetadata;
7373
import org.apache.iceberg.TableMetadataParser;
7474
import org.apache.iceberg.TableOperations;
75+
import org.apache.iceberg.TableProperties;
7576
import org.apache.iceberg.UpdateRequirement;
7677
import org.apache.iceberg.UpdateRequirements;
7778
import org.apache.iceberg.UpdateSchema;
@@ -2269,6 +2270,16 @@ public void testTableInternalPropertiesStoredOnCommit() {
22692270
catalog.createNamespace(NS);
22702271
catalog.buildTable(TABLE, SCHEMA).create();
22712272
catalog.loadTable(TABLE).newFastAppend().appendFile(FILE_A).commit();
2273+
catalog
2274+
.loadTable(TABLE)
2275+
.updateProperties()
2276+
.set(
2277+
TableProperties.WRITE_DATA_LOCATION,
2278+
"s3://my-bucket/path/to/data/newdb/newtable/my-data")
2279+
.set(
2280+
TableProperties.WRITE_METADATA_LOCATION,
2281+
"s3://my-bucket/path/to/data/newdb/newtable/my-metadata")
2282+
.commit();
22722283
Table afterAppend = catalog.loadTable(TABLE);
22732284
EntityResult schemaResult =
22742285
metaStoreManager.readEntityByName(
@@ -2295,6 +2306,12 @@ public void testTableInternalPropertiesStoredOnCommit() {
22952306
IcebergTableLikeEntity.CURRENT_SNAPSHOT_ID,
22962307
String.valueOf(afterAppend.currentSnapshot().snapshotId()))
22972308
.containsEntry(IcebergTableLikeEntity.LOCATION, afterAppend.location())
2309+
.containsEntry(
2310+
IcebergTableLikeEntity.USER_SPECIFIED_WRITE_DATA_LOCATION_KEY,
2311+
afterAppend.properties().get(TableProperties.WRITE_DATA_LOCATION))
2312+
.containsEntry(
2313+
IcebergTableLikeEntity.USER_SPECIFIED_WRITE_METADATA_LOCATION_KEY,
2314+
afterAppend.properties().get(TableProperties.WRITE_METADATA_LOCATION))
22982315
.containsEntry(IcebergTableLikeEntity.TABLE_UUID, afterAppend.uuid().toString())
22992316
.containsEntry(
23002317
IcebergTableLikeEntity.CURRENT_SCHEMA_ID,

0 commit comments

Comments
 (0)