Fokko commented on code in PR #1693:
URL: https://github.com/apache/iceberg-python/pull/1693#discussion_r1965141158


##########
pyiceberg/table/upsert_util.py:
##########
@@ -36,7 +37,17 @@ def create_match_filter(df: pyarrow_table, join_cols: 
list[str]) -> BooleanExpre
     if len(join_cols) == 1:
         return In(join_cols[0], unique_keys[0].to_pylist())
     else:
-        return Or(*[And(*[EqualTo(col, row[col]) for col in join_cols]) for 
row in unique_keys.to_pylist()])
+        filters: List[BooleanExpression] = [
+            cast(BooleanExpression, And(*[EqualTo(col, row[col]) for col in 
join_cols])) for row in unique_keys.to_pylist()
+        ]
+
+        if not filters:
+            return In(join_cols[0], [])
+
+        if len(filters) == 1:
+            return filters[0]
+
+        return functools.reduce(lambda a, b: Or(a, b), filters)

Review Comment:
   @omkenge I've updated the suggestion, I think `AlwaysFalse()` is easier to 
interpret, what do you think?



-- 
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-unsubscr...@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to