Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change how a column of type VECTOR is parsed #1169

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -862,6 +862,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
Loading