Skip to content

Commit

Permalink
Change how a column of type VECTOR is parsed (#1169)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Dec 19, 2024
1 parent efc68e4 commit b8607e9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20241018-173123.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix parsing of the VECTOR type
time: 2024-10-18T17:31:23.931299-04:00
custom:
Author: achawkins
Issue: "1098"
8 changes: 8 additions & 0 deletions dbt/adapters/snowflake/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ def string_size(self) -> int:
return 16777216
else:
return int(self.char_size)

@classmethod
def from_description(cls, name: str, raw_data_type: str) -> "SnowflakeColumn":
if "vector" in raw_data_type.lower():
column = cls(name, raw_data_type, None, None, None)
else:
column = super().from_description(name, raw_data_type)
return column
13 changes: 13 additions & 0 deletions tests/unit/test_snowflake_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,19 @@ def test_float_from_description(self):
assert col.is_string() is False
assert col.is_integer() is False

def test_vector_from_description(self):
col = SnowflakeColumn.from_description("my_col", "VECTOR(FLOAT, 768)")
assert col.column == "my_col"
assert col.dtype == "VECTOR(FLOAT, 768)"
assert col.char_size is None
assert col.numeric_precision is None
assert col.numeric_scale is None
assert col.is_float() is False
assert col.is_number() is False
assert col.is_numeric() is False
assert col.is_string() is False
assert col.is_integer() is False


class SnowflakeConnectionsTest(unittest.TestCase):
def test_comment_stripping_regex(self):
Expand Down

0 comments on commit b8607e9

Please sign in to comment.