From b356ba8fb6b2197d16c771b414f84dde75492775 Mon Sep 17 00:00:00 2001 From: Marco van den Boom Date: Sat, 19 Oct 2024 15:59:37 +0200 Subject: [PATCH] fix SNOW-1753336 --- CHANGELOG.md | 19 ++++++--------- src/snowflake/snowpark/mock/_connection.py | 2 +- .../scala/test_update_delete_merge_suite.py | 24 +++++++++++++++++++ 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b34963b20..190502f5cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,9 +51,14 @@ #### Bug Fixes - Fixed a bug where `DataFrame.alias` raises `KeyError` for input column name. - -#### Bug Fixes - Fixed a bug where `to_csv` on Snowflake stage fails when data contains empty strings. +- Fixed a bug where nullable columns were annotated wrongly. +- Fixed a bug where the `date_add` and `date_sub` functions failed for `NULL` values. +- Fixed a bug where `equal_null` could fail inside a merge statement. +- Fixed a bug where `row_number` could fail inside a Window function. +- Fixed a bug where `Table.update` and `Table.merge` could fail if the target table's + index was not the default `RangeIndex`. + ## 1.23.0 (2024-10-09) @@ -121,16 +126,6 @@ - Fixed a bug where `pd.to_numeric()` would leave `Timedelta` inputs as `Timedelta` instead of converting them to integers. - Fixed `loc` set when setting a single row, or multiple rows, of a DataFrame with a Series value. -### Snowpark Local Testing Updates - -#### Bug Fixes - -- Fixed a bug where nullable columns were annotated wrongly. -- Fixed a bug where the `date_add` and `date_sub` functions failed for `NULL` values. -- Fixed a bug where `equal_null` could fail inside a merge statement. -- Fixed a bug where `row_number` could fail inside a Window function. -- Fixed a bug where updates could fail when the source is the result of a join. - ## 1.22.1 (2024-09-11) This is a re-release of 1.22.0. Please refer to the 1.22.0 release notes for detailed release content. diff --git a/src/snowflake/snowpark/mock/_connection.py b/src/snowflake/snowpark/mock/_connection.py index 37a2d77a44..af660c0133 100644 --- a/src/snowflake/snowpark/mock/_connection.py +++ b/src/snowflake/snowpark/mock/_connection.py @@ -120,7 +120,7 @@ def read_table(self, name: Union[str, Iterable[str]]) -> TableEmulator: name, current_schema, current_database ) if qualified_name in self.table_registry: - return copy(self.table_registry[qualified_name]) + return copy(self.table_registry[qualified_name].reset_index(drop=True)) else: raise SnowparkLocalTestingException( f"Object '{name}' does not exist or not authorized." diff --git a/tests/integ/scala/test_update_delete_merge_suite.py b/tests/integ/scala/test_update_delete_merge_suite.py index a01f6a1ac5..b20e1dea87 100644 --- a/tests/integ/scala/test_update_delete_merge_suite.py +++ b/tests/integ/scala/test_update_delete_merge_suite.py @@ -696,3 +696,27 @@ def test_snow_1694649_repro_merge_with_equal_null(session): Row(0, "a"), Row(1, "b"), ] + + +@pytest.mark.skipif( + not installed_pandas, + reason="Test requires pandas.", +) +def test_snow_1707286_repro_merge_with_(session): + import pandas as pd + + df1 = session.create_dataframe(pd.DataFrame({"A": [1, 2, 3, 4, 5]})) + df2 = session.create_dataframe(pd.DataFrame({"A": [3, 4]})) + + table = df1.where(col("A") > 2).cache_result() + + table.update( + assignments={"A": lit(9)}, + condition=table["A"] == df2["A"], + source=df2, + ) + assert table.order_by("A").collect() == [ + Row(0, "9"), + Row(1, "9"), + Row(2, "5"), + ]