Skip to content

Commit 828f8eb

Browse files
authored
SNOW-2333472: More hybrid benchmark fixes (#3771)
1 parent 344ffc0 commit 828f8eb

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/snowflake/snowpark/modin/plugin/extensions/base_overrides.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
from snowflake.snowpark.modin.plugin.compiler.snowflake_query_compiler import (
7171
HYBRID_SWITCH_FOR_UNIMPLEMENTED_METHODS,
7272
)
73+
from snowflake.snowpark.modin.plugin._internal.utils import new_snow_series
7374
from snowflake.snowpark.modin.plugin.extensions.utils import (
7475
ensure_index,
7576
extract_validate_and_try_convert_named_aggs_from_kwargs,
@@ -1166,10 +1167,11 @@ def _to_series_list(self, index: pd.Index) -> list[pd.Series]:
11661167
# TODO: SNOW-1119855: Modin upgrade - modin.pandas.base.BasePandasDataset
11671168
if isinstance(index, pd.MultiIndex):
11681169
return [
1169-
pd.Series(index.get_level_values(level)) for level in range(index.nlevels)
1170+
new_snow_series(index.get_level_values(level))
1171+
for level in range(index.nlevels)
11701172
]
11711173
elif isinstance(index, pd.Index):
1172-
return [pd.Series(index)]
1174+
return [new_snow_series(index)]
11731175
else:
11741176
raise Exception("invalid index: " + str(index))
11751177

src/snowflake/snowpark/modin/plugin/extensions/dataframe_overrides.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
is_snowflake_agg_func,
7878
)
7979
from snowflake.snowpark.modin.plugin._internal.utils import (
80+
new_snow_series,
8081
add_extra_columns_and_select_required_columns,
8182
assert_fields_are_none,
8283
convert_index_to_list_of_qcs,
@@ -1827,7 +1828,7 @@ def rename(
18271828
)
18281829

18291830
if isinstance(index, dict):
1830-
index = Series(index)
1831+
index = new_snow_series(index)
18311832

18321833
new_qc = self._query_compiler.rename(
18331834
index_renamer=index, columns_renamer=columns, level=level, errors=errors

tests/integ/modin/hybrid/test_switch_operations.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,3 +608,23 @@ def test_switch_then_iloc():
608608
# Setting should similarly not error
609609
df.iloc[1, 1] = 100
610610
assert df.iloc[1, 1] == 100
611+
612+
613+
@sql_count_checker(query_count=1, join_count=1)
614+
def test_rename():
615+
# SNOW-2333472: Switching backends then performing a rename should be valid.
616+
df = pd.DataFrame([[0] * 3] * 3)
617+
assert df.get_backend() == "Pandas"
618+
assert_snowpark_pandas_equal_to_pandas(
619+
df.move_to("Snowflake").rename({0: "a", 1: "b", 2: "c"}),
620+
# Perform to_pandas first due to modin issue 7667
621+
df.to_pandas().rename({0: "a", 1: "b", 2: "c"}),
622+
)
623+
624+
625+
@sql_count_checker(query_count=1, join_count=1)
626+
def test_set_index():
627+
s = pd.Series([0]).move_to("Snowflake")
628+
# SNOW-2333472: Switching backends then setting the index should be valid.
629+
s.index = ["a"]
630+
assert_snowpark_pandas_equal_to_pandas(s, native_pd.Series([0], index=["a"]))

0 commit comments

Comments
 (0)