Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1348457:Fix Reading files from Stage with Snowpark.session.read + INFER_SCHEMA option causes an error if the filename has a whitespace #1449

Merged
merged 5 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#### Bug Fixes

- Fixed a bug that caused NaT and NaN values to not be recognized.
- Fixed a bug when inferring schema, single quotes are added to stage files already have single quotes.


## 1.15.0 (2024-04-24)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,9 +871,7 @@ def infer_schema_statement(path: str, file_format_name: str) -> str:
+ LEFT_PARENTHESIS
+ LOCATION
+ RIGHT_ARROW
+ SINGLE_QUOTE
+ path
+ SINGLE_QUOTE
+ (path if is_single_quoted(path) else SINGLE_QUOTE + path + SINGLE_QUOTE)
+ COMMA
+ FILE_FORMAT
+ RIGHT_ARROW
Expand Down
15 changes: 15 additions & 0 deletions tests/integ/scala/test_dataframe_reader_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1412,3 +1412,18 @@ def test_filepath_not_exist_or_empty(session):
f"Given path: '{not_exist_file_path}' could not be found or is empty."
in str(ex_info)
)


def test_filepath_with_single_quote(session):
test_file_on_stage_with_quote = f"'@{tmp_stage_name1}/{test_file_csv}'"
test_file_on_stage = f"@{tmp_stage_name1}/{test_file_csv}"
result1 = (
session.read.option("INFER_SCHEMA", True).csv(test_file_on_stage).collect()
)
result2 = (
session.read.option("INFER_SCHEMA", True)
.csv(test_file_on_stage_with_quote)
.collect()
)

assert result1 == result2
Loading