From 58c0acb9e7e70e69c1093f5348e4c3ab67254f60 Mon Sep 17 00:00:00 2001 From: Sophie Tan Date: Thu, 7 Mar 2024 13:26:02 -0800 Subject: [PATCH] Remove unecessary dropnas (#1292) --- CHANGELOG.md | 4 ++++ src/snowflake/snowpark/mock/_plan.py | 4 ++-- tests/integ/test_dataframe.py | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 941dd101f20..19f0aaeb63c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ - Session.use_database - Session.use_role +### Bug Fixes + +- Fixed a bug in Local Testing's implementation of LEFT ANTI and LEFT SEMI joins where rows with null values are dropped. + ### Deprecations: - Deprecated `Session.get_fully_qualified_current_schema`. Consider using `Session.get_fully_qualified_name_if_possible` instead. diff --git a/src/snowflake/snowpark/mock/_plan.py b/src/snowflake/snowpark/mock/_plan.py index e53b75f3aff..f38c5376e23 100644 --- a/src/snowflake/snowpark/mock/_plan.py +++ b/src/snowflake/snowpark/mock/_plan.py @@ -854,9 +854,9 @@ def outer_join(base_df): ) sf_types = result_df.sf_types if "SEMI" in source_plan.join_type.sql: # left semi - result_df = left[outer_join(left)].dropna() + result_df = left[outer_join(left)] elif "ANTI" in source_plan.join_type.sql: # left anti - result_df = left[~outer_join(left)].dropna() + result_df = left[~outer_join(left)] elif "LEFT" in source_plan.join_type.sql: # left outer join # rows from LEFT that did not get matched unmatched_left = left[~outer_join(left)] diff --git a/tests/integ/test_dataframe.py b/tests/integ/test_dataframe.py index 6eda7ed1dab..b532bffa3fb 100644 --- a/tests/integ/test_dataframe.py +++ b/tests/integ/test_dataframe.py @@ -1193,6 +1193,12 @@ def test_join_left_anti(session): expected = [Row(3, 3), Row(4, 4)] assert sorted(res, key=lambda r: r[0]) == expected + df3 = session.create_dataframe( + [[i if i & 2 else None] for i in range(3, 8)], schema=["id"] + ) + res = df3.join(df1, "id", "leftanti").collect() + assert res == [Row(ID=None), Row(ID=None)] + @pytest.mark.localtest def test_join_left_outer(session):