@@ -713,6 +713,46 @@ def test_upsert_with_nulls(catalog: Catalog) -> None:
713713 schema = schema ,
714714 )
715715
716+ # upsert table with null value
717+ data_with_null = pa .Table .from_pylist (
718+ [
719+ {"foo" : None , "bar" : 1 , "baz" : False },
720+ ],
721+ schema = schema ,
722+ )
723+ upd = table .upsert (data_with_null , join_cols = ["foo" ])
724+ assert upd .rows_updated == 0
725+ assert upd .rows_inserted == 1
726+ assert table .scan ().to_arrow () == pa .Table .from_pylist (
727+ [
728+ {"foo" : None , "bar" : 1 , "baz" : False },
729+ {"foo" : "apple" , "bar" : 7 , "baz" : False },
730+ {"foo" : "banana" , "bar" : None , "baz" : False },
731+ ],
732+ schema = schema ,
733+ )
734+
735+ # upsert table with null and non-null values, in two join columns
736+ data_with_null = pa .Table .from_pylist (
737+ [
738+ {"foo" : None , "bar" : 1 , "baz" : True },
739+ {"foo" : "lemon" , "bar" : None , "baz" : False },
740+ ],
741+ schema = schema ,
742+ )
743+ upd = table .upsert (data_with_null , join_cols = ["foo" , "bar" ])
744+ assert upd .rows_updated == 1
745+ assert upd .rows_inserted == 1
746+ assert table .scan ().to_arrow () == pa .Table .from_pylist (
747+ [
748+ {"foo" : "lemon" , "bar" : None , "baz" : False },
749+ {"foo" : None , "bar" : 1 , "baz" : True },
750+ {"foo" : "apple" , "bar" : 7 , "baz" : False },
751+ {"foo" : "banana" , "bar" : None , "baz" : False },
752+ ],
753+ schema = schema ,
754+ )
755+
716756
717757def test_transaction (catalog : Catalog ) -> None :
718758 """Test the upsert within a Transaction. Make sure that if something fails the entire Transaction is
0 commit comments