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 31f3db7679 [python] Fix sequence numbers of rolled blob files on data 
evolution tables (#11118)
31f3db7679 is described below

commit 31f3db76793dd709f5d0d17a4b44cafb34174140
Author: Nicholas Jiang <[email protected]>
AuthorDate: Thu Nov 12 17:41:13 2026 +0800

    [python] Fix sequence numbers of rolled blob files on data evolution tables 
(#11118)
---
 .../python/write/table_update_by_row_id.py         |  3 +-
 .../execution/python/write/writer/blob_writer.py   |  9 +++-
 paimon-python/pypaimon/tests/blob_table_test.py    | 59 ++++++++++++++++++++++
 3 files changed, 67 insertions(+), 4 deletions(-)

diff --git 
a/paimon-python/pypaimon/execution/python/write/table_update_by_row_id.py 
b/paimon-python/pypaimon/execution/python/write/table_update_by_row_id.py
index 106d785dc2..7a20c6bae6 100644
--- a/paimon-python/pypaimon/execution/python/write/table_update_by_row_id.py
+++ b/paimon-python/pypaimon/execution/python/write/table_update_by_row_id.py
@@ -940,8 +940,7 @@ class PythonTableUpdateByRowId(RowIdUpdateInputMixin):
                         f"[{blob_start}, {next_blob_start - 1}] exceeds target 
range "
                         f"[{first_row_id}, {blob_end - 1}]")
                 file.first_row_id = blob_start
-                # Only update-by-row-id blob delta files use the 0/0 sentinel;
-                # regular blob writes keep their per-row sequence range.
+                # Commit replaces the 0/0 sentinel with the snapshot id.
                 file.min_sequence_number = 0
                 file.max_sequence_number = 0
                 blob_starts[blob_column] = next_blob_start
diff --git 
a/paimon-python/pypaimon/execution/python/write/writer/blob_writer.py 
b/paimon-python/pypaimon/execution/python/write/writer/blob_writer.py
index 65ea655e5a..e68bd1b290 100644
--- a/paimon-python/pypaimon/execution/python/write/writer/blob_writer.py
+++ b/paimon-python/pypaimon/execution/python/write/writer/blob_writer.py
@@ -251,8 +251,13 @@ class BlobWriter(AppendOnlyDataWriter):
             max_value_stats = [None]
             value_null_counts = [0]
 
-        min_seq = self.sequence_generator.current - row_count
-        max_seq = self.sequence_generator.current - 1
+        if self.options.data_evolution_enabled(False):
+            # Like Java, every rolled file starts at 0, so commit assigns the
+            # snapshot id to all of them.
+            min_seq, max_seq = self._append_file_sequence_range(row_count)
+        else:
+            min_seq = self.sequence_generator.current - row_count
+            max_seq = self.sequence_generator.current - 1
         self.sequence_generator.start = self.sequence_generator.current
 
         self.committed_files.append(DataFileMeta.create(
diff --git a/paimon-python/pypaimon/tests/blob_table_test.py 
b/paimon-python/pypaimon/tests/blob_table_test.py
index ce486698b8..4579392229 100755
--- a/paimon-python/pypaimon/tests/blob_table_test.py
+++ b/paimon-python/pypaimon/tests/blob_table_test.py
@@ -2435,6 +2435,65 @@ class DedicatedFormatWriterTest(unittest.TestCase):
             5: b'blob-5',
         })
 
+    def test_update_blob_column_after_rolling_write(self):
+        pa_schema = pa.schema([
+            ('id', pa.int32()),
+            ('blob_data', pa.large_binary()),
+        ])
+        schema = Schema.from_pyarrow_schema(pa_schema, options={
+            'row-tracking.enabled': 'true',
+            'data-evolution.enabled': 'true',
+            'blob.target-file-size': '1 B',
+        })
+        table_name = 'test_db.blob_update_column_after_rolling_write'
+        self.catalog.create_table(table_name, schema, False)
+        table = self.catalog.get_table(table_name)
+
+        num_rows = 10
+        wb = table.new_batch_write_builder()
+        w = wb.new_write()
+        w.write_arrow(pa.Table.from_pydict({
+            'id': list(range(num_rows)),
+            'blob_data': [f'blob-{i}'.encode() for i in range(num_rows)],
+        }, schema=pa_schema))
+        wb.new_commit().commit(w.prepare_commit())
+        w.close()
+
+        table = self.catalog.get_table(table_name)
+        snapshot_id = table.snapshot_manager().get_latest_snapshot().id
+        blob_files = [
+            f for split in table.new_read_builder().new_scan().plan().splits()
+            for f in split.files if f.file_name.endswith('.blob')
+        ]
+        self.assertEqual(len(blob_files), num_rows)
+        for f in blob_files:
+            self.assertEqual(f.min_sequence_number, snapshot_id, f.file_name)
+            self.assertEqual(f.max_sequence_number, snapshot_id, f.file_name)
+
+        update_builder = table.new_batch_write_builder()
+        table_update = update_builder.new_update().with_update_type(
+            ['blob_data'])
+        update_messages = table_update.update_by_arrow_with_row_id(
+            pa.Table.from_pydict({
+                '_ROW_ID': pa.array([2, 7], type=pa.int64()),
+                'blob_data': pa.array(
+                    [b'updated-2', b'updated-7'], type=pa.large_binary()),
+            }))
+        update_builder.new_commit().commit(update_messages)
+
+        table = self.catalog.get_table(table_name)
+        read_builder = table.new_read_builder()
+        result = read_builder.new_read().to_arrow(
+            read_builder.new_scan().plan().splits())
+        by_id = {
+            row['id']: row['blob_data']
+            for row in result.select(['id', 'blob_data']).to_pylist()
+        }
+        expected = {i: f'blob-{i}'.encode() for i in range(num_rows)}
+        expected[2] = b'updated-2'
+        expected[7] = b'updated-7'
+        self.assertEqual(by_id, expected)
+
     @pytest.mark.python_plan
     def test_blob_write_read_partition(self):
         """Test complete end-to-end blob functionality: write blob data and 
read it back to verify correctness."""

Reply via email to