omkenge commented on code in PR #1693: URL: https://github.com/apache/iceberg-python/pull/1693#discussion_r1965130816
########## 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: I think , Returning In(join_cols[0], []) is correct because it results in a predicate that is always false, so no target row matches the update condition. Returning AlwaysTrue() would be wrong because it would match every row in the target, causing an unintended update of all rows. What do you thing? -- 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