This is an automated email from the ASF dual-hosted git repository.
pvary pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/main by this push:
new f723526ca7 Hive: Write format-version to HMS table parameters (#18534)
f723526ca7 is described below
commit f723526ca7b3bc2eeacba3a47cbec5f018bd4679
Author: Anurag Mantripragada <[email protected]>
AuthorDate: Tue Oct 20 02:30:08 2026 -0700
Hive: Write format-version to HMS table parameters (#18534)
---
.../iceberg/hive/HMSTablePropertyHelper.java | 1 +
.../org/apache/iceberg/hive/TestHiveCatalog.java | 49 ++++++++++++++++++++++
2 files changed, 50 insertions(+)
diff --git
a/hive-metastore/src/main/java/org/apache/iceberg/hive/HMSTablePropertyHelper.java
b/hive-metastore/src/main/java/org/apache/iceberg/hive/HMSTablePropertyHelper.java
index 494bd80894..aee2fb04f1 100644
---
a/hive-metastore/src/main/java/org/apache/iceberg/hive/HMSTablePropertyHelper.java
+++
b/hive-metastore/src/main/java/org/apache/iceberg/hive/HMSTablePropertyHelper.java
@@ -110,6 +110,7 @@ public class HMSTablePropertyHelper {
maxHiveTablePropertySize);
setStorageHandler(parameters, hiveEngineEnabled);
setMetadataHash(metadata, parameters);
+ parameters.put(TableProperties.FORMAT_VERSION,
String.valueOf(metadata.formatVersion()));
// Set the basic statistics
if (summary.get(SnapshotSummary.TOTAL_DATA_FILES_PROP) != null) {
diff --git
a/hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
b/hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
index 58a45e68db..36f6a35098 100644
--- a/hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
+++ b/hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
@@ -94,6 +94,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.FieldSource;
import org.junit.jupiter.params.provider.ValueSource;
/**
@@ -994,6 +995,54 @@ public class TestHiveCatalog extends
CatalogTests<HiveCatalog> {
}
}
+ @ParameterizedTest
+ @FieldSource("org.apache.iceberg.TestHelpers#ALL_VERSIONS")
+ void formatVersionInTableParametersOnCreate(int formatVersion) throws
Exception {
+ Schema schema = getTestSchema();
+ TableIdentifier tableIdentifier = TableIdentifier.of(DB_NAME, "tbl");
+ String location = temp.resolve("tbl").toUri().toString();
+
+ try {
+ catalog
+ .buildTable(tableIdentifier, schema)
+ .withLocation(location)
+ .withProperty(TableProperties.FORMAT_VERSION,
String.valueOf(formatVersion))
+ .create();
+
+ assertThat(hmsTableParameters())
+ .containsEntry(TableProperties.FORMAT_VERSION,
String.valueOf(formatVersion));
+ } finally {
+ catalog.dropTable(tableIdentifier);
+ }
+ }
+
+ @Test
+ void formatVersionInTableParametersOnUpgrade() throws Exception {
+ Schema schema = getTestSchema();
+ TableIdentifier tableIdentifier = TableIdentifier.of(DB_NAME, "tbl");
+ String location = temp.resolve("tbl").toString();
+ int upgradedFormatVersion = 3;
+
+ try {
+ catalog
+ .buildTable(tableIdentifier, schema)
+ .withLocation(location)
+ .withProperty(TableProperties.FORMAT_VERSION, "2")
+ .create();
+
+ catalog
+ .loadTable(tableIdentifier)
+ .updateProperties()
+ .set(TableProperties.FORMAT_VERSION,
String.valueOf(upgradedFormatVersion))
+ .commit();
+
+ assertThat(hmsTableParameters())
+ .containsEntry(TableProperties.FORMAT_VERSION,
String.valueOf(upgradedFormatVersion));
+ } finally {
+ catalog.dropTable(tableIdentifier);
+ }
+ }
+
@Test
public void testSnapshotStatsTableProperties() throws Exception {
Schema schema = getTestSchema();