Skip to content

Commit

Permalink
FIX: Fix merge_asof test disabled sql simplifier (#2156)
Browse files Browse the repository at this point in the history
<!---
Please answer these questions before creating your pull request. Thanks!
--->

1. Which Jira issue is this PR addressing? Make sure that there is an
accompanying issue to your PR.

   <!---
   In this section, please add a Snowflake Jira issue number.
   
Note that if a corresponding GitHub issue exists, you should still
include
   the Snowflake Jira issue number. For example, for GitHub issue
#1400, you should
   add "SNOW-1335071" here.
    --->

   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 <[email protected]>
  • Loading branch information
sfc-gh-nkrishna authored Aug 23, 2024
1 parent c040c8f commit 7cbad6f
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions tests/integ/modin/test_merge_asof.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -259,16 +261,18 @@ 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
# MATCH_CONDITION clause is invalid: The left and right side expressions must be numeric or timestamp expressions.
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)
Expand Down Expand Up @@ -301,26 +305,34 @@ 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,
left_on=["a"],
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"
)
Expand Down

0 comments on commit 7cbad6f

Please sign in to comment.