-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into shobs-min-iam
- Loading branch information
Showing
7 changed files
with
99 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
tests/system/small/regression/test_issue355_merge_after_filter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import pandas as pd | ||
import pytest | ||
|
||
from tests.system.utils import assert_pandas_df_equal | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("merge_how",), | ||
[ | ||
("inner",), | ||
("outer",), | ||
("left",), | ||
("right",), | ||
], | ||
) | ||
def test_merge_after_filter(baseball_schedules_df, merge_how): | ||
on = ["awayTeamName"] | ||
left_columns = [ | ||
"gameId", | ||
"year", | ||
"homeTeamName", | ||
"awayTeamName", | ||
"duration_minutes", | ||
] | ||
right_columns = [ | ||
"gameId", | ||
"year", | ||
"homeTeamName", | ||
"awayTeamName", | ||
"duration_minutes", | ||
] | ||
|
||
left = baseball_schedules_df[left_columns] | ||
left = left[left["homeTeamName"] == "Rays"] | ||
# Offset the rows somewhat so that outer join can have an effect. | ||
right = baseball_schedules_df[right_columns] | ||
right = right[right["homeTeamName"] == "White Sox"] | ||
|
||
df = left.merge(right, on=on, how=merge_how) | ||
bf_result = df.to_pandas() | ||
|
||
left_pandas = baseball_schedules_df.to_pandas()[left_columns] | ||
left_pandas = left_pandas[left_pandas["homeTeamName"] == "Rays"] | ||
|
||
right_pandas = baseball_schedules_df.to_pandas()[right_columns] | ||
right_pandas = right_pandas[right_pandas["homeTeamName"] == "White Sox"] | ||
|
||
pd_result = pd.merge( | ||
left_pandas, | ||
right_pandas, | ||
merge_how, | ||
on, | ||
sort=True, | ||
) | ||
|
||
assert_pandas_df_equal(bf_result, pd_result, ignore_order=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters