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

- Improved `DataFrameReader.dbapi` (PuPr) reading performance by setting the default `fetch_size` parameter value to 100000.
- Improved error message for XSD validation failure when reading XML files using `session.read.option('rowValidationXSDPath', <xsd_path>).xml(<stage_file_path>)`.

### Snowpark pandas API Updates

Expand Down
3 changes: 2 additions & 1 deletion src/snowflake/snowpark/_internal/xml_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ def process_xml_range(
yield {column_name_of_corrupt_record: record_str}
elif mode == "FAILFAST":
raise RuntimeError(
f"Malformed XML record at bytes {record_start}-{record_end}: {e}"
f"Malformed XML record at bytes {record_start}-{record_end}: {e}\n"
f"XML record string: {record_str}"
)

if record_end > approx_end:
Expand Down
8 changes: 8 additions & 0 deletions tests/integ/test_xml_reader_row_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,11 @@ def test_read_xml_row_validation_xsd_path(session):
assert result[0]["'price'"] == '"44.95"'
assert result[0]["'publish_date'"] == '"2000-10-01"'
assert result[0]["'_id'"] == '"bk101"'


def test_read_xml_row_validation_xsd_path_failfast(session):
row_tag = "book"
with pytest.raises(SnowparkSQLException, match="XML record string:"):
session.read.option("rowTag", row_tag).option(
"rowValidationXSDPath", f"@{tmp_stage_name}/{test_file_books_xsd}"
).option("mode", "failfast").xml(f"@{tmp_stage_name}/{test_file_books_xml}")