Skip to content

Commit

Permalink
one validation check and a comment (#1816)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-rpanchapakesan authored Dec 1, 2023
1 parent f323d22 commit 47b7e20
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/snowflake/connector/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class FieldType(NamedTuple):


def vector_pa_type(metadata: ResultMetadataV2) -> DataType:
"""Generate the arrow type represented by the given vector column metadata."""
"""Generate the Arrow type represented by the given vector column metadata.
Vectors are represented as Arrow fixed-size lists.
"""

if metadata.fields is None:
raise ValueError(
Expand All @@ -60,6 +63,10 @@ def vector_pa_type(metadata: ResultMetadataV2) -> DataType:
raise ValueError(
"Invalid result metadata for vector type: expected a dimension"
)
elif metadata.vector_dimension <= 0:
raise ValueError(
"Invalid result metadata for vector type: expected a positive dimension"
)

if field_type == "FIXED":
return pa.list_(pa.int32(), metadata.vector_dimension)
Expand Down

0 comments on commit 47b7e20

Please sign in to comment.