Stephen0421 commented on code in PR #9148: URL: https://github.com/apache/paimon/pull/9148#discussion_r3790819538
########## paimon-python/pypaimon/read/reader/blob_view_read_support.py: ########## @@ -0,0 +1,65 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Helpers for eager blob-view/descriptor inline conversion on read.""" + +from typing import List + +from pypaimon.common.options.core_options import CoreOptions +from pypaimon.read.reader.iface.record_reader import RecordReader +from pypaimon.schema.data_types import DataField, PyarrowFieldParser + + +def needs_blob_inline_convert(table) -> bool: + view_fields = CoreOptions.blob_view_fields(table.options) + descriptor_fields = CoreOptions.blob_descriptor_fields(table.options) + if descriptor_fields: + # Materialize when blob-as-descriptor=false; otherwise still wrap so + # merge to_iterator()+get_blob() receives descriptor field metadata. + return True + if not view_fields: + return False + if CoreOptions.blob_as_descriptor(table.options): + return True + return CoreOptions.blob_view_resolve_enabled(table.options) + + +def wrap_record_reader_with_blob_inline_convert( + reader: RecordReader, + split_read, + read_fields: List[DataField], +) -> RecordReader: + from pypaimon.read.reader.auth_masking_reader import ( + BatchToRecordReaderAdapter, RecordReaderToBatchAdapter) + from pypaimon.read.reader.blob_descriptor_convert_reader import BlobInlineConvertReader + from pypaimon.read.reader.field_indices import ( + blob_field_indices, descriptor_field_indices_for_table, vector_field_indices) + + schema = PyarrowFieldParser.from_paimon_schema(read_fields) + batch_reader = RecordReaderToBatchAdapter(reader, schema) Review Comment: Fixed. The merge wrap round-trip now sets `include_row_kind=True` so `BatchToRecordReaderAdapter` restores the original kind instead of defaulting to `-U`. Added coverage for `+I` / `-U` / `+U` / `-D` (`test_wrap_record_reader_preserves_all_row_kinds`). ########## paimon-python/pypaimon/read/split_read.py: ########## @@ -1017,16 +1083,25 @@ def create_reader(self) -> RecordReader: reader = FilterRecordReader(kv_unwrap_reader, self.predicate_for_reader) else: reader = kv_unwrap_reader + value_fields = self.read_fields[-self.value_arity:] + if self._needs_blob_inline_convert() and not self._blob_view_prescan: + reader = wrap_record_reader_with_blob_inline_convert( + reader, self, value_fields) Review Comment: Fixed. Merge now applies LIMIT before inline convert when the nested-leaf predicate is not re-applied after projection, so descriptors/views are not materialized past LIMIT. Prescan LIMIT is skipped when a predicate or auth filter is present (same as DataEvolution), because prescan only projects view columns and the filtered first-N would otherwise miss the lookup. Added LIMIT-only materialize coverage, DataEvolution predicate+LIMIT, and a RawFileSplitRead predicate+LIMIT regression (`id == 9` with `LIMIT 1`). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
