This is an automated email from the ASF dual-hosted git repository.

JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 07aa62d25b [Table] Fix copyWithLatestSchema option drop after table 
was opened (#8026)
07aa62d25b is described below

commit 07aa62d25bd2671265e58f73fcc20266e45e102c
Author: Arnav Balyan <[email protected]>
AuthorDate: Sun May 31 19:01:23 2026 +0530

    [Table] Fix copyWithLatestSchema option drop after table was opened (#8026)
---
 .../java/org/apache/paimon/table/AbstractFileStoreTable.java  |  7 ++++---
 .../java/org/apache/paimon/table/SimpleTableTestBase.java     | 11 +++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java 
b/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java
index df42249159..23214ff05f 100644
--- 
a/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java
+++ 
b/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java
@@ -383,9 +383,10 @@ abstract class AbstractFileStoreTable implements 
FileStoreTable {
     public FileStoreTable copyWithLatestSchema() {
         Optional<TableSchema> optionalLatestSchema = schemaManager().latest();
         if (optionalLatestSchema.isPresent()) {
-            Map<String, String> options = tableSchema.options();
-            TableSchema newTableSchema = optionalLatestSchema.get();
-            newTableSchema = newTableSchema.copy(options);
+            TableSchema latestSchema = optionalLatestSchema.get();
+            Map<String, String> mergedOptions = new 
HashMap<>(latestSchema.options());
+            mergedOptions.putAll(tableSchema.options());
+            TableSchema newTableSchema = latestSchema.copy(mergedOptions);
             SchemaValidation.validateTableSchema(newTableSchema);
             return copy(newTableSchema);
         } else {
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/table/SimpleTableTestBase.java 
b/paimon-core/src/test/java/org/apache/paimon/table/SimpleTableTestBase.java
index cfdccc197e..e02c2bae1b 100644
--- a/paimon-core/src/test/java/org/apache/paimon/table/SimpleTableTestBase.java
+++ b/paimon-core/src/test/java/org/apache/paimon/table/SimpleTableTestBase.java
@@ -615,6 +615,17 @@ public abstract class SimpleTableTestBase {
                                 
"1|40|400|binary|varbinary|mapKey:mapVal|multiset|4000"));
     }
 
+    @Test
+    public void testCopyWithLatestSchemaPicksUpAlteredOptions() throws 
Exception {
+        FileStoreTable table = createFileStoreTable();
+        SchemaManager schemaManager = new SchemaManager(table.fileIO(), 
table.location());
+
+        schemaManager.commitChanges(SchemaChange.setOption("my-custom-key", 
"my-custom-value"));
+
+        FileStoreTable updated = table.copyWithLatestSchema();
+        assertThat(updated.schema().options()).containsEntry("my-custom-key", 
"my-custom-value");
+    }
+
     @Test
     public void testConsumerIdNotBlank() throws Exception {
         FileStoreTable table =

Reply via email to