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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to