Skip to content

Commit 75260b9

Browse files
SNOW-3309660: Fix XML tests to run in Snowfort (#4200)
1 parent 808d846 commit 75260b9

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#### Bug Fixes
1010

1111
- Fixed a bug where using parameter bindings for `CALL` queries issued through `session.sql` would raise an error.
12+
- Fixed a bug where `StringType` columns from Iceberg tables were not recognized as max-size strings.
1213

1314
## 1.50.0 (2026-04-23)
1415

src/snowflake/snowpark/_internal/type_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,11 @@ def convert_sf_to_sp_type(
278278
)
279279
if column_type_name == "TEXT":
280280
if internal_size > 0:
281-
return StringType(internal_size, internal_size == max_string_size)
281+
return StringType(
282+
internal_size,
283+
internal_size == max_string_size
284+
or internal_size == _MAX_ICEBERG_STRING_SIZE,
285+
)
282286
elif internal_size == 0:
283287
return StringType()
284288
raise ValueError("Negative value is not a valid input for StringType")

tests/integ/test_xml_reader_row_tag.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,11 @@ def test_read_xml_row_tag(
232232
session, file, row_tag, expected_row_count, expected_column_count
233233
):
234234
df = session.read.option("rowTag", row_tag).xml(f"@{tmp_stage_name}/{file}")
235-
result = df.collect()
236-
assert len(result) == expected_row_count
237-
assert len(result[0]) == expected_column_count
235+
# Use count() + len(df.columns) instead of collect() to avoid materializing
236+
# large result sets (e.g. 740 rows) that trigger paginated download URLs
237+
# unsupported by StoredProcRestfulSession inside a stored procedure.
238+
assert df.count() == expected_row_count
239+
assert len(df.columns) == expected_column_count
238240

239241

240242
def test_read_xml_no_xxe(session):

tests/unit/test_types.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
split_top_level_comma_fields,
5454
type_string_to_type_object,
5555
find_top_level_colon,
56+
_MAX_ICEBERG_STRING_SIZE,
5657
)
5758
from snowflake.snowpark.types import (
5859
ArrayType,
@@ -1044,6 +1045,25 @@ def test_convert_sf_to_sp_type_internal_size():
10441045
assert snowpark_type.length == 16777216
10451046
assert snowpark_type._is_max_size
10461047

1048+
# Iceberg deployments report internal_size=134217728 for max-length strings,
1049+
# which differs from the regular max_string_size (16777216). This must still
1050+
# be recognized as a max-size string so that StringType(134217728) == StringType().
1051+
snowpark_type = convert_sf_to_sp_type(
1052+
"TEXT", 0, 0, _MAX_ICEBERG_STRING_SIZE, 16777216
1053+
)
1054+
assert isinstance(snowpark_type, StringType)
1055+
assert snowpark_type.length == _MAX_ICEBERG_STRING_SIZE
1056+
assert snowpark_type._is_max_size
1057+
assert snowpark_type == StringType()
1058+
1059+
snowpark_type = convert_sf_to_sp_type(
1060+
"TEXT", 0, 0, _MAX_ICEBERG_STRING_SIZE, _MAX_ICEBERG_STRING_SIZE
1061+
)
1062+
assert isinstance(snowpark_type, StringType)
1063+
assert snowpark_type.length == _MAX_ICEBERG_STRING_SIZE
1064+
assert snowpark_type._is_max_size
1065+
assert snowpark_type == StringType()
1066+
10471067
with pytest.raises(
10481068
ValueError, match="Negative value is not a valid input for StringType"
10491069
):

0 commit comments

Comments
 (0)