Skip to content

Commit 2fc9c02

Browse files
committed
Improve error message for data type with incorrect number of properties
1 parent c3bf0be commit 2fc9c02

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [0.63.2] - 2026-03-02
4+
5+
- Improved error message for data types with incorrect number of properties, e.g. `TIMESTAMP_NTZ` or `TIMESTAMP_NTZ(9,1)`. Each data types now expects specific number of properties.
6+
37
## [0.63.1] - 2026-03-02
48

59
- Added `external_volume` and `catalog` parameters to `DATABASE` object type in order to support Iceberg tables on database level.

snowddl/blueprint/data_type.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,23 @@ def __init__(self, data_type_str):
147147
except KeyError:
148148
raise ValueError(f"Invalid base data type [{m['base_type']}] in type string [{data_type_str}]")
149149

150+
self.val1 = None
151+
self.val2 = None
152+
150153
if self.base_type == BaseDataType.VECTOR:
151-
self.val1 = str(m["val1_vector"]).upper()
152-
self.val2 = int(m["val2_vector"])
154+
if m["val1_vector"] is not None:
155+
self.val1 = str(m["val1_vector"]).upper()
156+
157+
if m["val2_vector"] is not None:
158+
self.val2 = int(m["val2_vector"])
153159
else:
154-
self.val1 = int(m["val1"]) if self.base_type.number_of_properties >= 1 else None
155-
self.val2 = int(m["val2"]) if self.base_type.number_of_properties >= 2 else None
160+
if m["val1"] is not None:
161+
self.val1 = int(m["val1"])
162+
163+
if m["val2"] is not None:
164+
self.val2 = int(m["val2"])
165+
166+
self._validate_number_of_properties(data_type_str)
156167

157168
@staticmethod
158169
def from_base_type(base_type: BaseDataType):
@@ -177,3 +188,17 @@ def __eq__(self, other):
177188
raise NotImplementedError
178189

179190
return str(self) == str(other)
191+
192+
def _validate_number_of_properties(self, data_type_str):
193+
if self.val1 is not None and self.val2 is not None:
194+
parsed_number_of_properties = 2
195+
elif self.val1 is not None:
196+
parsed_number_of_properties = 1
197+
else:
198+
parsed_number_of_properties = 0
199+
200+
if self.base_type.number_of_properties != parsed_number_of_properties:
201+
raise ValueError(
202+
f"Invalid number of properties for base data type [{self.base_type.name}] in type string [{data_type_str}], "
203+
f"expected exactly [{self.base_type.number_of_properties}]"
204+
)

snowddl/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.63.1"
1+
__version__ = "0.63.2"

0 commit comments

Comments
 (0)