Skip to content

Commit ee33ab4

Browse files
committed
addressed coderabbit review feedback
1 parent 62287c7 commit ee33ab4

File tree

6 files changed

+59
-30
lines changed

6 files changed

+59
-30
lines changed

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ export default {
2626
type: "string",
2727
label: "Index Type",
2828
description: "Type of index (`DELTA_SYNC` or `DIRECT_ACCESS`).",
29-
options: ["DELTA_SYNC", "DIRECT_ACCESS"],
29+
options: [
30+
"DELTA_SYNC",
31+
"DIRECT_ACCESS",
32+
],
3033
},
3134
primaryKey: {
3235
type: "string",
@@ -58,7 +61,10 @@ export default {
5861
type: "string",
5962
label: "Pipeline Type",
6063
description: "Pipeline type for syncing (default: TRIGGERED).",
61-
options: ["TRIGGERED", "CONTINUOUS"],
64+
options: [
65+
"TRIGGERED",
66+
"CONTINUOUS",
67+
],
6268
optional: true,
6369
default: "TRIGGERED",
6470
},
@@ -75,26 +81,31 @@ export default {
7581
if (this.indexType === "DELTA_SYNC") {
7682
if (!this.sourceTable) {
7783
throw new ConfigurationError(
78-
"sourceTable is required when indexType is DELTA_SYNC."
84+
"sourceTable is required when indexType is DELTA_SYNC.",
7985
);
8086
}
87+
const columnsToSync = Array.isArray(this.columnsToSync)
88+
? this.columnsToSync
89+
: utils.parseObject(this.columnsToSync);
8190

82-
const columnsToSync = utils.parseObject(this.columnsToSync);
83-
const embeddingSourceColumns = utils.parseObject(
84-
this.embeddingSourceColumns
85-
);
91+
const embeddingSourceColumns = Array.isArray(this.embeddingSourceColumns)
92+
? this.embeddingSourceColumns.map((item) =>
93+
typeof item === "string"
94+
? JSON.parse(item)
95+
: item)
96+
: utils.parseObject(this.embeddingSourceColumns);
8697

8798
if (!Array.isArray(columnsToSync) || !columnsToSync.length) {
8899
throw new ConfigurationError(
89-
"columnsToSync must be a non-empty array for DELTA_SYNC indexes."
100+
"columnsToSync must be a non-empty array for DELTA_SYNC indexes.",
90101
);
91102
}
92103
if (
93104
!Array.isArray(embeddingSourceColumns) ||
94105
!embeddingSourceColumns.length
95106
) {
96107
throw new ConfigurationError(
97-
"embeddingSourceColumns must be a non-empty array for DELTA_SYNC indexes."
108+
"embeddingSourceColumns must be a non-empty array for DELTA_SYNC indexes.",
98109
);
99110
}
100111

@@ -113,7 +124,7 @@ export default {
113124

114125
$.export(
115126
"$summary",
116-
`Successfully created vector search index: ${response?.name || this.name}`
127+
`Successfully created vector search index: ${response?.name || this.name}`,
117128
);
118129
return response;
119130
},

components/databricks/actions/delete-vector-search-index-data/delete-vector-search-index-data.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ export default {
3030
if (!keys.length) {
3131
throw new Error("Please provide at least one primary key to delete.");
3232
}
33-
33+
3434
const response = await this.databricks.deleteVectorSearchData({
3535
indexName: this.indexName,
36-
params: { primary_keys: keys },
36+
data: {
37+
primary_keys: keys,
38+
},
3739
$,
3840
});
3941

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default {
1111
indexName: {
1212
propDefinition: [
1313
databricks,
14-
"indexName",
14+
"indexName",
1515
],
1616
},
1717
},

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ export default {
1111
},
1212

1313
async run({ $ }) {
14-
const response = await this.databricks.listVectorSearchIndexes({ $ });
14+
const response = await this.databricks.listVectorSearchIndexes({
15+
$,
16+
});
1517

1618
const count = response?.vector_indexes?.length || 0;
17-
$.export("$summary", `Found ${count} vector search index${count === 1 ? "" : "es"}`);
19+
$.export("$summary", `Found ${count} vector search index${count === 1
20+
? ""
21+
: "es"}`);
1822

1923
return response;
2024
},

components/databricks/actions/upsert-vector-search-index-data/upsert-vector-search-index-data.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313
indexName: {
1414
propDefinition: [
1515
databricks,
16-
"indexName",
16+
"indexName",
1717
],
1818
},
1919
rows: {

components/databricks/databricks.app.mjs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,15 @@ export default {
5959
})) || [];
6060
},
6161
},
62-
indexName: {
62+
indexName: {
6363
type: "string",
6464
label: "Vector Search Index",
6565
description: "The name of the vector search index",
6666
async options() {
6767
const { vector_indexes } = await this.listVectorSearchIndexes();
68-
return vector_indexes?.map(({
69-
name: value,
70-
}) => ({
68+
return vector_indexes?.map(({ name: value }) => ({
7169
value,
72-
label: value,
70+
label: value,
7371
})) || [];
7472
},
7573
},
@@ -221,7 +219,9 @@ export default {
221219
});
222220
},
223221

224-
getVectorSearchIndex({ indexName, ...args }) {
222+
getVectorSearchIndex({
223+
indexName, ...args
224+
}) {
225225
return this._makeRequest({
226226
path: `/vector-search/indexes/${indexName}`,
227227
method: "GET",
@@ -237,47 +237,59 @@ export default {
237237
});
238238
},
239239

240-
deleteVectorSearchIndex({ indexName, ...args }) {
240+
deleteVectorSearchIndex({
241+
indexName, ...args
242+
}) {
241243
return this._makeRequest({
242244
path: `/vector-search/indexes/${indexName}`,
243245
method: "DELETE",
244246
...args,
245247
});
246248
},
247249

248-
queryVectorSearchIndex({ indexName, ...args }) {
250+
queryVectorSearchIndex({
251+
indexName, ...args
252+
}) {
249253
return this._makeRequest({
250254
path: `/vector-search/indexes/${indexName}/query`,
251255
method: "POST",
252256
...args,
253257
});
254258
},
255259

256-
syncVectorSearchIndex({ indexName, ...args }) {
260+
syncVectorSearchIndex({
261+
indexName, ...args
262+
}) {
257263
return this._makeRequest({
258264
path: `/vector-search/indexes/${indexName}/sync`,
259265
method: "POST",
260266
...args,
261267
});
262268
},
263269

264-
deleteVectorSearchData({ indexName,...args }) {
270+
deleteVectorSearchData({
271+
indexName, ...args
272+
}) {
265273
return this._makeRequest({
274+
path: `/vector-search/indexes/${indexName}/delete-data`,
266275
method: "DELETE",
267-
url: `/api/2.0/vector-search/indexes/${indexName}/delete-data`,
268-
...args,
276+
...args,
269277
});
270278
},
271279

272-
upsertVectorSearchIndexData({ indexName, ...args }) {
280+
upsertVectorSearchIndexData({
281+
indexName, ...args
282+
}) {
273283
return this._makeRequest({
274284
path: `/vector-search/indexes/${indexName}/upsert-data`,
275285
method: "POST",
276286
...args,
277287
});
278288
},
279289

280-
scanVectorSearchIndex({ indexName, ...args }) {
290+
scanVectorSearchIndex({
291+
indexName, ...args
292+
}) {
281293
return this._makeRequest({
282294
path: `/vector-search/indexes/${indexName}/scan`,
283295
method: "POST",

0 commit comments

Comments
 (0)