Skip to content

Commit 910f80e

Browse files
SNOW-2221567: Fix pd.read_excel bug when reading files inside stage inner directory (#3579)
1 parent 2e42e72 commit 910f80e

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#### Bug Fixes
5050

5151
- Added an upper bound to the row estimation when the cartesian product from an align or join results in a very large number. This mitigates a performance regression.
52-
52+
- Fix a `pd.read_excel` bug when reading files inside stage inner directory.
5353

5454
## 1.34.0 (2025-07-15)
5555

src/snowflake/snowpark/modin/plugin/io/snow_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def _file_from_stage(filepath_or_buffer):
173173
with tempfile.TemporaryDirectory() as local_temp_dir:
174174
session.file.get(filepath_or_buffer, local_temp_dir)
175175
_, stripped_filepath = extract_stage_name_and_prefix(filepath_or_buffer)
176-
yield os.path.join(local_temp_dir, stripped_filepath)
176+
yield os.path.join(local_temp_dir, os.path.basename(stripped_filepath))
177177

178178

179179
class PandasOnSnowflakeIO(BaseIO):

tests/integ/modin/io/test_read_excel.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,24 @@ def test_read_excel_from_stage(session, resources_path):
5555
native_pd.read_excel(filename),
5656
check_dtype=False,
5757
)
58+
59+
60+
def test_read_excel_from_stage_inner_directory(session, resources_path):
61+
test_files = TestFiles(resources_path)
62+
63+
filename = test_files.test_file_excel
64+
65+
stage_name = Utils.random_stage_name()
66+
Utils.create_stage(session, stage_name, is_temporary=True)
67+
68+
# Upload file to inner directory in stage
69+
inner_dir = "data/excel_files"
70+
stage_path_with_dir = f"@{stage_name}/{inner_dir}"
71+
Utils.upload_to_stage(session, stage_path_with_dir, filename, compress=False)
72+
73+
with SqlCounter(query_count=2):
74+
assert_frame_equal(
75+
pd.read_excel(f"@{stage_name}/{inner_dir}/{os.path.basename(filename)}"),
76+
native_pd.read_excel(filename),
77+
check_dtype=False,
78+
)

0 commit comments

Comments
 (0)