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


##########
pyiceberg/table/upsert_util.py:
##########
@@ -65,7 +65,16 @@ def get_rows_to_update(source_table: pa.Table, target_table: 
pa.Table, join_cols
         # When the target table is empty, there is nothing to update :)
         return source_table.schema.empty_table()
 
-    diff_expr = functools.reduce(operator.or_, [pc.field(f"{col}-lhs") != 
pc.field(f"{col}-rhs") for col in non_key_cols])
+    diff_expr = functools.reduce(
+        operator.or_,
+        [
+            pc.or_kleene(
+                pc.not_equal(pc.field(f"{col}-lhs"), pc.field(f"{col}-rhs")),
+                pc.is_null(pc.not_equal(pc.field(f"{col}-lhs"), 
pc.field(f"{col}-rhs"))),
+            )
+            for col in non_key_cols
+        ],

Review Comment:
   This seems to fix it, but feels to complicated 🤔 
   ```suggestion
       diff_expr = functools.reduce(
           operator.or_,
           [
               pc.coalesce(
                   pc.not_equal(pc.field(f"{col}-lhs"), pc.field(f"{col}-rhs")),
                   pc.is_null(pc.field(f"{col}-lhs")) != 
pc.is_null(pc.field(f"{col}-rhs")),
               )
               for col in non_key_cols
           ],
       )
   ```



-- 
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