Skip to content

Commit 677e733

Browse files
committed
address comment
1 parent 58bffe9 commit 677e733

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/snowflake/snowpark/_internal/type_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,7 @@ def extract_bracket_content(type_str: str, keyword: str) -> str:
997997
e.g., "array<int>" => "int". It also parses the nested array like "array<array<...>>".
998998
Raises ValueError on mismatched or missing bracket.
999999
"""
1000+
type_str = type_str.strip()
10001001
prefix_pattern = rf"(?i)^\s*{keyword}\s*<"
10011002
match = re.match(prefix_pattern, type_str)
10021003
if not match:

tests/unit/test_types.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,14 @@ def test_type_string_to_type_object_array_of_decimal():
15401540
assert dt.element_type.precision == 10
15411541
assert dt.element_type.scale == 2
15421542

1543+
try:
1544+
type_string_to_type_object("array<decimal(10,2>")
1545+
raise AssertionError("Expected ValueError for not a supported type")
1546+
except ValueError as ex:
1547+
assert "is not a supported type" in str(
1548+
ex
1549+
), f"Expected not a supported type, got: {ex}"
1550+
15431551

15441552
def test_type_string_to_type_object_map_of_int_string():
15451553
dt = type_string_to_type_object("map<int, string>")
@@ -1720,7 +1728,7 @@ def test_type_string_to_type_object_implicit_struct_with_spaces():
17201728
Test spacing variations. E.g. " col1 : int , col2 : map< string , decimal(5,2) > ".
17211729
"""
17221730
dt = type_string_to_type_object(
1723-
" col1 : int , col2 : map< string , decimal(5,2) > "
1731+
" col1 : int , col2 : map< string , decimal( 5 , 2 ) > "
17241732
)
17251733
assert isinstance(dt, StructType), f"Expected StructType, got {dt}"
17261734
assert len(dt.fields) == 2, f"Expected 2 fields, got {len(dt.fields)}"

0 commit comments

Comments
 (0)