Repository: dbt-labs/dbt-snowflake (python)

Issue:
[Bug] Support Vector data types for macro `snowflake__get_columns_in_relation` 
### Is this a new bug in dbt-snowflake?

- [X] I believe this is a new bug in dbt-snowflake
- [X] I have searched the existing issues, and I could not find an existing issue for this bug

### Current Behavior

When trying to run an incremental load referencing a table that has a column that is cast as a VECTOR data type, I get the following error: `Could not interpret data_type "VECTOR(FLOAT, 1536)": could not convert "FLOAT" to an integer`

This appears to be due to the `from_description` Column function [here](https://github.com/dbt-labs/dbt-adapters/blob/main/dbt/adapters/base/column.py#L130) expecting only integers within parenthesis.

### Expected Behavior

Expected column data type to be properly parsed and reproduced in the incremental table.

### Steps To Reproduce

do `dbt run` on a model that has an incremental load materialization and has a column that is the VECTOR data type

### Relevant log output

```shell
15:40:11  Snowflake adapter: Error running SQL: macro get_columns_in_relation
15:40:11  Snowflake adapter: Rolling back transaction.
15:40:11  On <model name>: Close
15:40:11  Runtime Error in model <model name> (<model name>.sql)
  Could not interpret data_type "VECTOR(FLOAT, 1536)": could not convert "FLOAT" to an integer
```


### Environment

```markdown
- OS: Ubuntu 22.04.4 LTS
- Python:  3.11.7
- dbt-core: 1.8.3
- dbt-snowflake: 1.8.3
```


### Additional Context

suspected cause of the issue: 
https://github.com/dbt-labs/dbt-snowflake/blob/2576a08379e248d393b9a698e58fac0d32c23648/dbt/include/snowflake/macros/adapters.sql
https://github.com/dbt-labs/dbt-adapters/blob/main/dbt/adapters/base/column.py#L130

Pull request:
Change how a column of type VECTOR is parsed
resolves #1098
[docs](https://github.com/dbt-labs/docs.getdbt.com/issues/new/choose) dbt-labs/docs.getdbt.com/#

<!---
  Include the number of the issue addressed by this PR above if applicable.
  PRs for code changes without an associated issue *will not be merged*.
  See CONTRIBUTING.md for more information.

  Include the number of the docs issue that was opened for this PR. If
  this change has no user-facing implications, "N/A" suffices instead. New
  docs tickets can be created by clicking the link above or by going to
  https://github.com/dbt-labs/docs.getdbt.com/issues/new/choose.
-->

### Problem

<!---
  Describe the problem this PR is solving. What is the application state
  before this PR is merged?
-->

When an incremental (maybe other materializations, but I have not checked) model with a `VECTOR` type is run, it will fail to create the `SnowflakeColumn` object from the `from_description` class method. This is because the [`dbt-adapters` `Column.from_description`](https://github.com/dbt-labs/dbt-adapters/blob/main/dbt/adapters/base/column.py#L127) method does some parsing to extract the precision and scale of a numeric type and tries to cast both values within parenthesis to integers. The Snowflake vector is of the form `VECTOR(<data_type>, <dimension>)`, so the `<data_type>` will fail to be cast as an integer.

### Solution

<!---
  Describe the way this PR solves the above problem. Add as much detail as you
  can to help reviewers understand your changes. Include any alternatives and
  tradeoffs you considered.
-->

If the data type has the word `VECTOR` in it, bypass the additional parsing done in `dbt-adapters` and return a `SnowflakeColumn` that uses the raw data type as the parsed data type. If it does not, then pass it through to the default `from_description` method.

### Checklist

- [X] I have read [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md) and understand what's expected of me
- [X] I have run this code in development and it appears to resolve the stated issue
- [X] This PR includes tests, or tests are not required/relevant for this PR
- [X] This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX


Patch:
diff --git a/.changes/unreleased/Fixes-20241018-173123.yaml b/.changes/unreleased/Fixes-20241018-173123.yaml
new file mode 100644
index 0000000..eab4e83
--- /dev/null
+++ b/.changes/unreleased/Fixes-20241018-173123.yaml
@@ -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"
diff --git a/dbt/adapters/snowflake/column.py b/dbt/adapters/snowflake/column.py
index de92a05..281831b 100644
--- a/dbt/adapters/snowflake/column.py
+++ b/dbt/adapters/snowflake/column.py
@@ -41,3 +41,11 @@ class SnowflakeColumn(Column):
             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


Test patch:
diff --git a/tests/unit/test_snowflake_adapter.py b/tests/unit/test_snowflake_adapter.py
index aa580aa..18a5310 100644
--- a/tests/unit/test_snowflake_adapter.py
+++ b/tests/unit/test_snowflake_adapter.py
@@ -863,6 +863,19 @@ class TestSnowflakeColumn(unittest.TestCase):
         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):