Skip to content

Commit

Permalink
community: SAP HANA Vector Engine fix for latest HANA release (langch…
Browse files Browse the repository at this point in the history
…ain-ai#23516)

- **Description:** This PR fixes an issue with SAP HANA Cloud QRC03
version. In that version the number to indicate no length being set for
a vector column changed from -1 to 0. The change in this PR support both
behaviours (old/new).
- **Dependencies:** No dependencies have been introduced.

- **Tests**:  The change is covered by previous unit tests.
  • Loading branch information
yonarw authored Jun 26, 2024
1 parent 1e3e05b commit 6d0ebbc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libs/community/langchain_community/vectorstores/hanavector.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __init__(
f'"{self.metadata_column}" NCLOB, '
f'"{self.vector_column}" REAL_VECTOR '
)
if self.vector_column_length == -1:
if self.vector_column_length in [-1, 0]:
sql_str += ");"
else:
sql_str += f"({self.vector_column_length}));"
Expand Down Expand Up @@ -186,7 +186,9 @@ def _check_column( # type: ignore[no-untyped-def]
f"Column {column_name} has the wrong type: {rows[0][0]}"
)
# Check length, if parameter was provided
if column_length is not None:
# Length can either be -1 (QRC01+02-24) or 0 (QRC03-24 onwards)
# to indicate no length constraint being present.
if column_length is not None and column_length > 0:
if rows[0][1] != column_length:
raise AttributeError(
f"Column {column_name} has the wrong length: {rows[0][1]}"
Expand Down

0 comments on commit 6d0ebbc

Please sign in to comment.