Skip to content

Commit 2109892

Browse files
authored
fix: handle unspecified column_configs for KNN (#157)
* fix: handle unspecified column_configs for KNN Fixes a bug in which we tried to find the embedding columns. The prior integration tests for KNN all had certain fields filled in and hence couldn't catch this case. Thanks to the offline report from Amarnath Mullick. * embedding_service is only available in SpannerVectorStore constructor
1 parent 1f7d444 commit 2109892

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/langchain_google_spanner/vector_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def _generate_sql(
440440
"""
441441

442442
embedding_config = list(
443-
filter(lambda x: x.name == embedding_column, column_configs)
443+
filter(lambda x: x.name == embedding_column, column_configs or [])
444444
)
445445
if embedding_column and len(embedding_config) > 0:
446446
config = embedding_config[0]

tests/integration/test_spanner_vector_store.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ class TestStaticUtilityGoogleSQL_KNN:
9090
def setup_database(self, client, cleanupGSQL):
9191
yield
9292

93+
def test_init_vector_store_table_with_basic_args(self):
94+
SpannerVectorStore.init_vector_store_table(
95+
instance_id=instance_id,
96+
database_id=google_database,
97+
table_name=table_name,
98+
)
99+
93100
def test_init_vector_store_table1(self):
94101
SpannerVectorStore.init_vector_store_table(
95102
instance_id=instance_id,
@@ -160,6 +167,13 @@ class TestStaticUtilityPGSQL:
160167
def setup_database(self, client, cleanupPGSQL):
161168
yield
162169

170+
def test_init_vector_store_basic_args(self):
171+
SpannerVectorStore.init_vector_store_table(
172+
instance_id=instance_id,
173+
database_id=pg_database,
174+
table_name=table_name,
175+
)
176+
163177
def test_init_vector_store_table1(self):
164178
SpannerVectorStore.init_vector_store_table(
165179
instance_id=instance_id,

0 commit comments

Comments
 (0)