You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "JingsongLi (via GitHub)" <gi...@apache.org> on 2025/10/16 15:09:20 UTC

[PR] [python] Filter manifest files by partition predicate in scan [paimon]

JingsongLi opened a new pull request, #6419:
URL: https://github.com/apache/paimon/pull/6419

   <!-- Please specify the module before the PR name: [core] ... or [flink] ... -->
   
   ### Purpose
   
   <!-- Linking this pull request to the issue -->
   Fix TODO.
   
   <!-- What is the purpose of the change -->
   
   ### Tests
   
   <!-- List UT and IT cases to verify this change -->
   
   ### API and Format
   
   <!-- Does this change affect API or storage format -->
   
   ### Documentation
   
   <!-- Does this change introduce a new feature -->
   


-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [python] Filter manifest files by partition predicate in scan [paimon]

Posted by "chenghuichen (via GitHub)" <gi...@apache.org>.
chenghuichen commented on code in PR #6419:
URL: https://github.com/apache/paimon/pull/6419#discussion_r2438049269


##########
paimon-python/pypaimon/read/push_down_utils.py:
##########
@@ -21,6 +21,50 @@
 from pypaimon.common.predicate import Predicate
 
 
+def to_partition_predicate(input_predicate: 'Predicate', all_fields: List[str], partition_keys: List[str]):
+    if not input_predicate or not partition_keys:
+        return None
+
+    predicates: list['Predicate'] = split_and(input_predicate)
+    predicates = [element for element in predicates if _get_all_fields(element).issubset(partition_keys)]
+    new_predicate = Predicate(
+        method='and',
+        index=None,
+        field=None,
+        literals=predicates
+    )
+
+    part_to_index = {element: idx for idx, element in enumerate(partition_keys)}
+    mapping: Dict[int, int] = {
+        i: part_to_index.get(all_fields[i], -1)
+        for i in range(len(all_fields))
+    }
+
+    return change_index(new_predicate, mapping)
+
+
+def split_and(input_predicate: 'Predicate'):

Review Comment:
   Consider making `split_and` and `change_index` private — they’re not part of push_down_utils’ public API.



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [python] Filter manifest files by partition predicate in scan [paimon]

Posted by "chenghuichen (via GitHub)" <gi...@apache.org>.
chenghuichen commented on code in PR #6419:
URL: https://github.com/apache/paimon/pull/6419#discussion_r2438049269


##########
paimon-python/pypaimon/read/push_down_utils.py:
##########
@@ -21,6 +21,50 @@
 from pypaimon.common.predicate import Predicate
 
 
+def to_partition_predicate(input_predicate: 'Predicate', all_fields: List[str], partition_keys: List[str]):
+    if not input_predicate or not partition_keys:
+        return None
+
+    predicates: list['Predicate'] = split_and(input_predicate)
+    predicates = [element for element in predicates if _get_all_fields(element).issubset(partition_keys)]
+    new_predicate = Predicate(
+        method='and',
+        index=None,
+        field=None,
+        literals=predicates
+    )
+
+    part_to_index = {element: idx for idx, element in enumerate(partition_keys)}
+    mapping: Dict[int, int] = {
+        i: part_to_index.get(all_fields[i], -1)
+        for i in range(len(all_fields))
+    }
+
+    return change_index(new_predicate, mapping)
+
+
+def split_and(input_predicate: 'Predicate'):

Review Comment:
   Consider making split_and and change_index private functions (by prefixing with an underscore) to improve the readability and clarity of this utility module.
   
   



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [python] Filter manifest files by partition predicate in scan [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #6419:
URL: https://github.com/apache/paimon/pull/6419


-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org