Skip to content

Commit 3913b7f

Browse files
authored
[Fix] Fix waiting for databricks_vector_search_index readiness (#4243)
## Changes <!-- Summary of your changes that are easy to understand --> Change the wait condition from waiting for the index to be fully ready to either fully ready or started indexing. Resolves #4144 ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] `make test` run locally - [ ] relevant change in `docs/` folder - [ ] covered with integration tests in `internal/acceptance` - [x] relevant acceptance tests are passing - [ ] using Go SDK
1 parent 11c84e4 commit 3913b7f

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

vectorsearch/resource_vector_search_index.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ func waitForSearchIndexCreation(w *databricks.WorkspaceClient, ctx context.Conte
3737
if err != nil {
3838
return retry.NonRetryableError(err)
3939
}
40-
if index.Status.Ready { // We really need to depend on the detailed status of the index, but it's not available in the API yet
40+
// We really need to depend on the detailed status of the index, but it's not available in the API yet
41+
if index.Status != nil && (index.Status.Ready || index.Status.IndexedRowCount > 0) {
4142
return nil
4243
}
4344
return retry.RetryableError(fmt.Errorf("vector search index %s is still pending", searchIndexName))

vectorsearch/resource_vector_search_index_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,54 @@ func TestVectorSearchIndexCreate(t *testing.T) {
8282
assert.Equal(t, "abc", d.Id())
8383
}
8484

85+
func TestVectorSearchIndexCreateNotReadyButIndexedRows(t *testing.T) {
86+
d, err := qa.ResourceFixture{
87+
MockWorkspaceClientFunc: func(w *mocks.MockWorkspaceClient) {
88+
e := w.GetMockVectorSearchIndexesAPI().EXPECT()
89+
e.CreateIndex(mock.Anything, vectorsearch.CreateVectorIndexRequest{
90+
Name: "abc",
91+
EndpointName: "test",
92+
PrimaryKey: "id",
93+
IndexType: "DELTA_SYNC",
94+
DeltaSyncIndexSpec: &vectorsearch.DeltaSyncVectorIndexSpecRequest{
95+
SourceTable: "main.default.test",
96+
PipelineType: "TRIGGERED",
97+
EmbeddingSourceColumns: []vectorsearch.EmbeddingSourceColumn{
98+
{
99+
Name: "text",
100+
EmbeddingModelEndpointName: "e5_small_v2",
101+
},
102+
},
103+
},
104+
}).Return(&vectorsearch.CreateVectorIndexResponse{}, nil)
105+
e.GetIndexByIndexName(mock.Anything, "abc").Return(&vectorsearch.VectorIndex{
106+
Name: "abc",
107+
EndpointName: "test",
108+
PrimaryKey: "id",
109+
IndexType: "DELTA_SYNC",
110+
DeltaSyncIndexSpec: &vectorsearch.DeltaSyncVectorIndexSpecResponse{
111+
SourceTable: "main.default.test",
112+
PipelineType: "TRIGGERED",
113+
EmbeddingSourceColumns: []vectorsearch.EmbeddingSourceColumn{
114+
{
115+
Name: "text",
116+
EmbeddingModelEndpointName: "e5_small_v2",
117+
},
118+
},
119+
},
120+
Status: &vectorsearch.VectorIndexStatus{
121+
IndexedRowCount: 10,
122+
},
123+
}, nil)
124+
},
125+
Resource: ResourceVectorSearchIndex(),
126+
HCL: indexHcl,
127+
Create: true,
128+
}.Apply(t)
129+
assert.NoError(t, err)
130+
assert.Equal(t, "abc", d.Id())
131+
}
132+
85133
func TestVectorSearchIndexRead(t *testing.T) {
86134
d, err := qa.ResourceFixture{
87135
MockWorkspaceClientFunc: func(w *mocks.MockWorkspaceClient) {

0 commit comments

Comments
 (0)