plusplusjiajia commented on code in PR #8136:
URL: https://github.com/apache/paimon/pull/8136#discussion_r3553031959
##########
paimon-python/pypaimon/read/table_scan.py:
##########
@@ -42,17 +42,94 @@ def __init__(
self.predicate = predicate
self.limit = limit
self.partition_predicate = partition_predicate
+ self._read_type = None
+ self._query_auth_fn = self.table.catalog_environment.table_query_auth(
+ self.table.options, self.table.identifier)
self.file_scanner = self._create_file_scanner()
def plan(self) -> Plan:
- return self.file_scanner.scan()
+ auth_result = self._auth_query()
+ if auth_result is not None:
+ self._apply_auth_to_scanner(auth_result)
+ plan = self.file_scanner.scan()
+ if auth_result is not None:
+ plan = auth_result.convert_plan(plan)
+ return plan
+
+ def _apply_auth_to_scanner(self, auth_result):
+ if not auth_result.filter:
+ return
+ partition_preds, has_non_partition =
self._split_auth_filter(auth_result)
+ if partition_preds:
+ from pypaimon.common.predicate_builder import PredicateBuilder
+ combined = PredicateBuilder.and_predicates(partition_preds)
+ self.file_scanner.auth_partition_predicate = combined
+ if has_non_partition:
+ self.file_scanner.auth_has_non_partition_filter = True
+
+ def _split_auth_filter(self, auth_result):
+ partition_keys = set(self.table.partition_keys or [])
+ if not partition_keys:
+ return [], bool(auth_result.filter)
+
+ partition_preds = []
+ has_non_partition = False
+ field_index_map = {f.name: i for i, f in enumerate(self.table.fields)}
Review Comment:
When query auth returns a partition-column filter for a table whose
partition column is not in the same position as the partition row, this uses
full table field positions but later tests the predicate against
entry.partition, which only contains partition fields. For common layouts like
id, name, dtpart PARTITIONED BY (dtpart), the generated index is out of range
or points to the wrong partition key, so scan planning can fail or prune
visible splits before the auth reader runs.
--
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]