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 64a0c7f5b7 [python] Fix Data Evolution column updates with rolled
vector files (#11085)
64a0c7f5b7 is described below
commit 64a0c7f5b70aba4b246798439cc186167c82426a
Author: QuakeWang <[email protected]>
AuthorDate: Wed Nov 11 13:34:39 2026 +0800
[python] Fix Data Evolution column updates with rolled vector files (#11085)
---
.../pypaimon/execution/python/read/split_read.py | 7 +++-
.../execution/python/write/file_store_write.py | 2 +
.../execution/python/write/row_id_file_index.py | 18 +++------
.../pypaimon/tests/multimodal_columns_test.py | 46 ++++++++++++++++++++++
4 files changed, 59 insertions(+), 14 deletions(-)
diff --git a/paimon-python/pypaimon/execution/python/read/split_read.py
b/paimon-python/pypaimon/execution/python/read/split_read.py
index 7dcc6396ba..c9908222f9 100644
--- a/paimon-python/pypaimon/execution/python/read/split_read.py
+++ b/paimon-python/pypaimon/execution/python/read/split_read.py
@@ -17,6 +17,7 @@
import os
from abc import ABC, abstractmethod
+from copy import copy
from functools import partial
from typing import Callable, Dict, List, Optional, Tuple
@@ -1730,9 +1731,11 @@ class DataEvolutionSplitRead(SplitRead):
): r]
file_record_readers[i] = MergeAllBatchReader(suppliers,
batch_size=batch_size)
else:
- # Create concatenated reader for multiple files
+ # Lazy readers must keep this bunch's projection after
+ # self.read_fields is restored to the full projection.
+ bunch_reader = copy(self)
suppliers = [
- partial(self._create_file_reader, file=file,
+ partial(bunch_reader._create_file_reader, file=file,
read_fields=read_field_names,
deletion_vector=deletion_vector) for file in
bunch.files()
]
diff --git a/paimon-python/pypaimon/execution/python/write/file_store_write.py
b/paimon-python/pypaimon/execution/python/write/file_store_write.py
index 8ecc08a592..fd3d15aa56 100644
--- a/paimon-python/pypaimon/execution/python/write/file_store_write.py
+++ b/paimon-python/pypaimon/execution/python/write/file_store_write.py
@@ -90,6 +90,8 @@ class FileStoreWrite:
max_value = CoreOptions.TARGET_FILE_ROW_NUM.default_value()
self.options.set(
CoreOptions.TARGET_FILE_SIZE, str(max_value))
+ self.options.set(
+ CoreOptions.VECTOR_TARGET_FILE_SIZE, str(max_value))
self.options.set(
CoreOptions.TARGET_FILE_ROW_NUM, str(max_value))
diff --git a/paimon-python/pypaimon/execution/python/write/row_id_file_index.py
b/paimon-python/pypaimon/execution/python/write/row_id_file_index.py
index 8eb81b3259..b4b5982286 100644
--- a/paimon-python/pypaimon/execution/python/write/row_id_file_index.py
+++ b/paimon-python/pypaimon/execution/python/write/row_id_file_index.py
@@ -68,23 +68,17 @@ class RowIdFileIndex:
files_with_row_id = [
file for file in split.files if file.first_row_id is not None
]
- data_files = [
- file for file in files_with_row_id
- if not DataFileMeta.is_blob_file(file.file_name)
- ]
- for file in split.files:
- if (
- file.first_row_id is None
- or DataFileMeta.is_blob_file(file.file_name)
- ):
+ for file in files_with_row_id:
+ # Dedicated column files can start inside their normal file's
range.
+ if DataFileMeta.is_blob_file(file.file_name) or
DataFileMeta.is_vector_file(file.file_name):
continue
- row_id_ranges.append(file.row_id_range())
- for file in data_files:
+ row_range = file.row_id_range()
+ row_id_ranges.append(row_range)
target_files = [
target_file
for target_file in files_with_row_id
if cls._overlaps(
- file.row_id_range(), target_file.row_id_range()
+ row_range, target_file.row_id_range()
)
]
diff --git a/paimon-python/pypaimon/tests/multimodal_columns_test.py
b/paimon-python/pypaimon/tests/multimodal_columns_test.py
index 572ba8f3f4..6c58e26017 100644
--- a/paimon-python/pypaimon/tests/multimodal_columns_test.py
+++ b/paimon-python/pypaimon/tests/multimodal_columns_test.py
@@ -302,6 +302,52 @@ def
test_compute_columns_reads_output_columns_and_accepts_reordered_record_batch
assert _rows(frames, ["id", "label"]) == [{"id": i + 20, "label": "old!!"}
for i in range(5)]
[email protected]_plan
[email protected]_write
[email protected]("rolled_vectors", [False, True],
ids=["aligned-input", "rolled-input"])
+def test_compute_columns_preserves_vector_file_groups(tmp_path,
rolled_vectors):
+ vector_type = pa.list_(pa.float32(), 2)
+ connection = pmm.connect(options={"warehouse": str(tmp_path)})
+ table = connection.create_table(
+ "frames",
+ schema=pa.schema([("id", pa.int64()), ("embedding", vector_type)]),
+ options={"file.format": "parquet", "vector.file.format": "parquet",
+ "vector.target-file-size": "1 b", "deletion-vectors.enabled":
"true"},
+ )
+ append_table = table.copy({"vector.target-file-size": "16 b" if
rolled_vectors else "1 mb"})
+ for start in (0, 6):
+ rows = [{"id": i, "embedding": [float(i), -1.]} for i in range(start,
start + 6)]
+ append_table.add_batches(rows[offset:offset + 2] for offset in
range(0, 6, 2))
+
+ table.delete("id = 3")
+ source = _snapshot(table)
+ files = _files(table)
+ assert sorted((file.first_row_id, file.row_count) for file in
files.values()
+ if not DataFileMeta.is_vector_file(file.file_name)) == [(0,
6), (6, 6)]
+ expected_vector_ranges = [(i, 2) for i in range(0, 12, 2)] if
rolled_vectors else [(0, 6), (6, 6)]
+ assert sorted((file.first_row_id, file.row_count) for file in
files.values()
+ if DataFileMeta.is_vector_file(file.file_name)) ==
expected_vector_ranges
+ visible_ids = [i for i in range(12) if i != 3]
+ assert _rows(table, ["id", "embedding"]) == [
+ {"id": i, "embedding": [float(i), -1.]} for i in visible_ids]
+
+ def recompute(batch):
+ return pa.table({"embedding": pa.array(
+ [[float(i), 1.] for i in batch["id"].to_pylist()],
type=vector_type)})
+
+ result = table.compute_columns("embedding", inputs=["id"], fn=recompute,
batch_size=2)
+
+ assert result.updated_rows == len(visible_ids)
+ assert result.snapshot_id == source + 1
+ assert _rows(table, ["id", "embedding"]) == [
+ {"id": i, "embedding": [float(i), 1.]} for i in visible_ids]
+ current_files = _files(table)
+ assert set(files).issubset(current_files)
+ new_files = [file for name, file in current_files.items() if name not in
files]
+ assert all(DataFileMeta.is_vector_file(file.file_name) for file in
new_files)
+ assert sorted((file.first_row_id, file.row_count) for file in new_files)
== [(0, 6), (6, 6)]
+
+
def test_compute_columns_preserves_deleted_rows_across_partitions(tmp_path):
connection = pmm.connect(options={"warehouse": str(tmp_path /
"warehouse")})
table = connection.create_table(