Skip to content

Validate that index name is a UC index #96

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

Merged
merged 3 commits into from
Apr 8, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ def __init__(
f"The `index_name` parameter must be a string, but got {type(index_name).__name__}."
)

if index_name.count(".") != 2:
raise ValueError(
f"The `index_name` parameter must be in the format 'catalog.schema.name', but got {index_name!r}."
)

try:
from databricks.vector_search.client import ( # type: ignore[import]
VectorSearchClient,
Expand Down
4 changes: 3 additions & 1 deletion integrations/langchain/tests/unit_tests/test_vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def test_init_with_endpoint_name() -> None:
assert vectorsearch.index.describe() == INDEX_DETAILS[DELTA_SYNC_INDEX]


@pytest.mark.parametrize("index_name", [None, 123, MagicMock(spec=VectorSearchIndex)])
@pytest.mark.parametrize(
"index_name", [None, 123, "invalid.name", MagicMock(spec=VectorSearchIndex)]
)
def test_init_fail_invalid_index_name(index_name) -> None:
with pytest.raises(ValueError, match="The `index_name` parameter must be"):
DatabricksVectorSearch(index_name=index_name)
Expand Down