Skip to content

Commit 47fe441

Browse files
committed
addressed all test failures
1 parent dfb8fd9 commit 47fe441

File tree

3 files changed

+65
-19
lines changed

3 files changed

+65
-19
lines changed

components/databricks/actions/create-vector-search-index/create-vector-search-index.mjs

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ export default {
1818
"A unique name for the index (e.g., `main_catalog.docs.en_wiki_index`).",
1919
},
2020
endpointName: {
21-
type: "string",
22-
label: "Endpoint Name",
23-
description: "The vector search endpoint that will serve the index.",
21+
propDefinition: [
22+
databricks,
23+
"endpointName",
24+
],
2425
},
2526
indexType: {
2627
type: "string",
@@ -40,21 +41,28 @@ export default {
4041
type: "string",
4142
label: "Source Table",
4243
description:
43-
"The Delta table backing the index (required if `indexType` is `DELTA_SYNC`).",
44+
"The Delta table backing the index (required for `DELTA_SYNC`).",
4445
optional: true,
4546
},
4647
columnsToSync: {
4748
type: "string[]",
4849
label: "Columns to Sync",
4950
description:
50-
"List of columns to sync from the source Delta table. Example: `[\"id\", \"text\"]`",
51+
"List of columns to sync from the source Delta table. Example: `[\"id\", \"text\"]` (required for `DELTA_SYNC`).",
5152
optional: true,
5253
},
5354
embeddingSourceColumns: {
5455
type: "string[]",
5556
label: "Embedding Source Columns",
5657
description:
57-
"List of embedding source column configs. Each entry should be a JSON object string like `{ \"embedding_model_endpoint_name\": \"e5-small-v2\", \"name\": \"text\" }`",
58+
"List of embedding source column configs. Each entry should be a JSON object string like `[ { \"embedding_model_endpoint_name\": \"e5-small-v2\", \"name\": \"text\" } ]` (required for `DELTA_SYNC`).",
59+
optional: true,
60+
},
61+
schemaJson: {
62+
type: "string",
63+
label: "Schema JSON",
64+
description:
65+
"The schema of the index in JSON format. Example: `{ \"columns\": [{ \"name\": \"id\", \"type\": \"string\" }, { \"name\": \"text_vector\", \"type\": \"array<double>\" }] }`. Required for `DIRECT_ACCESS` indexes.",
5866
optional: true,
5967
},
6068
pipelineType: {
@@ -84,6 +92,7 @@ export default {
8492
"sourceTable is required when indexType is DELTA_SYNC.",
8593
);
8694
}
95+
8796
const columnsToSync = Array.isArray(this.columnsToSync)
8897
? this.columnsToSync
8998
: utils.parseObject(this.columnsToSync);
@@ -100,10 +109,7 @@ export default {
100109
"columnsToSync must be a non-empty array for DELTA_SYNC indexes.",
101110
);
102111
}
103-
if (
104-
!Array.isArray(embeddingSourceColumns) ||
105-
!embeddingSourceColumns.length
106-
) {
112+
if (!Array.isArray(embeddingSourceColumns) || !embeddingSourceColumns.length) {
107113
throw new ConfigurationError(
108114
"embeddingSourceColumns must be a non-empty array for DELTA_SYNC indexes.",
109115
);
@@ -117,6 +123,17 @@ export default {
117123
};
118124
}
119125

126+
else if (this.indexType === "DIRECT_ACCESS") {
127+
if (!this.schemaJson) {
128+
throw new ConfigurationError(
129+
"schemaJson is required when indexType is DIRECT_ACCESS.",
130+
);
131+
}
132+
payload.direct_access_index_spec = {
133+
schema_json: this.schemaJson,
134+
};
135+
}
136+
120137
const response = await this.databricks.createVectorSearchIndex({
121138
data: payload,
122139
$,

components/databricks/actions/list-vector-search-indexes/list-vector-search-indexes.mjs

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,47 @@ export default {
88
type: "action",
99
props: {
1010
databricks,
11+
endpointName: {
12+
propDefinition: [
13+
databricks,
14+
"endpointName",
15+
],
16+
},
1117
},
1218

1319
async run({ $ }) {
14-
const response = await this.databricks.listVectorSearchIndexes({
15-
$,
16-
});
20+
const allIndexes = [];
21+
let pageToken;
1722

18-
const count = response?.vector_indexes?.length || 0;
19-
$.export("$summary", `Found ${count} vector search index${count === 1
20-
? ""
21-
: "es"}`);
23+
do {
24+
const {
25+
vector_indexes, next_page_token,
26+
} = await this.databricks.listIndexes({
27+
params: {
28+
endpoint_name: this.endpointName,
29+
...(pageToken
30+
? {
31+
page_token: pageToken,
32+
}
33+
: {}),
34+
},
35+
$,
36+
});
2237

23-
return response;
38+
if (vector_indexes?.length) {
39+
allIndexes.push(...vector_indexes);
40+
}
41+
42+
pageToken = next_page_token;
43+
} while (pageToken);
44+
45+
$.export(
46+
"$summary",
47+
`Successfully retrieved ${allIndexes.length} index${allIndexes.length === 1
48+
? ""
49+
: "es"}.`,
50+
);
51+
52+
return allIndexes;
2453
},
2554
};

components/databricks/actions/query-vector-search-index/query-vector-search-index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default {
1818
columns: {
1919
type: "string[]",
2020
label: "Columns",
21-
description: "List of column names to include in the response.",
21+
description: "List of column names to include in the response. Example: `[\"id\"]`",
2222
},
2323
queryText: {
2424
type: "string",

0 commit comments

Comments
 (0)