From 7cbad6f83d8d4b6b514369e6470c536cb4760aec Mon Sep 17 00:00:00 2001 From: Naren Krishna Date: Fri, 23 Aug 2024 13:07:27 -0700 Subject: [PATCH] FIX: Fix `merge_asof` test disabled sql simplifier (#2156) 1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR. Fixes SNOW-NNNNNNN 2. Fill out the following pre-review checklist: - [ ] I am adding a new automated test(s) to verify correctness of my new code - [ ] If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing - [ ] I am adding new logging messages - [ ] I am adding a new telemetry message - [ ] I am adding new credentials - [ ] I am adding a new dependency - [ ] If this is a new feature/behavior, I'm adding the Local Testing parity changes. 3. Please describe how your code solves the related issue. Please write a short description of how your code change solves the related issue. Signed-off-by: Naren Krishna --- tests/integ/modin/test_merge_asof.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/integ/modin/test_merge_asof.py b/tests/integ/modin/test_merge_asof.py index 8f62afa7b59..681d339da90 100644 --- a/tests/integ/modin/test_merge_asof.py +++ b/tests/integ/modin/test_merge_asof.py @@ -2,6 +2,8 @@ # Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved. # +import re + import modin.pandas as pd import numpy as np import pandas as native_pd @@ -259,8 +261,10 @@ def test_merge_asof_negative_non_numeric_on(left_right_native_df_non_numeric_on) ) # pandas raises a ValueError with incompatible merge dtype with pytest.raises( - ValueError, - match="Incompatible merge dtype, dtype\\('O'\\) and dtype\\('O'\\), both sides must have numeric dtype", + MergeError, + match=re.escape( + "Incompatible merge dtype, dtype('O') and dtype('O'), both sides must have numeric dtype" + ), ): native_pd.merge_asof(left_native_df, right_native_df, on="a") # Snowpark pandas raises a SnowparkSQLException @@ -268,7 +272,7 @@ def test_merge_asof_negative_non_numeric_on(left_right_native_df_non_numeric_on) with pytest.raises( SnowparkSQLException, ): - pd.merge_asof(left_snow_df, right_snow_df, on="a") + pd.merge_asof(left_snow_df, right_snow_df, on="a").to_pandas() @sql_count_checker(query_count=0) @@ -301,14 +305,18 @@ def test_merge_asof_negative_multiple_on(left_right_native_df): right_on=["a", "another_col_right"], ) # ValueError is raised when left_on and right_on are lists not of the same length - with pytest.raises(ValueError, match=r"len\(right_on\) must equal len\(left_on\)"): + with pytest.raises( + ValueError, match=re.escape("len(right_on) must equal len(left_on)") + ): native_pd.merge_asof( left_native_df, right_native_df, left_on=["a"], right_on=["a", "another_col_right"], ) - with pytest.raises(ValueError, match=r"len\(right_on\) must equal len\(left_on\)"): + with pytest.raises( + ValueError, match=re.escape("len(right_on) must equal len(left_on)") + ): pd.merge_asof( left_snow_df, right_snow_df, @@ -316,11 +324,15 @@ def test_merge_asof_negative_multiple_on(left_right_native_df): right_on=["a", "another_col_right"], ) # ValueError is raised when left_on is a list of length > 1 and right_on is a scalar - with pytest.raises(ValueError, match=r"len\(right_on\) must equal len\(left_on\)"): + with pytest.raises( + ValueError, match=re.escape("len(right_on) must equal len(left_on)") + ): native_pd.merge_asof( left_native_df, right_native_df, left_on=["a", "another_col"], right_on="a" ) - with pytest.raises(ValueError, match=r"len\(right_on\) must equal len\(left_on\)"): + with pytest.raises( + ValueError, match=re.escape("len(right_on) must equal len(left_on)") + ): pd.merge_asof( left_snow_df, right_snow_df, left_on=["a", "another_col"], right_on="a" )