Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#### Bug Fixes

- Fixed a bug where using parameter bindings for `CALL` queries issued through `session.sql` would raise an error.
- Improved the `FileNotFoundError` message raised when `INFER_SCHEMA` returns zero rows so it also points to file format options (`PARSE_HEADER`, `SKIP_HEADER`, `ON_ERROR=CONTINUE`) that can silently filter everything out, instead of only suggesting a missing path.

## 1.50.0 (2026-04-23)

Expand Down
14 changes: 13 additions & 1 deletion src/snowflake/snowpark/dataframe_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,8 +1338,20 @@ def _infer_schema_for_file_format(
raise e

if len(results) == 0:
# Zero rows can mean the path is empty/missing, or that file
# format options (PARSE_HEADER, SKIP_HEADER, ON_ERROR=CONTINUE)
# silently filtered everything out.
hints = [
f"{k}={format_type_options.get(k, infer_schema_options.get(k))}"
for k in ("PARSE_HEADER", "SKIP_HEADER", "ON_ERROR")
if k in format_type_options or k in infer_schema_options
]
suffix = f" Applied options: {', '.join(hints)}." if hints else ""
raise FileNotFoundError(
f"Given path: '{path}' could not be found or is empty."
f"Given path: '{path}' returned no results from INFER_SCHEMA. "
"The path may be empty/missing, or file format options may "
"have filtered every row/header. Check the file contents and "
"file format options." + suffix
)
new_schema = []
schema_to_cast = []
Expand Down
13 changes: 9 additions & 4 deletions tests/integ/scala/test_dataframe_reader_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2119,18 +2119,23 @@ def test_filepath_not_exist_or_empty(session):
session.read.option("PARSE_HEADER", True).option("INFER_SCHEMA", True).csv(
empty_file_path
)
assert f"Given path: '{empty_file_path}' could not be found or is empty." in str(
ex_info
assert (
f"Given path: '{empty_file_path}' returned no results from INFER_SCHEMA."
in str(ex_info.value)
)
# Message should mention file format options so users don't chase a phantom
# path-not-found when the real cause is PARSE_HEADER/SKIP_HEADER/ON_ERROR.
assert "file format options" in str(ex_info.value)

with pytest.raises(FileNotFoundError) as ex_info:
session.read.option("PARSE_HEADER", True).option("INFER_SCHEMA", True).csv(
not_exist_file_path
)
assert (
f"Given path: '{not_exist_file_path}' could not be found or is empty."
in str(ex_info)
f"Given path: '{not_exist_file_path}' returned no results from INFER_SCHEMA."
in str(ex_info.value)
)
assert "file format options" in str(ex_info.value)


@pytest.mark.skipif(
Expand Down
Loading