Skip to content

Commit 4e0ef2f

Browse files
committed
fix XML tests to run in snowfort
1 parent 0aeccd9 commit 4e0ef2f

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

src/snowflake/snowpark/_internal/type_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ 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 or internal_size == _MAX_ICEBERG_STRING_SIZE,
284+
)
282285
elif internal_size == 0:
283286
return StringType()
284287
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: 14 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,19 @@ 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("TEXT", 0, 0, _MAX_ICEBERG_STRING_SIZE, 16777216)
1052+
assert isinstance(snowpark_type, StringType)
1053+
assert snowpark_type.length == _MAX_ICEBERG_STRING_SIZE
1054+
assert snowpark_type._is_max_size
1055+
1056+
snowpark_type = convert_sf_to_sp_type("TEXT", 0, 0, _MAX_ICEBERG_STRING_SIZE, _MAX_ICEBERG_STRING_SIZE)
1057+
assert isinstance(snowpark_type, StringType)
1058+
assert snowpark_type.length == _MAX_ICEBERG_STRING_SIZE
1059+
assert snowpark_type._is_max_size
1060+
10471061
with pytest.raises(
10481062
ValueError, match="Negative value is not a valid input for StringType"
10491063
):

0 commit comments

Comments
 (0)