Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions paimon-python/pypaimon/multimodal/lance_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ def export_lance(query, uri, *, mode, blob_mode, storage_options, blob_paralleli
# A nested projection's alias may match an unrelated source column.
video_field_ids = {field.id for field in query._table.fields if field.name in video_fields}
for field in fields:
if "." in field.name:
raise ValueError(
"export_lance does not support '.' in top-level column %r; project it out." % field.name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: _validate_export_fields(query._table, fields) right below already iterates over fields to validate each output column before building the Arrow/Lance schema. Moving this if "." in field.name: check into _validate_export_fields would keep all output-field checks in one helper and avoid iterating over fields twice.

if field.id in video_field_ids:
raise ValueError("export_lance does not support video-frame column %r; project it out." % field.name)
if _contains_type(field.type, "VARIANT"):
Expand Down
13 changes: 13 additions & 0 deletions paimon-python/pypaimon/tests/multimodal_lance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,19 @@ def test_export_lance_rejects_invalid_projection_before_writing(conn, tmp_path,
assert not path.exists()


def test_export_lance_rejects_dotted_output_column_before_writing(conn, tmp_path):
table = _table(conn, "dotted_columns", {"id": pa.int32(), "next.done": pa.bool_()},
[{"id": 1, "next.done": True}])
path = tmp_path / "dotted_columns.lance"

with pytest.raises(ValueError, match=r"'next\.done'.*project it out"):
table.scan().export_lance(str(path))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Since _blob_descriptor_query_read_builder() appends predicate-only columns to internal_projection before _transform_batch strips them out, it would be nice to also verify that filtering on the dotted column while projecting it out succeeds (e.g., adding a second row {"id": 2, "next.done": False} and asserting table.scan().where("next.done = true").select(["id"]).export_lance(str(path)) exports [{"id": 1}]).


assert not path.exists()
table.scan().select(["id"]).export_lance(str(path))
assert _rows(path) == [{"id": 1}]


def test_export_lance_rejects_search_queries(conn, tmp_path):
table = _table(conn, "search", {"id": pa.int32(), "embedding": pa.list_(pa.float32(), 2)})
queries = [
Expand Down
Loading