Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit b8607e9

Browse files
achawkinsAndrew Hawkinscolin-rogers-dbt
authored
Change how a column of type VECTOR is parsed (#1169)
* Change how a column of type VECTOR is parsed * Add changelog entry --------- Co-authored-by: Andrew Hawkins <[email protected]> Co-authored-by: Colin Rogers <[email protected]>
1 parent efc68e4 commit b8607e9

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Fixes
2+
body: Fix parsing of the VECTOR type
3+
time: 2024-10-18T17:31:23.931299-04:00
4+
custom:
5+
Author: achawkins
6+
Issue: "1098"

dbt/adapters/snowflake/column.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,11 @@ def string_size(self) -> int:
4141
return 16777216
4242
else:
4343
return int(self.char_size)
44+
45+
@classmethod
46+
def from_description(cls, name: str, raw_data_type: str) -> "SnowflakeColumn":
47+
if "vector" in raw_data_type.lower():
48+
column = cls(name, raw_data_type, None, None, None)
49+
else:
50+
column = super().from_description(name, raw_data_type)
51+
return column

tests/unit/test_snowflake_adapter.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,19 @@ def test_float_from_description(self):
863863
assert col.is_string() is False
864864
assert col.is_integer() is False
865865

866+
def test_vector_from_description(self):
867+
col = SnowflakeColumn.from_description("my_col", "VECTOR(FLOAT, 768)")
868+
assert col.column == "my_col"
869+
assert col.dtype == "VECTOR(FLOAT, 768)"
870+
assert col.char_size is None
871+
assert col.numeric_precision is None
872+
assert col.numeric_scale is None
873+
assert col.is_float() is False
874+
assert col.is_number() is False
875+
assert col.is_numeric() is False
876+
assert col.is_string() is False
877+
assert col.is_integer() is False
878+
866879

867880
class SnowflakeConnectionsTest(unittest.TestCase):
868881
def test_comment_stripping_regex(self):

0 commit comments

Comments
 (0)