Skip to content

Commit 5f49cbf

Browse files
authored
feat(databricks): expand API coverage and preserve paginated results (#9163)
* feat(databricks): expand API coverage and preserve paginated results * fix(databricks): preserve saved controls and correct output contracts * fix(databricks): clarify operation parameter descriptions
1 parent 0a140b4 commit 5f49cbf

52 files changed

Lines changed: 7473 additions & 807 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/docs/content/docs/integrations/databricks.mdx‎

Lines changed: 1201 additions & 204 deletions
Large diffs are not rendered by default.

‎apps/sim/blocks/blocks/databricks.ts‎

Lines changed: 2006 additions & 205 deletions
Large diffs are not rendered by default.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { filterUndefined } from '@sim/utils/object'
2+
import type {
3+
DatabricksCancelAllRunsParams,
4+
DatabricksSuccessResponse,
5+
} from '@/tools/databricks/types'
6+
import {
7+
DATABRICKS_AUTH_PARAMS,
8+
databricksUrl,
9+
readDatabricksError,
10+
} from '@/tools/databricks/utils'
11+
import type { ToolConfig } from '@/tools/types'
12+
13+
export const cancelAllRunsTool: ToolConfig<
14+
DatabricksCancelAllRunsParams,
15+
DatabricksSuccessResponse
16+
> = {
17+
id: 'databricks_cancel_all_runs',
18+
name: 'Databricks Cancel All Runs',
19+
description: 'Request cancellation of active runs of a job or queued runs in the workspace.',
20+
version: '1.0.0',
21+
params: {
22+
...DATABRICKS_AUTH_PARAMS,
23+
jobId: {
24+
type: 'number',
25+
required: false,
26+
visibility: 'user-or-llm',
27+
description: 'Job identifier',
28+
},
29+
allQueuedRuns: {
30+
type: 'boolean',
31+
required: false,
32+
visibility: 'user-or-llm',
33+
description: 'Cancel queued runs; without a job ID this applies to the workspace',
34+
},
35+
},
36+
request: {
37+
url: (params) => databricksUrl(params.host, `/api/2.2/jobs/runs/cancel-all`),
38+
method: 'POST',
39+
headers: (params) => ({
40+
Authorization: `Bearer ${params.apiKey}`,
41+
'Content-Type': 'application/json',
42+
}),
43+
body: (params) => {
44+
return filterUndefined({
45+
job_id: params.jobId,
46+
all_queued_runs: params.allQueuedRuns,
47+
})
48+
},
49+
},
50+
transformResponse: async (response) => {
51+
if (!response.ok)
52+
throw new Error(await readDatabricksError(response, 'Failed to cancel all runs'))
53+
return { success: true, output: { success: true } }
54+
},
55+
outputs: {
56+
success: { type: 'boolean', description: 'Whether Databricks accepted the request' },
57+
},
58+
}

‎apps/sim/tools/databricks/cancel_run.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const cancelRunTool: ToolConfig<DatabricksCancelRunParams, DatabricksCanc
3434
},
3535

3636
request: {
37-
url: (params) => databricksUrl(params.host, '/api/2.1/jobs/runs/cancel'),
37+
url: (params) => databricksUrl(params.host, '/api/2.2/jobs/runs/cancel'),
3838
method: 'POST',
3939
headers: (params) => ({
4040
'Content-Type': 'application/json',
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { filterUndefined } from '@sim/utils/object'
2+
import type {
3+
DatabricksGetStatementParams,
4+
DatabricksSuccessResponse,
5+
} from '@/tools/databricks/types'
6+
import {
7+
DATABRICKS_AUTH_PARAMS,
8+
databricksUrl,
9+
optionalDatabricksString,
10+
readDatabricksError,
11+
} from '@/tools/databricks/utils'
12+
import type { ToolConfig } from '@/tools/types'
13+
import { safeUrlPathSegment } from '@/tools/url-path'
14+
15+
export const cancelStatementTool: ToolConfig<
16+
DatabricksGetStatementParams,
17+
DatabricksSuccessResponse
18+
> = {
19+
id: 'databricks_cancel_statement',
20+
name: 'Databricks Cancel Statement',
21+
description:
22+
'Request cancellation of an executing SQL statement; poll Get Statement to confirm its final status.',
23+
version: '1.0.0',
24+
params: {
25+
...DATABRICKS_AUTH_PARAMS,
26+
statementId: {
27+
type: 'string',
28+
required: true,
29+
visibility: 'user-or-llm',
30+
description: 'SQL statement identifier',
31+
},
32+
warehouseId: {
33+
type: 'string',
34+
required: false,
35+
visibility: 'user-or-llm',
36+
description: 'SQL warehouse identifier, when required by the statement endpoint',
37+
},
38+
},
39+
request: {
40+
url: (params) =>
41+
databricksUrl(
42+
params.host,
43+
`/api/2.0/sql/statements/${safeUrlPathSegment(params.statementId, 'statementId')}/cancel`
44+
),
45+
method: 'POST',
46+
headers: (params) => ({
47+
Authorization: `Bearer ${params.apiKey}`,
48+
'Content-Type': 'application/json',
49+
}),
50+
body: (params) =>
51+
filterUndefined({ warehouse_id: optionalDatabricksString(params.warehouseId) }),
52+
},
53+
transformResponse: async (response) => {
54+
if (!response.ok)
55+
throw new Error(await readDatabricksError(response, 'Failed to cancel SQL statement'))
56+
return { success: true, output: { success: true } }
57+
},
58+
outputs: {
59+
success: { type: 'boolean', description: 'Whether the cancellation request was accepted' },
60+
},
61+
}

0 commit comments

Comments
 (0)