diff --git a/.oxlintrc.json b/.oxlintrc.json index e45ab67fc..3e66f570e 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -26,11 +26,8 @@ { "patterns": [ { - "group": [ - "@databricks/sdk-experimental", - "@databricks/sdk-experimental/**" - ], - "message": "Import the Databricks SDK only through the wrapper in packages/shared/src/workspace-client. Add a re-export there if you need a new symbol." + "group": ["@databricks/sdk-*", "@databricks/sdk-*/**"], + "message": "Import the Databricks SDK only through the wrapper in packages/shared/src/workspace-client (legacy.ts for @databricks/sdk-experimental, modular.ts for the modular @databricks/sdk-* packages). Add a re-export there if you need a new symbol." } ] } diff --git a/docs/docs/api/appkit/Function.createWorkspaceClient.md b/docs/docs/api/appkit/Function.createWorkspaceClient.md index 8ad87f41d..de3f98837 100644 --- a/docs/docs/api/appkit/Function.createWorkspaceClient.md +++ b/docs/docs/api/appkit/Function.createWorkspaceClient.md @@ -18,8 +18,8 @@ Host resolution: | Parameter | Type | | ------ | ------ | -| `opts` | [`WorkspaceClientOptions`](Interface.WorkspaceClientOptions.md) | +| `opts` | `WorkspaceClientOptions` | ## Returns -[`WorkspaceClient`](Interface.WorkspaceClient.md) +`WorkspaceClient` diff --git a/docs/docs/api/appkit/Interface.WorkspaceClient.md b/docs/docs/api/appkit/Interface.WorkspaceClient.md index bf508bbe4..26a680581 100644 --- a/docs/docs/api/appkit/Interface.WorkspaceClient.md +++ b/docs/docs/api/appkit/Interface.WorkspaceClient.md @@ -86,20 +86,20 @@ Serving Endpoints. ### statementExecution ```ts -readonly statementExecution: StatementExecutionService; +readonly statementExecution: StatementExecutionClient; ``` -Statement Execution. +Statement Execution (modular SDK). *** ### warehouses ```ts -readonly warehouses: WarehousesService; +readonly warehouses: WarehousesClient; ``` -SQL Warehouses. +SQL Warehouses (modular SDK). ## Methods diff --git a/docs/docs/api/appkit/Interface.WorkspaceClientOptions.md b/docs/docs/api/appkit/Interface.WorkspaceClientOptions.md index 29ef96aac..56229ac37 100644 --- a/docs/docs/api/appkit/Interface.WorkspaceClientOptions.md +++ b/docs/docs/api/appkit/Interface.WorkspaceClientOptions.md @@ -38,6 +38,16 @@ Databricks host, e.g. https://my-workspace.cloud.databricks.com. Defaults to DAT *** +### profile? + +```ts +optional profile: string; +``` + +`~/.databrickscfg` profile name. Used when no host/token is provided. + +*** + ### token? ```ts diff --git a/package.json b/package.json index 54c217804..0bb6b5b80 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,9 @@ "protobufjs@<7.6.2": "7.6.2", "qs@<6.15.2": "6.15.2", "size-sensor": "1.0.3" + }, + "patchedDependencies": { + "@databricks/sdk-statementexecution@0.46.0": "patches/@databricks__sdk-statementexecution@0.46.0.patch" } } } diff --git a/packages/appkit/src/connectors/sql-warehouse/arrow-schema.ts b/packages/appkit/src/connectors/sql-warehouse/arrow-schema.ts index 17d099e37..af5bfbb18 100644 --- a/packages/appkit/src/connectors/sql-warehouse/arrow-schema.ts +++ b/packages/appkit/src/connectors/sql-warehouse/arrow-schema.ts @@ -54,12 +54,12 @@ export function parseDatabricksType(typeText: string): DataType { export function buildEmptyArrowIPCBase64( columns: Array<{ name?: string; - type_text?: string; - type_name?: string; + typeText?: string; + typeName?: string; }>, ): string { const fields = columns.map((col, index) => { - const typeText = col.type_text ?? col.type_name ?? "STRING"; + const typeText = col.typeText ?? col.typeName ?? "STRING"; let dataType: DataType; try { dataType = parseDatabricksType(typeText); diff --git a/packages/appkit/src/connectors/sql-warehouse/client.ts b/packages/appkit/src/connectors/sql-warehouse/client.ts index 439658cbd..6e131c6e1 100644 --- a/packages/appkit/src/connectors/sql-warehouse/client.ts +++ b/packages/appkit/src/connectors/sql-warehouse/client.ts @@ -21,10 +21,14 @@ import { SpanStatusCode, TelemetryManager, } from "../../telemetry"; -import { - Context, - type sql, - type WorkspaceClient, +import type { + EndpointState, + ExecuteStatementRequest, + ExternalLink, + ResultData, + StatementResponse, + StatementStatus, + WorkspaceClient, } from "../../workspace-client"; import { buildEmptyArrowIPCBase64 } from "./arrow-schema"; import { executeStatementDefaults } from "./defaults"; @@ -40,9 +44,7 @@ const logger = createLogger("connectors:sql-warehouse"); * Arrow result to match the JSON path. Returns `undefined` when the manifest * carries no columns. */ -function arrowColumnNames( - response: sql.StatementResponse, -): string[] | undefined { +function arrowColumnNames(response: StatementResponse): string[] | undefined { const cols = response.manifest?.schema?.columns; if (!cols || cols.length === 0) return undefined; return cols.map((c, i) => @@ -50,6 +52,46 @@ function arrowColumnNames( ); } +/** + * Coerce the modular SDK's `bigint` row/byte counts back to `number` (the type + * the legacy SDK used). AppKit never does arithmetic on these — they are purely + * informational — but a stray `bigint` makes `JSON.stringify` throw ("Do not + * know how to serialize a BigInt") the instant the result is cached or written + * to an SSE frame. Reyden's INLINE + ARROW_STREAM result — which the analytics + * arrow path caches — carries them on `result`/`manifest`, so normalize every + * statement response at the SDK boundary. Mutates in place (the response is a + * fresh unmarshalled object, owned by the caller). + */ +const BIGINT_COUNT_FIELDS = ["rowOffset", "rowCount", "byteCount"] as const; + +function normalizeResultCounts(result: unknown): void { + if (!result || typeof result !== "object") return; + const r = result as Record; + for (const key of BIGINT_COUNT_FIELDS) { + if (typeof r[key] === "bigint") r[key] = Number(r[key]); + } + // EXTERNAL_LINKS entries carry the same count fields. + if (Array.isArray(r.externalLinks)) { + for (const link of r.externalLinks) normalizeResultCounts(link); + } +} + +function normalizeStatementCounts(response: T): T { + const manifest = response?.manifest as Record | undefined; + if (manifest) { + for (const key of ["totalRowCount", "totalByteCount"] as const) { + if (typeof manifest[key] === "bigint") + manifest[key] = Number(manifest[key]); + } + // Per-chunk `BaseChunkInfo` entries carry the same bigint count fields. + if (Array.isArray(manifest.chunks)) { + for (const chunk of manifest.chunks) normalizeResultCounts(chunk); + } + } + normalizeResultCounts(response?.result); + return response; +} + /** * Maximum size for inline Arrow IPC attachments (25 MiB decoded — the * Databricks Statement Execution API hard cap on INLINE responses). @@ -64,8 +106,8 @@ const MAX_INLINE_ATTACHMENT_BYTES = 25 * 1024 * 1024; /** * Safety cap on how many additional EXTERNAL_LINKS chunks * {@link SQLWarehouseConnector._resolveAllExternalLinks} will follow when the - * manifest omits `total_chunk_count`. High enough to cover any real result; - * only bounds a misbehaving warehouse with a cyclic `next_chunk_index`. + * manifest omits `totalChunkCount`. High enough to cover any real result; + * only bounds a misbehaving warehouse with a cyclic `nextChunkIndex`. */ const MAX_EXTERNAL_CHUNK_FOLLOWS = 10_000; @@ -105,7 +147,7 @@ const WAREHOUSE_RUNNING_CACHE_TTL_MS = 30_000; */ export interface WarehouseStatusUpdate { /** Current state from the SDK (RUNNING | STARTING | STOPPED | STOPPING | DELETED | DELETING). */ - state: sql.State; + state: EndpointState; /** Milliseconds elapsed since `ensureWarehouseRunning` was called. */ elapsedMs: number; /** 1-based attempt counter — useful for tests and telemetry. */ @@ -203,7 +245,7 @@ export class SQLWarehouseConnector { async executeStatement( workspaceClient: WorkspaceClient, - input: sql.ExecuteStatementRequest, + input: ExecuteStatementRequest, signal?: AbortSignal, ) { const startTime = Date.now(); @@ -220,7 +262,7 @@ export class SQLWarehouseConnector { kind: SpanKind.CLIENT, attributes: { "db.system": "databricks", - "db.warehouse_id": input.warehouse_id || "", + "db.warehouse_id": input.warehouseId || "", "db.catalog": input.catalog ?? "", "db.schema": input.schema ?? "", "db.statement": input.statement?.substring(0, 500) || "", @@ -252,52 +294,52 @@ export class SQLWarehouseConnector { throw ValidationError.missingField("statement"); } - if (!input.warehouse_id) { + if (!input.warehouseId) { throw ValidationError.missingField("warehouse_id"); } - const body: sql.ExecuteStatementRequest = { + const body: ExecuteStatementRequest = { statement: input.statement, parameters: input.parameters, - warehouse_id: input.warehouse_id, + warehouseId: input.warehouseId, catalog: input.catalog, schema: input.schema, - wait_timeout: - input.wait_timeout || executeStatementDefaults.wait_timeout, + waitTimeout: + input.waitTimeout || executeStatementDefaults.waitTimeout, disposition: input.disposition || executeStatementDefaults.disposition, format: input.format || executeStatementDefaults.format, - byte_limit: input.byte_limit, - row_limit: input.row_limit, - on_wait_timeout: - input.on_wait_timeout || executeStatementDefaults.on_wait_timeout, + byteLimit: input.byteLimit, + rowLimit: input.rowLimit, + onWaitTimeout: + input.onWaitTimeout || executeStatementDefaults.onWaitTimeout, }; span.addEvent("statement.submitting", { - "db.warehouse_id": input.warehouse_id, + "db.warehouse_id": input.warehouseId, }); const response = - await workspaceClient.statementExecution.executeStatement( - body, - this._createContext(signal), - ); + await workspaceClient.statementExecution.executeStatement(body, { + signal, + }); if (!response) { throw ConnectionError.apiFailure("SQL Warehouse"); } + normalizeStatementCounts(response); const status = response.status; - const statementId = response.statement_id as string; + const statementId = response.statementId as string; span.setAttribute("db.statement_id", statementId); span.addEvent("statement.submitted", { - "db.statement_id": response.statement_id, + "db.statement_id": response.statementId, "db.status": status?.state, }); let result: - | sql.StatementResponse - | { result: { statement_id: string; status: sql.StatementStatus } }; + | StatementResponse + | { result: { statement_id: string; status: StatementStatus } }; switch (status?.state) { case "RUNNING": @@ -322,7 +364,7 @@ export class SQLWarehouseConnector { case "FAILED": throw ExecutionError.statementFailed( status.error?.message, - status.error?.error_code, + status.error?.errorCode, ); case "CANCELED": throw ExecutionError.canceled(); @@ -336,7 +378,7 @@ export class SQLWarehouseConnector { const resultData = result.result as any; const rowCount = - resultData?.data?.length ?? resultData?.data_array?.length ?? 0; + resultData?.data?.length ?? resultData?.dataArray?.length ?? 0; if (rowCount > 0) { span.setAttribute("db.result.row_count", rowCount); @@ -344,7 +386,7 @@ export class SQLWarehouseConnector { const duration = Date.now() - startTime; logger.event()?.setContext("sql-warehouse", { - warehouse_id: input.warehouse_id, + warehouse_id: input.warehouseId, rows_returned: rowCount, query_duration_ms: duration, }); @@ -385,7 +427,7 @@ export class SQLWarehouseConnector { } const attributes = { - "db.warehouse_id": input.warehouse_id, + "db.warehouse_id": input.warehouseId, "db.catalog": input.catalog ?? "", "db.schema": input.schema ?? "", "db.statement": input.statement?.substring(0, 500) || "", @@ -622,9 +664,9 @@ export class SQLWarehouseConnector { ); } - const info = await workspaceClient.warehouses.get( + const info = await workspaceClient.warehouses.getWarehouse( { id: warehouseId }, - this._createContext(signal), + { signal }, ); const state = info?.state; const summary = info?.health?.summary; @@ -650,9 +692,9 @@ export class SQLWarehouseConnector { if (!didStart) { emitter.emit("STARTING", summary); onWarehouseStartIssued?.(); - await workspaceClient.warehouses.start( + await workspaceClient.warehouses.startWarehouse( { id: warehouseId }, - this._createContext(signal), + { signal }, ); didStart = true; } else { @@ -799,15 +841,14 @@ export class SQLWarehouseConnector { }); const response = - await workspaceClient.statementExecution.getStatement( - { - statement_id: statementId, - }, - this._createContext(signal), + await workspaceClient.statementExecution.getStatementResult( + { statementId }, + { signal }, ); if (!response) { throw ConnectionError.apiFailure("SQL Warehouse"); } + normalizeStatementCounts(response); const status = response.status; @@ -837,7 +878,7 @@ export class SQLWarehouseConnector { case "FAILED": throw ExecutionError.statementFailed( status.error?.message, - status.error?.error_code, + status.error?.errorCode, ); case "CANCELED": throw ExecutionError.canceled(); @@ -871,13 +912,13 @@ export class SQLWarehouseConnector { } private async _transformDataArray( - response: sql.StatementResponse, + response: StatementResponse, workspaceClient: WorkspaceClient, signal?: AbortSignal, ) { if (response.manifest?.format === "ARROW_STREAM") { const result = response.result as - | (sql.ResultData & { attachment?: string }) + | (ResultData & { attachment?: string }) | undefined; // Inline Arrow: pass the base64 IPC attachment through unmodified so @@ -893,20 +934,20 @@ export class SQLWarehouseConnector { // rather than omitting it) — it must NOT go down the streaming path // (`streamChunks([])` rejects), so fall through to synthesize an empty // Arrow table below. - if (result?.external_links && result.external_links.length > 0) { + if (result?.externalLinks && result.externalLinks.length > 0) { return this.updateWithArrowStatus(response, workspaceClient, signal); } // Empty result with a known schema: synthesize a zero-row Arrow IPC // attachment so the client always receives an Arrow Table for // ARROW_STREAM, regardless of whether the warehouse returned data. - // Note: an empty array (`data_array: []`) is truthy, so length-check + // Note: an empty array (`dataArray: []`) is truthy, so length-check // explicitly — otherwise zero-row responses fall through to the JSON // row transform below and return `[]` JSON rows instead of an Arrow // table. const hasNoRows = - !result?.data_array || - (Array.isArray(result.data_array) && result.data_array.length === 0); + !result?.dataArray || + (Array.isArray(result.dataArray) && result.dataArray.length === 0); if (hasNoRows && response.manifest?.schema?.columns) { const synthesized = buildEmptyArrowIPCBase64( response.manifest.schema.columns, @@ -917,19 +958,19 @@ export class SQLWarehouseConnector { }; } - // Inline data_array under ARROW_STREAM (rare): fall through to the + // Inline dataArray under ARROW_STREAM (rare): fall through to the // row transform below. The hook will receive `type: "result"` rows; // callers asking for ARROW_STREAM should not hit this path with // current Databricks warehouses. } - if (!response.result?.data_array || !response.manifest?.schema?.columns) { + if (!response.result?.dataArray || !response.manifest?.schema?.columns) { return response; } const columns = response.manifest.schema.columns; - const transformedData = response.result.data_array.map((row) => { + const transformedData = response.result.dataArray.map((row) => { const obj: Record = {}; row.forEach((value, index) => { const column = columns[index]; @@ -937,7 +978,7 @@ export class SQLWarehouseConnector { // attempt to parse JSON strings for string columns if ( - column?.type_name === "STRING" && + column?.typeName === "STRING" && typeof value === "string" && value && (value[0] === "{" || value[0] === "[") @@ -955,8 +996,8 @@ export class SQLWarehouseConnector { return obj; }); - // remove data_array - const { data_array: _data_array, ...restResult } = response.result; + // remove dataArray + const { dataArray: _dataArray, ...restResult } = response.result; return { ...response, result: { @@ -978,7 +1019,7 @@ export class SQLWarehouseConnector { * mechanism used for both INLINE and EXTERNAL_LINKS. */ private _validateArrowAttachment( - response: sql.StatementResponse, + response: StatementResponse, attachment: string, ) { // Cap the size to protect against unbounded inline payloads from @@ -1006,14 +1047,16 @@ export class SQLWarehouseConnector { return { ...response, result: { - ...(response.result as sql.ResultData & { + ...(response.result as ResultData & { attachment?: string; columnNames?: string[]; }), - // `statement_id` is a top-level field, not on `ResultData` — carry it + // `statementId` is a top-level field, not on `ResultData` — carry it // onto the result (as the EXTERNAL_LINKS path does) so the route can // advertise it in `X-Appkit-Arrow-Columns-Ref` for wide inline schemas. - statement_id: response.statement_id, + // Kept as the synthetic `statement_id` key (the connector→route wire + // contract), sourced from the modular SDK's camelCase `statementId`. + statement_id: response.statementId, columnNames, }, }; @@ -1023,26 +1066,26 @@ export class SQLWarehouseConnector { } private async updateWithArrowStatus( - response: sql.StatementResponse, + response: StatementResponse, workspaceClient: WorkspaceClient, signal?: AbortSignal, ): Promise<{ result: { statement_id: string; - status: sql.StatementStatus; + status: StatementStatus; columnNames?: string[]; - external_links?: sql.ExternalLink[]; + external_links?: ExternalLink[]; refreshChunkLink?: RefreshChunkLink; }; }> { - const statementId = response.statement_id as string; + const statementId = response.statementId as string; return { result: { statement_id: statementId, status: { state: response.status?.state, error: response.status?.error, - } as sql.StatementStatus, + } as StatementStatus, columnNames: arrowColumnNames(response), // Resolve the pre-signed links for EVERY chunk in the caller's own // execution context. Streaming these directly (see @@ -1069,9 +1112,9 @@ export class SQLWarehouseConnector { /** * Resolve pre-signed links for EVERY chunk of an EXTERNAL_LINKS result. * - * The execute/getStatement response carries only the first chunk's links - * (each link, except the last, exposes `next_chunk_index`); the remaining - * chunks are fetched with `getStatementResultChunkN`. Runs in the caller's + * The execute/getStatementResult response carries only the first chunk's links + * (each link, except the last, exposes `nextChunkIndex`); the remaining + * chunks are fetched with `getResultData`. Runs in the caller's * identity context (user creds for `.obo.sql`), so there is no cross-identity * fetch. Only the tiny link metadata is resolved eagerly — the bytes still * stream one chunk at a time downstream. Without this a multi-chunk result @@ -1080,29 +1123,29 @@ export class SQLWarehouseConnector { private async _resolveAllExternalLinks( workspaceClient: WorkspaceClient, statementId: string, - response: sql.StatementResponse, + response: StatementResponse, signal?: AbortSignal, - ): Promise { - const first = response.result?.external_links; + ): Promise { + const first = response.result?.externalLinks; if (!first || first.length === 0) return first; - const links: sql.ExternalLink[] = [...first]; + const links: ExternalLink[] = [...first]; // Bound the follow loop so a warehouse returning a cyclic/never-ending // `next_chunk_index` can't spin forever. The manifest's chunk count is the // natural bound; fall back to a generous safety cap if it's absent (real // results still terminate earlier when `next_chunk_index` becomes null) so // a missing count doesn't silently truncate a genuine multi-chunk result. const maxFetches = - response.manifest?.total_chunk_count ?? MAX_EXTERNAL_CHUNK_FOLLOWS; + response.manifest?.totalChunkCount ?? MAX_EXTERNAL_CHUNK_FOLLOWS; let next = this._nextChunkIndex(first); for (let fetches = 0; next != null && fetches < maxFetches; fetches++) { if (signal?.aborted) throw ExecutionError.canceled(); - const chunk = - await workspaceClient.statementExecution.getStatementResultChunkN( - { statement_id: statementId, chunk_index: next }, - this._createContext(signal), - ); - const chunkLinks = chunk.external_links ?? []; + const chunk = await workspaceClient.statementExecution.getResultData( + { statementId, chunkIndex: next }, + { signal }, + ); + normalizeResultCounts(chunk); + const chunkLinks = chunk.externalLinks ?? []; if (chunkLinks.length === 0) break; links.push(...chunkLinks); next = this._nextChunkIndex(chunkLinks); @@ -1110,32 +1153,32 @@ export class SQLWarehouseConnector { return links; } - /** The `next_chunk_index` advertised by a chunk's links, if any. */ - private _nextChunkIndex(links: sql.ExternalLink[]): number | undefined { + /** The `nextChunkIndex` advertised by a chunk's links, if any. */ + private _nextChunkIndex(links: ExternalLink[]): number | undefined { for (const link of links) { - if (link.next_chunk_index != null) return link.next_chunk_index; + if (link.nextChunkIndex != null) return link.nextChunkIndex; } return undefined; } /** * A closure that re-mints a single chunk's pre-signed link via - * `getStatementResultChunkN`, bound to the caller's workspace client + + * `getResultData`, bound to the caller's workspace client + * statement id. Created here (in the caller's identity context) so the * streamer — which runs outside that context — can refresh an expired link - * for `.obo.sql` statements without a cross-identity `getStatement`. + * for `.obo.sql` statements without a cross-identity `getStatementResult`. */ private _makeChunkLinkRefresher( workspaceClient: WorkspaceClient, statementId: string, ): RefreshChunkLink { return async (chunkIndex, signal) => { - const chunk = - await workspaceClient.statementExecution.getStatementResultChunkN( - { statement_id: statementId, chunk_index: chunkIndex }, - this._createContext(signal), - ); - return chunk.external_links?.find((l) => l.chunk_index === chunkIndex); + const chunk = await workspaceClient.statementExecution.getResultData( + { statementId, chunkIndex }, + { signal }, + ); + normalizeResultCounts(chunk); + return chunk.externalLinks?.find((l) => l.chunkIndex === chunkIndex); }; } @@ -1147,7 +1190,7 @@ export class SQLWarehouseConnector { * the pre-signed URLs need no auth to download. */ streamExternalLinks( - chunks: sql.ExternalLink[], + chunks: ExternalLink[], signal?: AbortSignal, refresh?: RefreshChunkLink, ): AsyncGenerator { @@ -1165,10 +1208,12 @@ export class SQLWarehouseConnector { jobId: string, signal?: AbortSignal, ): Promise { - const response = await workspaceClient.statementExecution.getStatement( - { statement_id: jobId }, - this._createContext(signal), - ); + const response = + await workspaceClient.statementExecution.getStatementResult( + { statementId: jobId }, + { signal }, + ); + normalizeStatementCounts(response); return arrowColumnNames(response); } @@ -1187,25 +1232,19 @@ export class SQLWarehouseConnector { if (error instanceof AppKitError) { throw error; } + // The legacy SDK exposed the Databricks error code as `errorCode`; the + // modular SDK's `ApiError` carries it as `code` (e.g. "INVALID_PARAMETER_VALUE"). + // Read either, so callers can still branch on the stable code — notably the + // analytics arrow disposition/format fallback, which keys on + // INVALID_PARAMETER_VALUE / NOT_IMPLEMENTED to switch INLINE↔EXTERNAL_LINKS. const sdkErrorCode = - error && typeof error === "object" && "errorCode" in error - ? (error as { errorCode?: unknown }).errorCode + error && typeof error === "object" + ? ((error as { errorCode?: unknown }).errorCode ?? + (error as { code?: unknown }).code) : undefined; throw ExecutionError.statementFailed( error instanceof Error ? error.message : String(error), typeof sdkErrorCode === "string" ? sdkErrorCode : undefined, ); } - - // create context for cancellation token - private _createContext(signal?: AbortSignal) { - return new Context({ - cancellationToken: { - isCancellationRequested: signal?.aborted ?? false, - onCancellationRequested: (cb: () => void) => { - signal?.addEventListener("abort", cb, { once: true }); - }, - }, - }); - } } diff --git a/packages/appkit/src/connectors/sql-warehouse/defaults.ts b/packages/appkit/src/connectors/sql-warehouse/defaults.ts index b046a5c4a..3a57c8058 100644 --- a/packages/appkit/src/connectors/sql-warehouse/defaults.ts +++ b/packages/appkit/src/connectors/sql-warehouse/defaults.ts @@ -1,18 +1,18 @@ -import type { sql } from "../../workspace-client"; +import type { ExecuteStatementRequest } from "../../workspace-client"; interface ExecuteStatementDefaults { - wait_timeout: string; - disposition: sql.ExecuteStatementRequest["disposition"]; - format: sql.ExecuteStatementRequest["format"]; - on_wait_timeout: sql.ExecuteStatementRequest["on_wait_timeout"]; + waitTimeout: string; + disposition: ExecuteStatementRequest["disposition"]; + format: ExecuteStatementRequest["format"]; + onWaitTimeout: ExecuteStatementRequest["onWaitTimeout"]; timeout: number; } // @TODO: Make these configurable globally and validate right values export const executeStatementDefaults: ExecuteStatementDefaults = { - wait_timeout: "30s", + waitTimeout: "30s", disposition: "INLINE", format: "JSON_ARRAY", - on_wait_timeout: "CONTINUE", + onWaitTimeout: "CONTINUE", timeout: 60000, }; diff --git a/packages/appkit/src/connectors/sql-warehouse/tests/arrow-schema.test.ts b/packages/appkit/src/connectors/sql-warehouse/tests/arrow-schema.test.ts index d8f52f016..b7826e87e 100644 --- a/packages/appkit/src/connectors/sql-warehouse/tests/arrow-schema.test.ts +++ b/packages/appkit/src/connectors/sql-warehouse/tests/arrow-schema.test.ts @@ -428,11 +428,11 @@ describe("parseDatabricksType — error / robustness", () => { describe("buildEmptyArrowIPCBase64", () => { test("produces a decodable empty Arrow Table with the right schema", () => { const columns = [ - { name: "user_id", type_text: "BIGINT" }, - { name: "name", type_text: "STRING" }, - { name: "created_at", type_text: "TIMESTAMP" }, - { name: "balance", type_text: "DECIMAL(10,2)" }, - { name: "active", type_text: "BOOLEAN" }, + { name: "user_id", typeText: "BIGINT" }, + { name: "name", typeText: "STRING" }, + { name: "created_at", typeText: "TIMESTAMP" }, + { name: "balance", typeText: "DECIMAL(10,2)" }, + { name: "active", typeText: "BOOLEAN" }, ]; const b64 = buildEmptyArrowIPCBase64(columns); const buf = Buffer.from(b64, "base64"); @@ -463,9 +463,9 @@ describe("buildEmptyArrowIPCBase64", () => { test("round-trips nested types end-to-end", () => { const columns = [ - { name: "tags", type_text: "ARRAY" }, - { name: "meta", type_text: "STRUCT" }, - { name: "counts", type_text: "MAP" }, + { name: "tags", typeText: "ARRAY" }, + { name: "meta", typeText: "STRUCT" }, + { name: "counts", typeText: "MAP" }, ]; const buf = Buffer.from(buildEmptyArrowIPCBase64(columns), "base64"); const table = tableFromIPC(buf); @@ -476,8 +476,8 @@ describe("buildEmptyArrowIPCBase64", () => { expect(table.schema.fields[2]?.type).toBeInstanceOf(Map_); }); - test("falls back from type_text to type_name when type_text missing", () => { - const columns = [{ name: "id", type_name: "BIGINT" }]; + test("falls back from typeText to typeName when typeText missing", () => { + const columns = [{ name: "id", typeName: "BIGINT" }]; const buf = Buffer.from(buildEmptyArrowIPCBase64(columns), "base64"); const table = tableFromIPC(buf); expect( @@ -487,8 +487,8 @@ describe("buildEmptyArrowIPCBase64", () => { test("unknown type degrades to Utf8 without throwing", () => { const columns = [ - { name: "id", type_text: "BIGINT" }, - { name: "weird", type_text: "FUTURE_TYPE_NOT_YET_SUPPORTED" }, + { name: "id", typeText: "BIGINT" }, + { name: "weird", typeText: "FUTURE_TYPE_NOT_YET_SUPPORTED" }, ]; const buf = Buffer.from(buildEmptyArrowIPCBase64(columns), "base64"); const table = tableFromIPC(buf); @@ -499,7 +499,7 @@ describe("buildEmptyArrowIPCBase64", () => { }); test("missing column name gets a synthesized placeholder", () => { - const columns = [{ type_text: "STRING" }, { name: "", type_text: "INT" }]; + const columns = [{ typeText: "STRING" }, { name: "", typeText: "INT" }]; const buf = Buffer.from(buildEmptyArrowIPCBase64(columns), "base64"); const table = tableFromIPC(buf); expect(table.schema.fields[0]?.name).toBe("column_0"); diff --git a/packages/appkit/src/connectors/sql-warehouse/tests/client.test.ts b/packages/appkit/src/connectors/sql-warehouse/tests/client.test.ts index 5a945b0cc..8344df2fc 100644 --- a/packages/appkit/src/connectors/sql-warehouse/tests/client.test.ts +++ b/packages/appkit/src/connectors/sql-warehouse/tests/client.test.ts @@ -1,7 +1,10 @@ import { tableFromIPC } from "apache-arrow"; import { describe, expect, test, vi } from "vitest"; -import type { sql } from "../../../workspace-client"; +import type { + ExternalLink, + StatementResponse, +} from "../../../workspace-client"; vi.mock("../../../telemetry", () => { const mockMeter = { @@ -40,11 +43,11 @@ function createConnector() { // `_transformDataArray` is async — it paginates multi-chunk EXTERNAL_LINKS // results. The workspace client is only touched when following -// `next_chunk_index`, so a bare stub suffices for the inline / JSON / +// `nextChunkIndex`, so a bare stub suffices for the inline / JSON / // single-chunk cases; the multi-chunk tests pass a real mock. function transform( connector: SQLWarehouseConnector, - response: sql.StatementResponse, + response: StatementResponse, workspaceClient: unknown = {}, ) { return (connector as any)._transformDataArray(response, workspaceClient); @@ -58,11 +61,11 @@ const REAL_ARROW_ATTACHMENT = describe("SQLWarehouseConnector._transformDataArray", () => { describe("classic warehouse (JSON_ARRAY + INLINE)", () => { - test("transforms data_array rows into named objects", async () => { + test("transforms dataArray rows into named objects", async () => { const connector = createConnector(); // Real response shape from classic warehouse: INLINE + JSON_ARRAY const response = { - statement_id: "stmt-1", + statementId: "stmt-1", status: { state: "SUCCEEDED" }, manifest: { format: "JSON_ARRAY", @@ -71,14 +74,14 @@ describe("SQLWarehouseConnector._transformDataArray", () => { columns: [ { name: "test_col", - type_text: "INT", - type_name: "INT", + typeText: "INT", + typeName: "INT", position: 0, }, { name: "test_col2", - type_text: "INT", - type_name: "INT", + typeText: "INT", + typeName: "INT", position: 1, }, ], @@ -87,33 +90,33 @@ describe("SQLWarehouseConnector._transformDataArray", () => { truncated: false, }, result: { - data_array: [["1", "2"]], + dataArray: [["1", "2"]], }, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; const result = await transform(connector, response); expect(result.result.data).toEqual([{ test_col: "1", test_col2: "2" }]); - expect(result.result.data_array).toBeUndefined(); + expect(result.result.dataArray).toBeUndefined(); }); test("parses JSON strings in STRING columns", async () => { const connector = createConnector(); const response = { - statement_id: "stmt-1", + statementId: "stmt-1", status: { state: "SUCCEEDED" }, manifest: { format: "JSON_ARRAY", schema: { columns: [ - { name: "id", type_name: "INT" }, - { name: "metadata", type_name: "STRING" }, + { name: "id", typeName: "INT" }, + { name: "metadata", typeName: "STRING" }, ], }, }, result: { - data_array: [["1", '{"key":"value"}']], + dataArray: [["1", '{"key":"value"}']], }, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; const result = await transform(connector, response); expect(result.result.data[0].metadata).toEqual({ key: "value" }); @@ -125,26 +128,26 @@ describe("SQLWarehouseConnector._transformDataArray", () => { const connector = createConnector(); // Real response shape from classic warehouse: EXTERNAL_LINKS + ARROW_STREAM const response = { - statement_id: "stmt-1", + statementId: "stmt-1", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM", schema: { columns: [ - { name: "test_col", type_name: "INT" }, - { name: "test_col2", type_name: "INT" }, + { name: "test_col", typeName: "INT" }, + { name: "test_col2", typeName: "INT" }, ], }, }, result: { - external_links: [ + externalLinks: [ { - external_link: "https://storage.example.com/chunk0", + externalLink: "https://storage.example.com/chunk0", expiration: "2026-04-15T00:00:00Z", }, ], }, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; const result = await transform(connector, response); expect(result.result.statement_id).toBe("stmt-1"); @@ -156,9 +159,9 @@ describe("SQLWarehouseConnector._transformDataArray", () => { test("passes attachment through unchanged for client-side decoding", async () => { const connector = createConnector(); // Real response shape from serverless warehouse: INLINE + ARROW_STREAM - // Data arrives in result.attachment as base64-encoded Arrow IPC, not data_array. + // Data arrives in result.attachment as base64-encoded Arrow IPC, not dataArray. const response = { - statement_id: "00000001-test-stmt", + statementId: "00000001-test-stmt", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM", @@ -167,30 +170,30 @@ describe("SQLWarehouseConnector._transformDataArray", () => { columns: [ { name: "test_col", - type_text: "INT", - type_name: "INT", + typeText: "INT", + typeName: "INT", position: 0, }, { name: "test_col2", - type_text: "INT", - type_name: "INT", + typeText: "INT", + typeName: "INT", position: 1, }, ], - total_chunk_count: 1, - chunks: [{ chunk_index: 0, row_offset: 0, row_count: 1 }], + totalChunkCount: 1, + chunks: [{ chunkIndex: 0, row_offset: 0, row_count: 1 }], total_row_count: 1, }, truncated: false, }, result: { - chunk_index: 0, + chunkIndex: 0, row_offset: 0, row_count: 1, attachment: REAL_ARROW_ATTACHMENT, }, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; const result = await transform(connector, response); expect(result.result.attachment).toBe(REAL_ARROW_ATTACHMENT); @@ -206,56 +209,56 @@ describe("SQLWarehouseConnector._transformDataArray", () => { test("preserves manifest and status alongside attachment", async () => { const connector = createConnector(); const response = { - statement_id: "00000001-test-stmt", + statementId: "00000001-test-stmt", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM", schema: { columns: [ - { name: "test_col", type_name: "INT" }, - { name: "test_col2", type_name: "INT" }, + { name: "test_col", typeName: "INT" }, + { name: "test_col2", typeName: "INT" }, ], }, }, result: { - chunk_index: 0, + chunkIndex: 0, row_count: 1, attachment: REAL_ARROW_ATTACHMENT, }, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; const result = await transform(connector, response); // Manifest, statement_id, and attachment are all preserved expect(result.manifest.format).toBe("ARROW_STREAM"); - expect(result.statement_id).toBe("00000001-test-stmt"); + expect(result.statementId).toBe("00000001-test-stmt"); expect(result.result.attachment).toBe(REAL_ARROW_ATTACHMENT); }); test("synthesizes an empty Arrow IPC attachment for empty results so the client always gets a Table", async () => { const connector = createConnector(); - // Empty result: no attachment, no data_array, no external_links — but + // Empty result: no attachment, no dataArray, no external_links — but // the manifest still describes the schema. The connector should fill in // `attachment` with a zero-row Arrow IPC matching the schema. const response = { - statement_id: "stmt-empty", + statementId: "stmt-empty", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM", schema: { columns: [ - { name: "user_id", type_text: "BIGINT", type_name: "BIGINT" }, - { name: "name", type_text: "STRING", type_name: "STRING" }, + { name: "user_id", typeText: "BIGINT", typeName: "BIGINT" }, + { name: "name", typeText: "STRING", typeName: "STRING" }, { name: "balance", - type_text: "DECIMAL(10,2)", - type_name: "DECIMAL", + typeText: "DECIMAL(10,2)", + typeName: "DECIMAL", }, ], }, total_row_count: 0, }, result: {}, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; const transformed = await transform(connector, response); const attachment: string = transformed.result.attachment; @@ -275,18 +278,18 @@ describe("SQLWarehouseConnector._transformDataArray", () => { test("does NOT synthesize an attachment when external_links are present", async () => { const connector = createConnector(); const response = { - statement_id: "stmt-ext", + statementId: "stmt-ext", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM", - schema: { columns: [{ name: "x", type_text: "INT" }] }, + schema: { columns: [{ name: "x", typeText: "INT" }] }, }, result: { - external_links: [ - { external_link: "https://example.com/x", expiration: "9999" }, + externalLinks: [ + { externalLink: "https://example.com/x", expiration: "9999" }, ], }, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; const transformed = await transform(connector, response); // External-links path returns the statement_id projection — no attachment. @@ -296,21 +299,21 @@ describe("SQLWarehouseConnector._transformDataArray", () => { test("empty external_links array is a zero-row result → synthesizes an empty table (not the streaming path)", async () => { const connector = createConnector(); - // Some warehouses emit `external_links: []` for a zero-row result rather + // Some warehouses emit `externalLinks: []` for a zero-row result rather // than omitting it. An empty array must NOT go down the streaming path // (streamChunks([]) rejects) — synthesize an empty Arrow table instead. const response = { - statement_id: "stmt-empty-ext", + statementId: "stmt-empty-ext", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM", schema: { - columns: [{ name: "x", type_text: "INT", type_name: "INT" }], + columns: [{ name: "x", typeText: "INT", typeName: "INT" }], }, total_row_count: 0, }, - result: { external_links: [] }, - } as unknown as sql.StatementResponse; + result: { externalLinks: [] }, + } as unknown as StatementResponse; const transformed = await transform(connector, response); const attachment: string = transformed.result.attachment; @@ -323,11 +326,11 @@ describe("SQLWarehouseConnector._transformDataArray", () => { test("does NOT synthesize an attachment when schema is missing", async () => { const connector = createConnector(); const response = { - statement_id: "stmt-no-schema", + statementId: "stmt-no-schema", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM" }, result: {}, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; const transformed = await transform(connector, response); // Without a schema we cannot build a Table — pass through unchanged. @@ -340,11 +343,11 @@ describe("SQLWarehouseConnector._transformDataArray", () => { // base64 chars decodes to ~27 MiB, comfortably above the limit. const oversized = "A".repeat(36 * 1024 * 1024); const response = { - statement_id: "stmt-oversized", + statementId: "stmt-oversized", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM" }, result: { attachment: oversized }, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; await expect(transform(connector, response)).rejects.toThrow( /exceeds maximum size/, @@ -352,28 +355,28 @@ describe("SQLWarehouseConnector._transformDataArray", () => { }); }); - describe("ARROW_STREAM with data_array (hypothetical inline variant)", () => { - test("transforms data_array like JSON_ARRAY path", async () => { + describe("ARROW_STREAM with dataArray (hypothetical inline variant)", () => { + test("transforms dataArray like JSON_ARRAY path", async () => { const connector = createConnector(); const response = { - statement_id: "stmt-1", + statementId: "stmt-1", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM", schema: { columns: [ - { name: "id", type_name: "INT" }, - { name: "value", type_name: "STRING" }, + { name: "id", typeName: "INT" }, + { name: "value", typeName: "STRING" }, ], }, }, result: { - data_array: [ + dataArray: [ ["1", "hello"], ["2", "world"], ], }, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; const result = await transform(connector, response); expect(result.result.data).toEqual([ @@ -384,88 +387,88 @@ describe("SQLWarehouseConnector._transformDataArray", () => { }); describe("edge cases", () => { - test("returns response unchanged when no data_array, attachment, or schema", async () => { + test("returns response unchanged when no dataArray, attachment, or schema", async () => { const connector = createConnector(); const response = { - statement_id: "stmt-1", + statementId: "stmt-1", status: { state: "SUCCEEDED" }, manifest: { format: "JSON_ARRAY" }, result: {}, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; const result = await transform(connector, response); expect(result).toBe(response); }); - test("attachment takes priority over data_array when both present", async () => { + test("attachment takes priority over dataArray when both present", async () => { const connector = createConnector(); const response = { - statement_id: "stmt-1", + statementId: "stmt-1", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM", schema: { columns: [ - { name: "test_col", type_name: "INT" }, - { name: "test_col2", type_name: "INT" }, + { name: "test_col", typeName: "INT" }, + { name: "test_col2", typeName: "INT" }, ], }, }, result: { attachment: REAL_ARROW_ATTACHMENT, - data_array: [["999", "999"]], + dataArray: [["999", "999"]], }, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; const result = await transform(connector, response); - // Should pass attachment through (client decodes), not transform data_array + // Should pass attachment through (client decodes), not transform dataArray expect(result.result.attachment).toBe(REAL_ARROW_ATTACHMENT); expect(result.result.data).toBeUndefined(); }); }); describe("multi-chunk EXTERNAL_LINKS pagination", () => { - function multiChunkResponse(totalChunks: number): sql.StatementResponse { + function multiChunkResponse(totalChunks: number): StatementResponse { return { - statement_id: "stmt-multi", + statementId: "stmt-multi", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM", - total_chunk_count: totalChunks, - schema: { columns: [{ name: "x", type_name: "INT" }] }, + totalChunkCount: totalChunks, + schema: { columns: [{ name: "x", typeName: "INT" }] }, }, result: { - external_links: [ + externalLinks: [ { - chunk_index: 0, - external_link: "https://example.com/chunk0", - next_chunk_index: 1, + chunkIndex: 0, + externalLink: "https://example.com/chunk0", + nextChunkIndex: 1, }, ], }, - } as unknown as sql.StatementResponse; + } as unknown as StatementResponse; } - test("follows next_chunk_index to resolve every chunk's links", async () => { + test("follows nextChunkIndex to resolve every chunk's links", async () => { const connector = createConnector(); - const getStatementResultChunkN = vi + const getResultData = vi .fn() .mockResolvedValueOnce({ - external_links: [ + externalLinks: [ { - chunk_index: 1, - external_link: "https://example.com/chunk1", - next_chunk_index: 2, + chunkIndex: 1, + externalLink: "https://example.com/chunk1", + nextChunkIndex: 2, }, ], }) .mockResolvedValueOnce({ - external_links: [ - { chunk_index: 2, external_link: "https://example.com/chunk2" }, + externalLinks: [ + { chunkIndex: 2, externalLink: "https://example.com/chunk2" }, ], }); const workspaceClient = { - statementExecution: { getStatementResultChunkN }, + statementExecution: { getResultData }, }; const result = await transform( @@ -474,16 +477,14 @@ describe("SQLWarehouseConnector._transformDataArray", () => { workspaceClient, ); - expect(getStatementResultChunkN).toHaveBeenCalledTimes(2); - expect(getStatementResultChunkN).toHaveBeenNthCalledWith( + expect(getResultData).toHaveBeenCalledTimes(2); + expect(getResultData).toHaveBeenNthCalledWith( 1, - expect.objectContaining({ statement_id: "stmt-multi", chunk_index: 1 }), + expect.objectContaining({ statementId: "stmt-multi", chunkIndex: 1 }), expect.anything(), ); expect( - result.result.external_links.map( - (l: sql.ExternalLink) => l.external_link, - ), + result.result.external_links.map((l: ExternalLink) => l.externalLink), ).toEqual([ "https://example.com/chunk0", "https://example.com/chunk1", @@ -491,20 +492,20 @@ describe("SQLWarehouseConnector._transformDataArray", () => { ]); }); - test("is bounded by total_chunk_count when next_chunk_index never terminates", async () => { + test("is bounded by totalChunkCount when nextChunkIndex never terminates", async () => { const connector = createConnector(); // Misbehaving warehouse: always advertises another chunk. - const getStatementResultChunkN = vi.fn().mockResolvedValue({ - external_links: [ + const getResultData = vi.fn().mockResolvedValue({ + externalLinks: [ { - chunk_index: 1, - external_link: "https://example.com/loop", - next_chunk_index: 99, + chunkIndex: 1, + externalLink: "https://example.com/loop", + nextChunkIndex: 99, }, ], }); const workspaceClient = { - statementExecution: { getStatementResultChunkN }, + statementExecution: { getResultData }, }; const result = await transform( @@ -513,8 +514,8 @@ describe("SQLWarehouseConnector._transformDataArray", () => { workspaceClient, ); - // Terminates (no hang) — capped at total_chunk_count fetches. - expect(getStatementResultChunkN).toHaveBeenCalledTimes(2); + // Terminates (no hang) — capped at totalChunkCount fetches. + expect(getResultData).toHaveBeenCalledTimes(2); expect(result.result.external_links.length).toBeGreaterThan(0); }); }); diff --git a/packages/appkit/src/connectors/sql-warehouse/warehouse-status-emitter.ts b/packages/appkit/src/connectors/sql-warehouse/warehouse-status-emitter.ts index aba8488c3..a9061f61d 100644 --- a/packages/appkit/src/connectors/sql-warehouse/warehouse-status-emitter.ts +++ b/packages/appkit/src/connectors/sql-warehouse/warehouse-status-emitter.ts @@ -1,5 +1,5 @@ import type { Span } from "../../telemetry"; -import type { sql } from "../../workspace-client"; +import type { EndpointState } from "../../workspace-client"; import type { WarehouseStatusUpdate } from "./client"; /** @@ -10,7 +10,7 @@ import type { WarehouseStatusUpdate } from "./client"; */ export class WarehouseStatusEmitter { attempt = 0; - private lastEmittedState: sql.State | null = null; + private lastEmittedState: EndpointState | null = null; constructor( private readonly span: Span, @@ -18,7 +18,7 @@ export class WarehouseStatusEmitter { private readonly onStatus: (update: WarehouseStatusUpdate) => void, ) {} - emit(state: sql.State, summary: string | undefined): void { + emit(state: EndpointState, summary: string | undefined): void { this.attempt += 1; this.span.addEvent("warehouse.status", { "db.warehouse.state": state, diff --git a/packages/appkit/src/connectors/tests/sql-warehouse.test.ts b/packages/appkit/src/connectors/tests/sql-warehouse.test.ts index 285fa8d0b..af1480aa1 100644 --- a/packages/appkit/src/connectors/tests/sql-warehouse.test.ts +++ b/packages/appkit/src/connectors/tests/sql-warehouse.test.ts @@ -61,7 +61,7 @@ describe("SQLWarehouseConnector", () => { await expect( connector.executeStatement(mockWorkspaceClient as any, { statement: sensitiveStatement, - warehouse_id: "test-warehouse", + warehouseId: "test-warehouse", }), ).rejects.toThrow(); @@ -89,7 +89,9 @@ describe("SQLWarehouseConnector", () => { statement_id: "stmt-123", status: { state: "RUNNING" }, }), - getStatement: vi.fn().mockRejectedValue(new Error("polling timeout")), + getStatementResult: vi + .fn() + .mockRejectedValue(new Error("polling timeout")), }, config: { host: "https://test.databricks.com" }, }; @@ -97,7 +99,7 @@ describe("SQLWarehouseConnector", () => { await expect( connector.executeStatement(mockWorkspaceClient as any, { statement: "SELECT secret_data FROM vault", - warehouse_id: "test-warehouse", + warehouseId: "test-warehouse", }), ).rejects.toThrow(); @@ -118,6 +120,141 @@ describe("SQLWarehouseConnector", () => { }); }); + describe("statement error-code propagation", () => { + let connector: SQLWarehouseConnector; + + beforeEach(() => { + vi.clearAllMocks(); + connector = new SQLWarehouseConnector({ timeout: 5000 }); + }); + + // Regression: the modular `@databricks/sdk-core` `ApiError` carries the + // Databricks error code on `.code`, whereas the legacy SDK used + // `.errorCode`. The analytics arrow disposition/format fallback keys on + // this code ("INVALID_PARAMETER_VALUE" / "NOT_IMPLEMENTED") to switch + // INLINE→EXTERNAL_LINKS, so the connector MUST surface either field as + // `ExecutionError.errorCode` — reading only `.errorCode` broke every arrow + // query (the INLINE+ARROW_STREAM probe rejection went unrecognized). + test("surfaces the modular SDK ApiError.code as ExecutionError.errorCode", async () => { + const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {}); + + class FakeApiError extends Error { + readonly code = "INVALID_PARAMETER_VALUE"; + } + const mockWorkspaceClient = { + statementExecution: { + executeStatement: vi + .fn() + .mockRejectedValue( + new FakeApiError( + "Incompatible parameters: The format field must be JSON_ARRAY when the disposition field is INLINE.", + ), + ), + }, + config: { host: "https://test.databricks.com" }, + }; + + await expect( + connector.executeStatement(mockWorkspaceClient as any, { + statement: "SELECT 1", + warehouseId: "test-warehouse", + disposition: "INLINE", + format: "ARROW_STREAM", + }), + ).rejects.toMatchObject({ errorCode: "INVALID_PARAMETER_VALUE" }); + + errorSpy.mockRestore(); + }); + + // A failed statement STATUS (not a thrown ApiError) still carries the code + // on `status.error.errorCode` — the SDK unmarshals `error_code` there, so + // that path was already correct and must stay so. + test("surfaces status.error.errorCode from a FAILED statement status", async () => { + const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {}); + + const mockWorkspaceClient = { + statementExecution: { + executeStatement: vi.fn().mockResolvedValue({ + statementId: "stmt-123", + status: { + state: "FAILED", + error: { + errorCode: "INVALID_PARAMETER_VALUE", + message: "bad parameter", + }, + }, + }), + }, + config: { host: "https://test.databricks.com" }, + }; + + await expect( + connector.executeStatement(mockWorkspaceClient as any, { + statement: "SELECT 1", + warehouseId: "test-warehouse", + }), + ).rejects.toMatchObject({ errorCode: "INVALID_PARAMETER_VALUE" }); + + errorSpy.mockRestore(); + }); + }); + + describe("bigint count normalization", () => { + let connector: SQLWarehouseConnector; + + beforeEach(() => { + vi.clearAllMocks(); + connector = new SQLWarehouseConnector({ timeout: 5000 }); + }); + + // Regression: the modular SDK types rowCount/byteCount/rowOffset (and the + // per-chunk BaseChunkInfo counts) as `bigint`, whereas the legacy SDK used + // `number`. Reyden's INLINE+ARROW_STREAM result is cached by the analytics + // arrow path, and `JSON.stringify` throws ("Do not know how to serialize a + // BigInt") on any surviving bigint — which broke EVERY query on Reyden. The + // connector must coerce these to `number` at the SDK boundary so the result + // stays serializable for the cache / SSE frames. + test("coerces bigint manifest/result/chunk counts so the result is JSON-serializable", async () => { + const mockWorkspaceClient = { + statementExecution: { + executeStatement: vi.fn().mockResolvedValue({ + statementId: "stmt-1", + status: { state: "SUCCEEDED" }, + manifest: { + format: "JSON_ARRAY", + totalRowCount: 2n, + totalByteCount: 100n, + chunks: [ + { chunkIndex: 0, rowOffset: 0n, rowCount: 2n, byteCount: 100n }, + ], + schema: { columns: [{ name: "id", typeName: "INT" }] }, + }, + result: { + dataArray: [["1"], ["2"]], + rowOffset: 0n, + rowCount: 2n, + byteCount: 100n, + }, + }), + }, + config: { host: "https://test.databricks.com" }, + }; + + const out: any = await connector.executeStatement( + mockWorkspaceClient as any, + { statement: "SELECT id FROM t", warehouseId: "reyden" }, + ); + + // The arrow cache serializes exactly this — it must not throw. + expect(() => JSON.stringify(out)).not.toThrow(); + // Counts are coerced to number (legacy parity), including per-chunk ones. + expect(typeof out.manifest.totalRowCount).toBe("number"); + expect(typeof out.manifest.totalByteCount).toBe("number"); + expect(typeof out.manifest.chunks[0].byteCount).toBe("number"); + expect(typeof out.result.rowCount).toBe("number"); + }); + }); + describe("ensureWarehouseRunning", () => { let connector: SQLWarehouseConnector; @@ -137,7 +274,9 @@ describe("SQLWarehouseConnector", () => { test("emits a single RUNNING update and returns when warehouse is already running", async () => { const get = vi.fn().mockResolvedValue({ state: "RUNNING" }); const start = vi.fn(); - const wsClient = { warehouses: { get, start } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: start }, + }; const updates: any[] = []; await connector.ensureWarehouseRunning(wsClient as any, "wh-1", { @@ -158,7 +297,9 @@ describe("SQLWarehouseConnector", () => { .mockResolvedValueOnce({ state: "STARTING" }) .mockResolvedValueOnce({ state: "RUNNING" }); const start = vi.fn().mockResolvedValue(undefined); - const wsClient = { warehouses: { get, start } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: start }, + }; const updates: any[] = []; const promise = connector.ensureWarehouseRunning( @@ -191,7 +332,9 @@ describe("SQLWarehouseConnector", () => { .mockResolvedValueOnce({ state: "STARTING" }) .mockResolvedValueOnce({ state: "RUNNING" }); const start = vi.fn(); - const wsClient = { warehouses: { get, start } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: start }, + }; const updates: any[] = []; const promise = connector.ensureWarehouseRunning( @@ -212,7 +355,9 @@ describe("SQLWarehouseConnector", () => { test("rejects when warehouse is DELETED", async () => { const get = vi.fn().mockResolvedValue({ state: "DELETED" }); const start = vi.fn(); - const wsClient = { warehouses: { get, start } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: start }, + }; const updates: any[] = []; await expect( @@ -228,7 +373,9 @@ describe("SQLWarehouseConnector", () => { test("rejects when warehouse is DELETING", async () => { const get = vi.fn().mockResolvedValue({ state: "DELETING" }); const start = vi.fn(); - const wsClient = { warehouses: { get, start } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: start }, + }; const updates: any[] = []; await expect( @@ -243,7 +390,9 @@ describe("SQLWarehouseConnector", () => { test("aborts immediately when signal is already aborted", async () => { const get = vi.fn(); - const wsClient = { warehouses: { get, start: vi.fn() } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: vi.fn() }, + }; const controller = new AbortController(); controller.abort(); @@ -258,7 +407,9 @@ describe("SQLWarehouseConnector", () => { test("times out if warehouse never reaches RUNNING", async () => { const get = vi.fn().mockResolvedValue({ state: "STARTING" }); - const wsClient = { warehouses: { get, start: vi.fn() } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: vi.fn() }, + }; const promise = connector.ensureWarehouseRunning( wsClient as any, @@ -281,7 +432,7 @@ describe("SQLWarehouseConnector", () => { test("rejects when warehouse_id is empty", async () => { const wsClient = { - warehouses: { get: vi.fn(), start: vi.fn() }, + warehouses: { getWarehouse: vi.fn(), startWarehouse: vi.fn() }, }; await expect( @@ -293,7 +444,9 @@ describe("SQLWarehouseConnector", () => { test("skips the SDK round-trip on a subsequent call within the recently-running TTL", async () => { const get = vi.fn().mockResolvedValue({ state: "RUNNING" }); - const wsClient = { warehouses: { get, start: vi.fn() } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: vi.fn() }, + }; const updates1: any[] = []; await connector.ensureWarehouseRunning(wsClient as any, "wh-cache", { @@ -314,7 +467,9 @@ describe("SQLWarehouseConnector", () => { test("rejects with ConfigurationError when STOPPED and autoStart is false", async () => { const get = vi.fn().mockResolvedValue({ state: "STOPPED" }); const start = vi.fn(); - const wsClient = { warehouses: { get, start } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: start }, + }; await expect( connector.ensureWarehouseRunning(wsClient as any, "wh-no-auto", { @@ -332,7 +487,9 @@ describe("SQLWarehouseConnector", () => { .mockResolvedValueOnce({ state: "STARTING" }) .mockResolvedValueOnce({ state: "STARTING" }) .mockResolvedValueOnce({ state: "RUNNING" }); - const wsClient = { warehouses: { get, start: vi.fn() } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: vi.fn() }, + }; const updates: any[] = []; const promise = connector.ensureWarehouseRunning( @@ -356,7 +513,9 @@ describe("SQLWarehouseConnector", () => { const sensitive = "getaddrinfo ENOTFOUND adb-1234567890.10.azuredatabricks.net"; const get = vi.fn().mockRejectedValue(new Error(sensitive)); - const wsClient = { warehouses: { get, start: vi.fn() } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: vi.fn() }, + }; await expect( connector.ensureWarehouseRunning(wsClient as any, "wh-leak", { @@ -381,7 +540,9 @@ describe("SQLWarehouseConnector", () => { .mockResolvedValueOnce({ state: "STARTING" }) .mockResolvedValueOnce({ state: "RUNNING" }); const start = vi.fn().mockResolvedValue(undefined); - const wsClient = { warehouses: { get, start } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: start }, + }; const allUpdates = [0, 1, 2].map(() => [] as { state: string }[]); const waits = allUpdates.map((updates) => @@ -406,7 +567,9 @@ describe("SQLWarehouseConnector", () => { .fn() .mockResolvedValueOnce({ state: "STARTING" }) .mockResolvedValueOnce({ state: "RUNNING" }); - const wsClient = { warehouses: { get, start: vi.fn() } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: vi.fn() }, + }; const controller = new AbortController(); const aborted = connector.ensureWarehouseRunning( @@ -438,7 +601,9 @@ describe("SQLWarehouseConnector", () => { .fn() .mockResolvedValueOnce({ state: "STARTING" }) .mockResolvedValueOnce({ state: "RUNNING" }); - const wsClient = { warehouses: { get, start: vi.fn() } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: vi.fn() }, + }; const mount1 = new AbortController(); const first = connector.ensureWarehouseRunning( @@ -467,7 +632,9 @@ describe("SQLWarehouseConnector", () => { test("orphan before warehouses.start is aborted on the next microtask", async () => { const get = vi.fn().mockResolvedValue({ state: "STARTING" }); - const wsClient = { warehouses: { get, start: vi.fn() } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: vi.fn() }, + }; const controller = new AbortController(); const only = connector.ensureWarehouseRunning( @@ -485,7 +652,7 @@ describe("SQLWarehouseConnector", () => { await Promise.resolve(); expect(get).toHaveBeenCalledTimes(1); - expect(wsClient.warehouses.start).not.toHaveBeenCalled(); + expect(wsClient.warehouses.startWarehouse).not.toHaveBeenCalled(); }); test("orphan after warehouses.start runs poll to completion", async () => { @@ -495,7 +662,9 @@ describe("SQLWarehouseConnector", () => { .mockResolvedValueOnce({ state: "STARTING" }) .mockResolvedValueOnce({ state: "RUNNING" }); const start = vi.fn().mockResolvedValue(undefined); - const wsClient = { warehouses: { get, start } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: start }, + }; const controller = new AbortController(); const only = connector.ensureWarehouseRunning( @@ -532,7 +701,9 @@ describe("SQLWarehouseConnector", () => { .fn() .mockResolvedValueOnce({ state: "STARTING" }) .mockResolvedValueOnce({ state: "RUNNING" }); - const wsClient = { warehouses: { get, start: vi.fn() } }; + const wsClient = { + warehouses: { getWarehouse: get, startWarehouse: vi.fn() }, + }; let callCount = 0; const promise = connector.ensureWarehouseRunning( diff --git a/packages/appkit/src/plugins/analytics/analytics.ts b/packages/appkit/src/plugins/analytics/analytics.ts index dc3543be4..9ec29131e 100644 --- a/packages/appkit/src/plugins/analytics/analytics.ts +++ b/packages/appkit/src/plugins/analytics/analytics.ts @@ -1069,7 +1069,7 @@ export class AnalyticsPlugin extends Plugin implements ToolProvider { workspaceClient, { statement, - warehouse_id: warehouseId, + warehouseId, parameters: sqlParameters, ...formatParameters, }, diff --git a/packages/appkit/src/plugins/analytics/query.ts b/packages/appkit/src/plugins/analytics/query.ts index bcd77a817..4b57b051b 100644 --- a/packages/appkit/src/plugins/analytics/query.ts +++ b/packages/appkit/src/plugins/analytics/query.ts @@ -4,7 +4,7 @@ import { isSQLTypeMarker, type SQLTypeMarker, sql as sqlHelpers } from "shared"; import { getWorkspaceId } from "../../context"; import { ValidationError } from "../../errors"; -import type { sql } from "../../workspace-client"; +import type { StatementParameter } from "../../workspace-client"; type SQLParameterValue = SQLTypeMarker | null | undefined; @@ -37,8 +37,8 @@ export class QueryProcessor { convertToSQLParameters( query: string, parameters?: Record, - ): { statement: string; parameters: sql.StatementParameterListItem[] } { - const sqlParameters: sql.StatementParameterListItem[] = []; + ): { statement: string; parameters: StatementParameter[] } { + const sqlParameters: StatementParameter[] = []; if (parameters) { // extract all params from the query @@ -72,7 +72,7 @@ export class QueryProcessor { private _createParameter( key: string, value: SQLParameterValue, - ): sql.StatementParameterListItem | null { + ): StatementParameter | null { if (value === null || value === undefined) { return null; } diff --git a/packages/appkit/src/plugins/analytics/result-delivery.ts b/packages/appkit/src/plugins/analytics/result-delivery.ts index a0435513c..3f40439d2 100644 --- a/packages/appkit/src/plugins/analytics/result-delivery.ts +++ b/packages/appkit/src/plugins/analytics/result-delivery.ts @@ -4,7 +4,7 @@ import type { SQLTypeMarker } from "shared"; import { ExecutionError } from "../../errors"; import { createLogger } from "../../logging/logger"; import type { RefreshChunkLink } from "../../stream/arrow-stream-processor"; -import type { sql } from "../../workspace-client"; +import type { ExternalLink } from "../../workspace-client"; /** * Centralized disposition/format fallback for analytics result delivery. @@ -39,7 +39,7 @@ export interface QueryExecutor { | { attachment?: string; data?: Record[]; - external_links?: sql.ExternalLink[]; + external_links?: ExternalLink[]; columnNames?: string[]; statement_id?: string; status?: unknown; @@ -52,7 +52,7 @@ export interface QueryExecutor { /** Streams already-resolved EXTERNAL_LINKS chunks; the connector provides it. */ export interface ArrowChunkStreamer { streamExternalLinks( - chunks: sql.ExternalLink[], + chunks: ExternalLink[], signal?: AbortSignal, refresh?: RefreshChunkLink, ): AsyncGenerator; diff --git a/packages/appkit/src/plugins/analytics/tests/analytics.integration.test.ts b/packages/appkit/src/plugins/analytics/tests/analytics.integration.test.ts index e099c8350..25134989f 100644 --- a/packages/appkit/src/plugins/analytics/tests/analytics.integration.test.ts +++ b/packages/appkit/src/plugins/analytics/tests/analytics.integration.test.ts @@ -98,7 +98,7 @@ describe("Analytics Plugin Integration", () => { beforeEach(() => { mockClient.mocks.executeStatement.mockReset(); - mockClient.mocks.getStatement.mockReset(); + mockClient.mocks.getStatementResult.mockReset(); getAppQuerySpy.mockReset(); }); @@ -110,8 +110,8 @@ describe("Analytics Plugin Integration", () => { ["Bob", "25"], ]; const mockColumns = [ - { name: "name", type_name: "STRING" }, - { name: "age", type_name: "STRING" }, + { name: "name", typeName: "STRING" }, + { name: "age", typeName: "STRING" }, ]; getAppQuerySpy.mockResolvedValueOnce({ @@ -148,7 +148,7 @@ describe("Analytics Plugin Integration", () => { expect(mockClient.mocks.executeStatement).toHaveBeenCalledWith( expect.objectContaining({ statement: testQuery, - warehouse_id: "test-warehouse-id", + warehouseId: "test-warehouse-id", }), expect.anything(), ); diff --git a/packages/appkit/src/plugins/analytics/tests/analytics.test.ts b/packages/appkit/src/plugins/analytics/tests/analytics.test.ts index 5101f9424..6c5bc0b85 100644 --- a/packages/appkit/src/plugins/analytics/tests/analytics.test.ts +++ b/packages/appkit/src/plugins/analytics/tests/analytics.test.ts @@ -173,7 +173,7 @@ describe("Analytics Plugin", () => { expect.anything(), expect.objectContaining({ statement: "SELECT * FROM test", - warehouse_id: "test-warehouse-id", + warehouseId: "test-warehouse-id", }), expect.any(AbortSignal), ); @@ -241,7 +241,7 @@ describe("Analytics Plugin", () => { expect.anything(), expect.objectContaining({ statement: "SELECT * FROM users WHERE id = :user_id", - warehouse_id: "test-warehouse-id", + warehouseId: "test-warehouse-id", }), expect.any(AbortSignal), ); @@ -638,7 +638,7 @@ describe("Analytics Plugin", () => { expect.objectContaining({ statement: "SELECT * FROM test", parameters: [], - warehouse_id: "test-warehouse-id", + warehouseId: "test-warehouse-id", }), expect.any(AbortSignal), ); @@ -673,7 +673,7 @@ describe("Analytics Plugin", () => { expect.anything(), expect.objectContaining({ statement: "SELECT * FROM test", - warehouse_id: "test-warehouse-id", + warehouseId: "test-warehouse-id", disposition: "INLINE", format: "ARROW_STREAM", }), @@ -1682,7 +1682,7 @@ describe("Analytics Plugin", () => { result: { data: [] }, }), }, - warehouses: { get: warehouseGet, start: vi.fn() }, + warehouses: { getWarehouse: warehouseGet, startWarehouse: vi.fn() }, }, }); const mockReq = createMockRequest({ diff --git a/packages/appkit/src/plugins/analytics/tests/arrow-delivery.integration.test.ts b/packages/appkit/src/plugins/analytics/tests/arrow-delivery.integration.test.ts index 934e83c28..404719440 100644 --- a/packages/appkit/src/plugins/analytics/tests/arrow-delivery.integration.test.ts +++ b/packages/appkit/src/plugins/analytics/tests/arrow-delivery.integration.test.ts @@ -38,9 +38,9 @@ describe.runIf(!!warehouseId)("arrow delivery (live warehouse)", () => { client, { statement, - warehouse_id: warehouseId as string, - wait_timeout: "50s", - on_wait_timeout: "CONTINUE", + warehouseId: warehouseId as string, + waitTimeout: "50s", + onWaitTimeout: "CONTINUE", disposition: fp.disposition as never, format: fp.format as never, }, diff --git a/packages/appkit/src/plugins/analytics/tests/metric.test.ts b/packages/appkit/src/plugins/analytics/tests/metric.test.ts index bf721feee..dee6c4df2 100644 --- a/packages/appkit/src/plugins/analytics/tests/metric.test.ts +++ b/packages/appkit/src/plugins/analytics/tests/metric.test.ts @@ -731,7 +731,7 @@ describe("analytics metric route", () => { expect.objectContaining({ statement: "SELECT MEASURE(`arr`) AS `arr` FROM `cat`.`sch`.`revenue_metrics`", - warehouse_id: "test-warehouse-id", + warehouseId: "test-warehouse-id", }), expect.any(AbortSignal), ); @@ -779,7 +779,7 @@ describe("analytics metric route", () => { result: { data: [] }, }), }, - warehouses: { get: warehouseGet, start: vi.fn() }, + warehouses: { getWarehouse: warehouseGet, startWarehouse: vi.fn() }, }, }); const mockReq = createMockRequest({ diff --git a/packages/appkit/src/stream/arrow-stream-processor.ts b/packages/appkit/src/stream/arrow-stream-processor.ts index 62cab4df4..e063b6abb 100644 --- a/packages/appkit/src/stream/arrow-stream-processor.ts +++ b/packages/appkit/src/stream/arrow-stream-processor.ts @@ -1,11 +1,9 @@ import { ExecutionError, ValidationError } from "../errors"; import { createLogger } from "../logging/logger"; -import type { sql } from "../workspace-client"; +import type { ExternalLink } from "../workspace-client"; const logger = createLogger("stream:arrow"); -type ExternalLink = sql.ExternalLink; - /** * Re-mint a chunk's pre-signed URL. DBSQL external links expire in <= 15 min, * so a large result whose tail chunks are reached after the earlier chunks @@ -83,11 +81,11 @@ export class ArrowStreamProcessor { signal?: AbortSignal, refresh?: RefreshChunkLink, ): AsyncGenerator { - let externalLink = chunk.external_link; + let externalLink = chunk.externalLink; if (!externalLink) { // A missing link cannot be fixed by retrying — fail loudly. throw ExecutionError.statementFailed( - `External link missing for chunk ${chunk.chunk_index}`, + `External link missing for chunk ${chunk.chunkIndex}`, ); } @@ -114,7 +112,7 @@ export class ArrowStreamProcessor { clearTimeout(timer); if (!r.ok) { throw ExecutionError.statementFailed( - `Failed to download chunk ${chunk.chunk_index}: ${r.status} ${r.statusText}`, + `Failed to download chunk ${chunk.chunkIndex}: ${r.status} ${r.statusText}`, ); } // Keep this attempt's controller alive to drive the body read + idle @@ -134,16 +132,16 @@ export class ArrowStreamProcessor { // chunk's link — a stale URL would just 403 again on the same address. // Only meaningful before any bytes are yielded (below), which is why // this lives in the establish-response loop. - if (refresh && chunk.chunk_index != null) { + if (refresh && chunk.chunkIndex != null) { try { - const fresh = await refresh(chunk.chunk_index, signal); - if (fresh?.external_link) externalLink = fresh.external_link; + const fresh = await refresh(chunk.chunkIndex, signal); + if (fresh?.externalLink) externalLink = fresh.externalLink; } catch (refreshError) { // Keep retrying the current URL; surface the original error if // all attempts fail. logger.warn( "Failed to re-resolve link for chunk %s: %O", - chunk.chunk_index, + chunk.chunkIndex, refreshError, ); } @@ -154,7 +152,7 @@ export class ArrowStreamProcessor { if (!response || !controller) { throw ExecutionError.statementFailed( - `Failed to download chunk ${chunk.chunk_index} after ${this.options.retries} attempts: ${ + `Failed to download chunk ${chunk.chunkIndex} after ${this.options.retries} attempts: ${ lastError instanceof Error ? lastError.message : String(lastError) }`, ); @@ -194,13 +192,13 @@ export class ArrowStreamProcessor { if (signal?.aborted) throw ExecutionError.canceled(); logger.error( "Failed streaming chunk %s body: %O", - chunk.chunk_index, + chunk.chunkIndex, error, ); throw error instanceof ExecutionError ? error : ExecutionError.statementFailed( - `Failed streaming chunk ${chunk.chunk_index}: ${ + `Failed streaming chunk ${chunk.chunkIndex}: ${ error instanceof Error ? error.message : String(error) }`, ); diff --git a/packages/appkit/src/stream/tests/arrow-stream-processor.test.ts b/packages/appkit/src/stream/tests/arrow-stream-processor.test.ts index 555f87339..84d1ee031 100644 --- a/packages/appkit/src/stream/tests/arrow-stream-processor.test.ts +++ b/packages/appkit/src/stream/tests/arrow-stream-processor.test.ts @@ -1,6 +1,5 @@ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; -import type { sql } from "../../workspace-client"; import { ArrowStreamProcessor } from "../arrow-stream-processor"; /** A ReadableStream that emits the given pieces in order, then closes. */ @@ -15,10 +14,10 @@ function streamOf(...pieces: Uint8Array[]): ReadableStream { function mockChunks(count: number) { return Array.from({ length: count }, (_, i) => ({ - chunk_index: i, - external_link: `https://example.com/chunk-${i}`, - row_offset: i * 100, - row_count: 100, + chunkIndex: i, + externalLink: `https://example.com/chunk-${i}`, + rowOffset: BigInt(i * 100), + rowCount: 100n, })); } @@ -166,7 +165,7 @@ describe("ArrowStreamProcessor.streamChunks", () => { }); test("throws immediately when a chunk has no external_link", async () => { - const chunks = [{ chunk_index: 0 }] as any; + const chunks = [{ chunkIndex: 0 }] as any; await expect(drain(processor.streamChunks(chunks))).rejects.toThrow( /External link missing/, ); @@ -218,8 +217,8 @@ describe("ArrowStreamProcessor.streamChunks", () => { globalThis.fetch = fetchMock; const refresh = vi.fn(async (chunkIndex: number) => ({ - chunk_index: chunkIndex, - external_link: "https://example.com/fresh-link", + chunkIndex, + externalLink: "https://example.com/fresh-link", })); const p = new ArrowStreamProcessor({ timeout: 5000, retries: 3 }); diff --git a/packages/appkit/src/testing/fixtures.ts b/packages/appkit/src/testing/fixtures.ts index f3663b430..bb060a172 100644 --- a/packages/appkit/src/testing/fixtures.ts +++ b/packages/appkit/src/testing/fixtures.ts @@ -344,12 +344,12 @@ export function createMockWorkspaceClient() { result: { data: [] }, }), }, - // Analytics route now calls `warehouses.get` before issuing SQL to + // Analytics route now calls `warehouses.getWarehouse` before issuing SQL to // ensure the warehouse is RUNNING. Default to RUNNING so existing // tests that only care about SQL behaviour aren't affected. warehouses: { - get: vi.fn().mockResolvedValue({ state: "RUNNING" }), - start: vi.fn().mockResolvedValue(undefined), + getWarehouse: vi.fn().mockResolvedValue({ state: "RUNNING" }), + startWarehouse: vi.fn().mockResolvedValue(undefined), }, }; } @@ -503,19 +503,19 @@ export async function runWithRequestContext( */ export function createSuccessfulSQLResponse( data: Any[][], - columns: Array<{ name: string; type_name?: string }>, + columns: Array<{ name: string; typeName?: string }>, ) { return { status: { state: "SUCCEEDED" }, - statement_id: `stmt-${Date.now()}`, + statementId: `stmt-${Date.now()}`, result: { - data_array: data, + dataArray: data, }, manifest: { schema: { columns: columns.map((col) => ({ name: col.name, - type_name: col.type_name ?? "STRING", + typeName: col.typeName ?? "STRING", })), }, }, @@ -531,32 +531,32 @@ export function createFailedSQLResponse(errorMessage: string) { message: errorMessage, }, }, - statement_id: `stmt-${Date.now()}`, + statementId: `stmt-${Date.now()}`, }; } /** - * A WorkspaceClient whose `executeStatement`/`getStatement` are bare `vi.fn()`s - * (no default resolution) so a test can script exactly what SQL returns. - * `warehouses.get` defaults to RUNNING. + * A WorkspaceClient whose `executeStatement`/`getStatementResult` are bare + * `vi.fn()`s (no default resolution) so a test can script exactly what SQL + * returns. `warehouses.getWarehouse` defaults to RUNNING. */ export function createConfigurableMockWorkspaceClient() { const executeStatement = vi.fn(); - const getStatement = vi.fn(); - // Analytics route now calls `warehouses.get` before issuing SQL; default to - // RUNNING so callers that don't care about warehouse readiness don't have - // to wire it up. + const getStatementResult = vi.fn(); + // Analytics route now calls `warehouses.getWarehouse` before issuing SQL; + // default to RUNNING so callers that don't care about warehouse readiness + // don't have to wire it up. const warehousesGet = vi.fn().mockResolvedValue({ state: "RUNNING" }); const warehousesStart = vi.fn().mockResolvedValue(undefined); const client = { statementExecution: { executeStatement, - getStatement, + getStatementResult, }, warehouses: { - get: warehousesGet, - start: warehousesStart, + getWarehouse: warehousesGet, + startWarehouse: warehousesStart, }, }; @@ -564,7 +564,7 @@ export function createConfigurableMockWorkspaceClient() { client, mocks: { executeStatement, - getStatement, + getStatementResult, warehousesGet, warehousesStart, }, diff --git a/packages/appkit/src/type-generator/statement-result.ts b/packages/appkit/src/type-generator/statement-result.ts index 7ae091aaf..24620988b 100644 --- a/packages/appkit/src/type-generator/statement-result.ts +++ b/packages/appkit/src/type-generator/statement-result.ts @@ -1,5 +1,5 @@ import { createLogger } from "../logging/logger"; -import type { WorkspaceClient } from "../workspace-client"; +import type { StatementResponse, WorkspaceClient } from "../workspace-client"; import { getErrorMessage } from "./errors"; import type { DatabricksStatementExecutionResponse } from "./types"; @@ -147,6 +147,42 @@ function isFormatRejection( ); } +/** + * Adapt the modular SDK's camelCase {@link StatementResponse} onto the + * type-generator's own snake_case {@link DatabricksStatementExecutionResponse} + * — the shape every downstream DESCRIBE parser (and every mocked test) reads. + * Keeping the boundary here means only this mapper touches the SDK shape; + * {@link normalizeResultRows} and the parsers stay unchanged. `attachment` + * survives thanks to the pinned pnpm patch on `@databricks/sdk-statementexecution`. + */ +function toDescribeResponse( + r: StatementResponse, +): DatabricksStatementExecutionResponse { + return { + statement_id: r.statementId ?? "", + status: { + state: r.status?.state ?? "", + error: r.status?.error + ? { + error_code: r.status.error.errorCode, + message: r.status.error.message, + } + : undefined, + }, + manifest: r.manifest ? { format: r.manifest.format } : undefined, + result: r.result + ? { + // DESCRIBE rows are always string/null cells. Local key stays + // snake_case (`data_array`); value is the SDK's camelCase `dataArray`. + data_array: r.result.dataArray as (string | null)[][] | undefined, + attachment: r.result.attachment, + next_chunk_index: r.result.nextChunkIndex, + next_chunk_internal_link: r.result.nextChunkInternalLink, + } + : undefined, + }; +} + /** * Run a DESCRIBE and return a response whose rows are readable via * `result.data_array`, adapting to the warehouse's result-format capability. @@ -175,15 +211,17 @@ export async function describeAdaptive( let lastError: unknown; for (const format of formats) { try { - const response = (await client.statementExecution.executeStatement({ - statement, - warehouse_id: warehouseId, - // Synchronous wait: without it the call can return PENDING/RUNNING with - // no rows, which downstream misreads as a no-result degrade. - wait_timeout: "30s", - format, - disposition: "INLINE", - })) as DatabricksStatementExecutionResponse; + const response = toDescribeResponse( + await client.statementExecution.executeStatement({ + statement, + warehouseId, + // Synchronous wait: without it the call can return PENDING/RUNNING with + // no rows, which downstream misreads as a no-result degrade. + waitTimeout: "30s", + format, + disposition: "INLINE", + }), + ); const normalized = await normalizeResultRows(response); if ( normalized.status?.state === "FAILED" && diff --git a/packages/appkit/src/type-generator/tests/generate-queries.test.ts b/packages/appkit/src/type-generator/tests/generate-queries.test.ts index 3a5d3e9a4..82089f79e 100644 --- a/packages/appkit/src/type-generator/tests/generate-queries.test.ts +++ b/packages/appkit/src/type-generator/tests/generate-queries.test.ts @@ -30,7 +30,10 @@ vi.mock("../../workspace-client", async (importOriginal) => { ...actual, createWorkspaceClient: () => ({ statementExecution: { executeStatement: mocks.executeStatement }, - warehouses: { get: mocks.getWarehouse, start: mocks.startWarehouse }, + warehouses: { + getWarehouse: mocks.getWarehouse, + startWarehouse: mocks.startWarehouse, + }, }), }; }); @@ -82,9 +85,9 @@ const lastSavedQueries = () => function succeededResult(columns: [string, string, string | null][]) { return { - statement_id: "stmt-1", + statementId: "stmt-1", status: { state: "SUCCEEDED" }, - result: { data_array: columns }, + result: { dataArray: columns }, }; } @@ -108,7 +111,7 @@ async function succeededArrowAttachmentResult( "base64", ); return { - statement_id: "stmt-arrow", + statementId: "stmt-arrow", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM" }, // No data_array — rows live in the attachment, like a real INLINE Arrow @@ -203,8 +206,8 @@ describe("generateQueriesFromDescribe", () => { expect(mocks.executeStatement).toHaveBeenCalledTimes(1); expect(mocks.executeStatement.mock.calls[0][0]).toMatchObject({ - warehouse_id: "wh-123", - wait_timeout: "30s", + warehouseId: "wh-123", + waitTimeout: "30s", format: "JSON_ARRAY", disposition: "INLINE", }); @@ -214,7 +217,7 @@ describe("generateQueriesFromDescribe", () => { mocks.readdir.mockResolvedValue(["bad_table.sql"]); mocks.readFile.mockResolvedValue("SELECT * FROM bad_table"); mocks.executeStatement.mockResolvedValue({ - statement_id: "stmt-2", + statementId: "stmt-2", status: { state: "FAILED", error: { message: "Table or view not found: bad_table" }, @@ -234,7 +237,7 @@ describe("generateQueriesFromDescribe", () => { mocks.readdir.mockResolvedValue(["query.sql"]); mocks.readFile.mockResolvedValue("SELECT 1"); mocks.executeStatement.mockResolvedValue({ - statement_id: "stmt-3", + statementId: "stmt-3", status: { state: "FAILED" }, }); @@ -256,7 +259,7 @@ describe("generateQueriesFromDescribe", () => { mocks.executeStatement .mockResolvedValueOnce(succeededResult([["id", "INT", null]])) .mockResolvedValueOnce({ - statement_id: "stmt-fail", + statementId: "stmt-fail", status: { state: "FAILED", error: { message: "Table not found" }, @@ -288,7 +291,7 @@ describe("generateQueriesFromDescribe", () => { mocks.executeStatement .mockRejectedValueOnce(new Error("Connection refused")) .mockResolvedValueOnce({ - statement_id: "stmt-fail-2", + statementId: "stmt-fail-2", status: { state: "FAILED", error: { message: "Table not found" } }, }); @@ -470,7 +473,7 @@ describe("generateQueriesFromDescribe", () => { .mockResolvedValueOnce("SELECT * FROM auth_blocked"); mocks.executeStatement .mockResolvedValueOnce({ - statement_id: "stmt-syntax", + statementId: "stmt-syntax", status: { state: "FAILED", error: { message: "Table not found" }, @@ -622,7 +625,7 @@ describe("generateQueriesFromDescribe", () => { // state with no result rows. Must degrade like a transient outage, not be // misreported as EMPTY (which would discard a good cached type). mocks.executeStatement.mockResolvedValue({ - statement_id: "stmt-1", + statementId: "stmt-1", status: { state: "PENDING" }, }); @@ -657,7 +660,7 @@ describe("generateQueriesFromDescribe", () => { mocks.executeStatement .mockResolvedValueOnce(succeededResult([["id", "INT", null]])) .mockResolvedValueOnce({ - statement_id: "stmt-pending", + statementId: "stmt-pending", status: { state: "RUNNING" }, }); @@ -684,7 +687,7 @@ describe("generateQueriesFromDescribe", () => { mocks.readdir.mockResolvedValue(["broken.sql"]); mocks.readFile.mockResolvedValue("SELECT * FROM missing"); mocks.executeStatement.mockResolvedValue({ - statement_id: "stmt", + statementId: "stmt", status: { state: "FAILED", error: { message: "Table or view not found: missing" }, diff --git a/packages/appkit/src/type-generator/tests/index.test.ts b/packages/appkit/src/type-generator/tests/index.test.ts index 64edcf358..218d516f4 100644 --- a/packages/appkit/src/type-generator/tests/index.test.ts +++ b/packages/appkit/src/type-generator/tests/index.test.ts @@ -11,8 +11,37 @@ import { vi, } from "vitest"; +import type { StatementResponse } from "../../workspace-client"; import type { DatabricksStatementExecutionResponse } from "../types"; +/** + * Adapt a local snake_case describe fixture to the modular SDK's camelCase + * `StatementResponse` — the shape the mocked `executeStatement` now returns. + * `describeAdaptive` maps it back to the local shape via `toDescribeResponse`, + * so fixtures stay authored in the type-generator's own domain shape. + */ +function asSdkResponse( + r: DatabricksStatementExecutionResponse, +): StatementResponse { + return { + statementId: r.statement_id, + status: r.status && { + state: r.status.state, + error: r.status.error && { + errorCode: r.status.error.error_code, + message: r.status.error.message, + }, + }, + manifest: r.manifest && { format: r.manifest.format }, + result: r.result && { + dataArray: r.result.data_array, + attachment: r.result.attachment, + nextChunkIndex: r.result.next_chunk_index, + nextChunkInternalLink: r.result.next_chunk_internal_link, + }, + } as unknown as StatementResponse; +} + const mocks = vi.hoisted(() => ({ generateQueriesFromDescribe: vi.fn(), getWarehouseState: vi.fn(), @@ -553,7 +582,7 @@ describe("generateFromEntryPoint — metric-view emission", () => { test("non-blocking + RUNNING warehouse: DESCRIBEs run and land full schemas", async () => { writeMetricConfig(); mocks.getWarehouseState.mockResolvedValue("RUNNING"); - mocks.executeStatement.mockResolvedValue(describeResponse); + mocks.executeStatement.mockResolvedValue(asSdkResponse(describeResponse)); await expect( generateFromEntryPoint({ @@ -568,7 +597,7 @@ describe("generateFromEntryPoint — metric-view emission", () => { expect(mocks.executeStatement).toHaveBeenCalledWith( expect.objectContaining({ statement: "DESCRIBE TABLE EXTENDED `demo`.`sales`.`revenue` AS JSON", - warehouse_id: "wh-1", + warehouseId: "wh-1", }), ); const declarations = fs.readFileSync(metricFile, "utf-8"); @@ -582,7 +611,7 @@ describe("generateFromEntryPoint — metric-view emission", () => { test("blocking + RUNNING: one preflight probe, no start/wait, DESCRIBEs run", async () => { writeMetricConfig(); mocks.getWarehouseState.mockResolvedValue("RUNNING"); - mocks.executeStatement.mockResolvedValue(describeResponse); + mocks.executeStatement.mockResolvedValue(asSdkResponse(describeResponse)); await expect( generateFromEntryPoint({ @@ -754,7 +783,7 @@ describe("generateFromEntryPoint — metric-view emission", () => { mocks.getWarehouseState.mockResolvedValue("STOPPED"); mocks.startWarehouse.mockResolvedValue(undefined); mocks.waitUntilRunning.mockResolvedValue("RUNNING"); - mocks.executeStatement.mockResolvedValue(describeResponse); + mocks.executeStatement.mockResolvedValue(asSdkResponse(describeResponse)); await expect( generateFromEntryPoint({ @@ -1013,7 +1042,7 @@ describe("generateFromEntryPoint — metric-view emission", () => { test("non-blocking + RUNNING with the default fetcher: probe and DESCRIBEs share exactly one client", async () => { writeMetricConfig(); mocks.getWarehouseState.mockResolvedValue("RUNNING"); - mocks.executeStatement.mockResolvedValue(describeResponse); + mocks.executeStatement.mockResolvedValue(asSdkResponse(describeResponse)); await expect( generateFromEntryPoint({ @@ -1152,24 +1181,23 @@ describe("generateFromEntryPoint — metric cache section", () => { const outFile = path.join(cacheTestDir, "generated", "analytics.d.ts"); const metricFile = path.join(cacheTestDir, "generated", "metric-views.d.ts"); - const describeResponseFor = ( - measure: string, - ): DatabricksStatementExecutionResponse => ({ - statement_id: "stmt-mock", - status: { state: "SUCCEEDED" }, - result: { - data_array: [ - [ - JSON.stringify({ - columns: [ - { name: measure, type: "DECIMAL(38,2)", is_measure: true }, - { name: "region", type: "STRING", is_measure: false }, - ], - }), + const describeResponseFor = (measure: string): StatementResponse => + asSdkResponse({ + statement_id: "stmt-mock", + status: { state: "SUCCEEDED" }, + result: { + data_array: [ + [ + JSON.stringify({ + columns: [ + { name: measure, type: "DECIMAL(38,2)", is_measure: true }, + { name: "region", type: "STRING", is_measure: false }, + ], + }), + ], ], - ], - }, - }); + }, + }); const writeConfig = ( metricViews: Record< @@ -2079,7 +2107,7 @@ describe("generateFromEntryPoint — anti-clobber for blocking mode", () => { }; mocks.getWarehouseState.mockResolvedValue("RUNNING"); - mocks.executeStatement.mockResolvedValue(describeResponse); + mocks.executeStatement.mockResolvedValue(asSdkResponse(describeResponse)); await expect( generateFromEntryPoint({ diff --git a/packages/appkit/src/type-generator/tests/mv-registry.test.ts b/packages/appkit/src/type-generator/tests/mv-registry.test.ts index 49d28fee0..19ef34583 100644 --- a/packages/appkit/src/type-generator/tests/mv-registry.test.ts +++ b/packages/appkit/src/type-generator/tests/mv-registry.test.ts @@ -10,6 +10,7 @@ import { afterEach, beforeEach, describe, expect, test } from "vitest"; // imports it from there. import { quoteFqnForSql } from "../../../../shared/src/schemas/metric-fqn"; import { metricSourceSchema } from "../../../../shared/src/schemas/metric-source"; +import type { StatementResponse } from "../../workspace-client"; import { readMetricConfig, resolveMetricConfig } from "../mv-registry/config"; import { createWorkspaceDescribeFetcher, @@ -53,6 +54,35 @@ function mockDescribeResponse( }; } +/** + * Adapt a local snake_case describe fixture to the modular SDK's camelCase + * `StatementResponse` — the shape a mocked `executeStatement` (consumed by the + * real `createWorkspaceDescribeFetcher` → `describeAdaptive`) now returns. + * Direct `syncMetrics(resolution, fetcher)` fixtures stay in the local snake + * shape (they bypass the SDK), so only the executeStatement mocks wrap with this. + */ +function asSdkResponse( + r: DatabricksStatementExecutionResponse, +): StatementResponse { + return { + statementId: r.statement_id, + status: r.status && { + state: r.status.state, + error: r.status.error && { + errorCode: r.status.error.error_code, + message: r.status.error.message, + }, + }, + manifest: r.manifest && { format: r.manifest.format }, + result: r.result && { + dataArray: r.result.data_array, + attachment: r.result.attachment, + nextChunkIndex: r.result.next_chunk_index, + nextChunkInternalLink: r.result.next_chunk_internal_link, + }, + } as unknown as StatementResponse; +} + /** * Real Arrow IPC attachment captured live from dogfood: * DESCRIBE TABLE EXTENDED `appkit_demo`.`public`.`revenue_metrics` AS JSON @@ -326,9 +356,11 @@ describe("resolveMetricConfig — FQN naming (UC-accurate)", () => { statementExecution: { executeStatement: async (req: Record) => { statements.push(req); - return mockDescribeResponse({ - columns: [{ name: "arr", type: "DECIMAL", is_measure: true }], - }); + return asSdkResponse( + mockDescribeResponse({ + columns: [{ name: "arr", type: "DECIMAL", is_measure: true }], + }), + ); }, }, } as unknown as Parameters[0]; @@ -664,7 +696,7 @@ describe("createWorkspaceDescribeFetcher", () => { statementExecution: { executeStatement: async (req: Record) => { statements.push(req); - return mockDescribeResponse(payload); + return asSdkResponse(mockDescribeResponse(payload)); }, }, } as unknown as Parameters[0]; @@ -680,8 +712,8 @@ describe("createWorkspaceDescribeFetcher", () => { expect(statements).toHaveLength(1); expect(statements[0]).toMatchObject({ statement: "DESCRIBE TABLE EXTENDED `demo`.`sales`.`revenue` AS JSON", - warehouse_id: "wh-1", - wait_timeout: "30s", + warehouseId: "wh-1", + waitTimeout: "30s", // describeAdaptive tries JSON_ARRAY first (standard DBSQL); it falls back // to ARROW_STREAM only if the warehouse rejects that format. format: "JSON_ARRAY", @@ -700,13 +732,13 @@ describe("createWorkspaceDescribeFetcher", () => { statementExecution: { executeStatement: async (req: Record) => { statements.push(req); - return { + return asSdkResponse({ statement_id: "stmt-arrow", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM" }, // Only an attachment — no data_array (the bug's trigger condition). result: { attachment: ARROW_ATTACHMENT_B64 }, - } as DatabricksStatementExecutionResponse; + }); }, }, } as unknown as Parameters[0]; @@ -1016,7 +1048,7 @@ describe("syncMetrics", () => { const client = { statementExecution: { executeStatement: async () => - ({ + asSdkResponse({ statement_id: "stmt-chunked", status: { state: "SUCCEEDED" }, manifest: { format: "ARROW_STREAM" }, @@ -1024,7 +1056,7 @@ describe("syncMetrics", () => { attachment: ARROW_ATTACHMENT_B64, next_chunk_index: 1, }, - }) as DatabricksStatementExecutionResponse, + }), }, } as unknown as Parameters[0]; const fetcher = createWorkspaceDescribeFetcher(client, "wh-1"); diff --git a/packages/appkit/src/type-generator/tests/statement-result.test.ts b/packages/appkit/src/type-generator/tests/statement-result.test.ts index 4221cd705..d545e49ce 100644 --- a/packages/appkit/src/type-generator/tests/statement-result.test.ts +++ b/packages/appkit/src/type-generator/tests/statement-result.test.ts @@ -3,7 +3,10 @@ import path from "node:path"; import { describe, expect, test } from "vitest"; -import type { WorkspaceClient } from "../../workspace-client"; +import type { + StatementResponse, + WorkspaceClient, +} from "../../workspace-client"; import { type DescribeFormatMemo, describeAdaptive, @@ -270,6 +273,31 @@ describe("describeAdaptive", () => { | DatabricksStatementExecutionResponse | Promise; + // Adapt a local snake_case fixture to the modular SDK's camelCase + // StatementResponse — the shape executeStatement now returns; describeAdaptive + // maps it back to the local shape via toDescribeResponse. + function asSdkResponse( + r: DatabricksStatementExecutionResponse, + ): StatementResponse { + return { + statementId: r.statement_id, + status: r.status && { + state: r.status.state, + error: r.status.error && { + errorCode: r.status.error.error_code, + message: r.status.error.message, + }, + }, + manifest: r.manifest && { format: r.manifest.format }, + result: r.result && { + dataArray: r.result.data_array, + attachment: r.result.attachment, + nextChunkIndex: r.result.next_chunk_index, + nextChunkInternalLink: r.result.next_chunk_internal_link, + }, + } as unknown as StatementResponse; + } + // Minimal WorkspaceClient stub: records the formats requested and delegates // each executeStatement to behavior(format), which may resolve or throw. function stubClient(behavior: StubBehavior) { @@ -278,7 +306,7 @@ describe("describeAdaptive", () => { statementExecution: { executeStatement: async (req: { format: string }) => { formats.push(req.format); - return behavior(req.format); + return asSdkResponse(await behavior(req.format)); }, }, } as unknown as WorkspaceClient; diff --git a/packages/appkit/src/type-generator/tests/unreachable-warehouse-gate.test.ts b/packages/appkit/src/type-generator/tests/unreachable-warehouse-gate.test.ts index 6134f8348..ef0b81519 100644 --- a/packages/appkit/src/type-generator/tests/unreachable-warehouse-gate.test.ts +++ b/packages/appkit/src/type-generator/tests/unreachable-warehouse-gate.test.ts @@ -21,7 +21,7 @@ vi.mock("../../workspace-client", async (importOriginal) => { ...actual, createWorkspaceClient: () => ({ statementExecution: { executeStatement: mocks.executeStatement }, - warehouses: { get: mocks.getWarehouse, start: vi.fn() }, + warehouses: { getWarehouse: mocks.getWarehouse, startWarehouse: vi.fn() }, }), }; }); diff --git a/packages/appkit/src/type-generator/tests/warehouse-status.test.ts b/packages/appkit/src/type-generator/tests/warehouse-status.test.ts index 882188e34..4a1b0f7b3 100644 --- a/packages/appkit/src/type-generator/tests/warehouse-status.test.ts +++ b/packages/appkit/src/type-generator/tests/warehouse-status.test.ts @@ -8,15 +8,15 @@ import { } from "../warehouse-status"; /** - * Build a minimal WorkspaceClient stub exposing only `warehouses.get`, the one - * method these helpers touch. Cast through `unknown` to the SDK type so callers - * type-check without us constructing a real client. + * Build a minimal WorkspaceClient stub exposing only `warehouses.getWarehouse`, + * the one method these helpers touch. Cast through `unknown` to the SDK type so + * callers type-check without us constructing a real client. */ function makeClient(get: ReturnType): WorkspaceClient { - return { warehouses: { get } } as unknown as WorkspaceClient; + return { warehouses: { getWarehouse: get } } as unknown as WorkspaceClient; } -/** A warehouses.get resolution carrying a given lifecycle state. */ +/** A warehouses.getWarehouse resolution carrying a given lifecycle state. */ const stateResponse = (state: WarehouseState) => ({ state }); describe("getWarehouseState", () => { diff --git a/packages/appkit/src/type-generator/warehouse-status.ts b/packages/appkit/src/type-generator/warehouse-status.ts index 27a0afeb5..8aae70e5e 100644 --- a/packages/appkit/src/type-generator/warehouse-status.ts +++ b/packages/appkit/src/type-generator/warehouse-status.ts @@ -71,14 +71,14 @@ export async function getWarehouseState( client: WorkspaceClient, warehouseId: string, ): Promise { - const response = await client.warehouses.get({ id: warehouseId }); + const response = await client.warehouses.getWarehouse({ id: warehouseId }); return response.state as WarehouseState; } /** * Initiate a start of a stopped/stopping SQL warehouse. * - * Only KICKS OFF the start: the SDK's `start()` returns a Waiter, but we + * Only KICKS OFF the start: the SDK's `startWarehouse()` returns a Waiter, but we * deliberately do not `.wait()` on it. Blocking on the full cold-start isn't our * job here — {@link waitUntilRunning} is the poller that watches the warehouse * the rest of the way to RUNNING. We just nudge it out of the stopped state. @@ -90,7 +90,7 @@ export async function startWarehouse( client: WorkspaceClient, warehouseId: string, ): Promise { - await client.warehouses.start({ id: warehouseId }); + await client.warehouses.startWarehouse({ id: warehouseId }); } /** diff --git a/packages/appkit/src/workspace-client/index.ts b/packages/appkit/src/workspace-client/index.ts index 581cb79a8..a7d7e1c34 100644 --- a/packages/appkit/src/workspace-client/index.ts +++ b/packages/appkit/src/workspace-client/index.ts @@ -13,15 +13,8 @@ export { Time, TimeUnits, } from "shared"; -export type { - CancellationToken, - ClientOptions, - files, - GenieMessage, - jobs, - serving, - sql, - Waiter, - WorkspaceClient, - WorkspaceClientOptions, -} from "shared/workspace-client"; +// Forwards every wrapper type — legacy service namespaces (files/jobs/serving), +// the client option/waiter types, and the modular SDK client + model types +// (warehouses, statementExecution). `sql` is gone: its statement + warehouse +// types now come from the modular SDK. +export type * from "shared/workspace-client"; diff --git a/packages/shared/package.json b/packages/shared/package.json index c98954700..75d38084f 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -47,7 +47,12 @@ "dependencies": { "@ast-grep/napi": "0.37.0", "@clack/prompts": "1.0.1", + "@databricks/sdk-auth": "0.46.0", + "@databricks/sdk-core": "0.46.0", "@databricks/sdk-experimental": "0.17.0", + "@databricks/sdk-options": "0.46.0", + "@databricks/sdk-statementexecution": "0.46.0", + "@databricks/sdk-warehouses": "0.46.0", "@standard-schema/spec": "1.1.0", "commander": "12.1.0", "dotenv": "16.6.1", diff --git a/packages/shared/src/workspace-client/client.ts b/packages/shared/src/workspace-client/client.ts index 18ef76a17..adf30c8db 100644 --- a/packages/shared/src/workspace-client/client.ts +++ b/packages/shared/src/workspace-client/client.ts @@ -12,11 +12,19 @@ import { type LegacyWorkspaceClient, type WorkspaceClientOptions, } from "./legacy"; +import { + buildStatementExecutionClient, + buildWarehousesClient, + type StatementExecutionClient, + type WarehousesClient, +} from "./modular"; import type { WorkspaceClient } from "./types"; export class AppKitWorkspaceClient implements WorkspaceClient { readonly #opts: WorkspaceClientOptions; #legacy?: LegacyWorkspaceClient; + #warehouses?: WarehousesClient; + #statementExecution?: StatementExecutionClient; constructor(opts: WorkspaceClientOptions) { this.#opts = opts; @@ -26,8 +34,12 @@ export class AppKitWorkspaceClient implements WorkspaceClient { return this.#getLegacy().files; } - get warehouses() { - return this.#getLegacy().warehouses; + // Migrated to the modular SDK — built lazily, independent of the legacy client. + get warehouses(): WarehousesClient { + if (!this.#warehouses) { + this.#warehouses = buildWarehousesClient(this.#opts); + } + return this.#warehouses; } get genie() { @@ -38,8 +50,12 @@ export class AppKitWorkspaceClient implements WorkspaceClient { return this.#getLegacy().jobs; } - get statementExecution() { - return this.#getLegacy().statementExecution; + // Migrated to the modular SDK — built lazily, independent of the legacy client. + get statementExecution(): StatementExecutionClient { + if (!this.#statementExecution) { + this.#statementExecution = buildStatementExecutionClient(this.#opts); + } + return this.#statementExecution; } get servingEndpoints() { diff --git a/packages/shared/src/workspace-client/index.ts b/packages/shared/src/workspace-client/index.ts index 91921efeb..2b981ebec 100644 --- a/packages/shared/src/workspace-client/index.ts +++ b/packages/shared/src/workspace-client/index.ts @@ -23,3 +23,5 @@ export { TimeUnits, } from "./legacy"; export type { files, jobs, serving, sql, WorkspaceClient } from "./types"; +// Modular SDK client + model types (warehouses). +export type * from "./modular"; diff --git a/packages/shared/src/workspace-client/modular.ts b/packages/shared/src/workspace-client/modular.ts new file mode 100644 index 000000000..a9cdef32b --- /dev/null +++ b/packages/shared/src/workspace-client/modular.ts @@ -0,0 +1,159 @@ +/** + * The single module allowed to import the modular `@databricks/sdk-*` SDK + * directly — the new-SDK sibling of {@link ./legacy.ts}. Every other AppKit + * module reaches these clients through the {@link WorkspaceClient} facade and + * the type re-exports below, so the modular SDK stays isolated exactly like the + * legacy one (the oxlint `no-restricted-imports` boundary walls `@databricks/sdk-*` + * off everywhere outside `packages/shared/src/workspace-client/`). + * + * Migrated services are built here as per-service clients; the facade delegates + * their accessors to these instead of the legacy monolithic client. Currently + * `warehouses` and `statementExecution` are migrated; every other service still + * routes through `legacy.ts`. + * + * NOTE: statementExecution relies on a pinned pnpm patch + * (`patches/@databricks__sdk-statementexecution@0.46.0.patch`) that restores the + * undocumented Reyden `attachment` response field, which the SDK's generated + * unmarshal transform would otherwise strip. + */ +import { newPatCredentials } from "@databricks/sdk-auth/credentials"; +import { addToDefault, setProduct } from "@databricks/sdk-core/clientinfo"; +import type { ClientOptions } from "@databricks/sdk-options/client"; +import { StatementExecutionClient } from "@databricks/sdk-statementexecution/v1"; +import { WarehousesClient } from "@databricks/sdk-warehouses/v1"; + +import type { WorkspaceClientOptions } from "./legacy"; + +/** + * Prepend `https://` to a scheme-less host. The legacy SDK normalized the host + * this way; the modular SDK does NOT — it passes the host straight into `fetch`, + * so a bare `DATABRICKS_HOST=my-workspace.cloud.databricks.com` (the common form, + * and what the Databricks Apps runtime sets) yields `TypeError: Invalid URL`. + */ +function normalizeHost(host: string | undefined): string | undefined { + const trimmed = host?.trim(); + if (!trimmed) return undefined; + return /^https?:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`; +} + +/** + * Map wrapper options onto the modular SDK's `ClientOptions`. Mirrors + * `buildLegacyWorkspaceClient`'s auth resolution verbatim, including the + * privilege-escalation guard: check `token !== undefined` (NOT truthiness) so an + * explicitly-passed token — even an empty string — pins the PAT path and fails + * loudly at request time rather than silently authenticating as the service + * principal via the default chain (which would be an OBO privilege escalation). + */ +function mapToClientOptions(opts: WorkspaceClientOptions): ClientOptions { + const clientOptions: ClientOptions = {}; + // Resolve + scheme-normalize the host the way the legacy SDK did. Explicit + // `opts.host` wins; otherwise fall back to `DATABRICKS_HOST` (env is where the + // Apps runtime and dev set it). When a profile is selected without an explicit + // host, defer to the SDK's profile-file resolution instead of the env. + const host = normalizeHost( + opts.host ?? (opts.profile ? undefined : process.env.DATABRICKS_HOST), + ); + if (host) { + clientOptions.host = host; + } + if (opts.token !== undefined) { + clientOptions.credentials = newPatCredentials(opts.token); + } else if (opts.profile) { + clientOptions.profileOptions = { profile: opts.profile }; + } + // Neither token nor profile → leave credentials unset so the SDK walks its + // default auth chain (env vars + ~/.databrickscfg), matching the legacy `{}` case. + return clientOptions; +} + +// The modular SDK has no per-client User-Agent option; product/client-info is a +// process-global set once via `setProduct`/`addToDefault` before any client is +// built. The AppKit product/version/userAgentExtra arrive on `opts.clientOptions` +// (from `getClientOptions()`); build-time callers omit them and are left unstamped, +// preserving the legacy behavior where build-time clients carry no AppKit UA. The +// flag latches only once we actually stamp, so a first (unstamped) build-time +// client never blocks a later runtime client from stamping. +let clientInfoStamped = false; + +/** + * Coerce an arbitrary string into a valid client-info segment. The modular SDK + * validates keys as simple tokens and throws `ClientInfoError` on anything else, + * so the legacy product name `@databricks/appkit` (with `@` and `/`) is rejected + * — collapse invalid runs to `-` and trim the ends (`@databricks/appkit` → + * `databricks-appkit`). + */ +function toClientInfoKey(value: string): string { + return value.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, ""); +} + +function ensureClientInfo(opts: WorkspaceClientOptions): void { + if (clientInfoStamped) { + return; + } + const co = opts.clientOptions; + if (!co?.product || !co?.productVersion) { + return; + } + // User-Agent stamping is best-effort: a value the SDK's client-info validator + // rejects must NEVER break client construction (the legacy SDK stamped the UA + // without validating). On failure the outbound request just carries the SDK's + // default User-Agent. + try { + setProduct(toClientInfoKey(co.product), co.productVersion); + if (co.userAgentExtra) { + for (const [key, value] of Object.entries(co.userAgentExtra)) { + addToDefault(toClientInfoKey(key), String(value)); + } + } + clientInfoStamped = true; + } catch { + clientInfoStamped = true; + } +} + +/** Build a modular Warehouses client from wrapper options. */ +export function buildWarehousesClient( + opts: WorkspaceClientOptions, +): WarehousesClient { + ensureClientInfo(opts); + return new WarehousesClient(mapToClientOptions(opts)); +} + +/** Build a modular Statement Execution client from wrapper options. */ +export function buildStatementExecutionClient( + opts: WorkspaceClientOptions, +): StatementExecutionClient { + ensureClientInfo(opts); + return new StatementExecutionClient(mapToClientOptions(opts)); +} + +// ── Client type re-exports (for the facade accessor types) ─────────────── +export type { StatementExecutionClient } from "@databricks/sdk-statementexecution/v1"; +export type { WarehousesClient } from "@databricks/sdk-warehouses/v1"; + +// ── Model type re-exports ──────────────────────────────────────────────── +// AppKit modules import request/response/enum types from the wrapper rather +// than the SDK, so the import boundary holds. Type-only: the connector compares +// state against string literals, which satisfy the SDK's `Enum | (string & {})` +// field unions — no runtime enum values needed. +export type { + ColumnInfo, + Disposition, + ExecuteStatementRequest, + ExternalLink, + Format, + ResultData, + ResultManifest, + Schema, + ServiceError, + StatementParameter, + StatementResponse, + StatementStatus, + StatementStatus_State, +} from "@databricks/sdk-statementexecution/v1"; +export type { + EndpointHealth, + EndpointInfo, + EndpointState, + GetWarehouseResponse, +} from "@databricks/sdk-warehouses/v1"; diff --git a/packages/shared/src/workspace-client/tests/modular.test.ts b/packages/shared/src/workspace-client/tests/modular.test.ts new file mode 100644 index 000000000..d6d092bcd --- /dev/null +++ b/packages/shared/src/workspace-client/tests/modular.test.ts @@ -0,0 +1,113 @@ +import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; + +// The wrapper's own tests are the one place allowed to mock the SDK directly. +// Capture the `ClientOptions` the modular `WarehousesClient` constructor receives +// so we can assert how wrapper options map onto the modular SDK's config. +const { ctorOpts, patTokens, productCalls } = vi.hoisted(() => ({ + ctorOpts: [] as Array>, + patTokens: [] as string[], + productCalls: [] as Array<[string, string]>, +})); + +vi.mock("@databricks/sdk-warehouses/v1", () => ({ + WarehousesClient: vi.fn().mockImplementation((opts) => { + ctorOpts.push(opts); + return { opts }; + }), +})); +vi.mock("@databricks/sdk-statementexecution/v1", () => ({ + StatementExecutionClient: vi.fn().mockImplementation((opts) => ({ opts })), +})); +vi.mock("@databricks/sdk-auth/credentials", () => ({ + newPatCredentials: vi.fn((token: string) => { + patTokens.push(token); + return { kind: "pat", token }; + }), +})); +vi.mock("@databricks/sdk-core/clientinfo", () => ({ + setProduct: vi.fn((name: string, version: string) => { + // Mirror the real SDK: reject client-info keys that aren't simple tokens. + if (/[^A-Za-z0-9._-]/.test(name)) { + throw new Error(`Invalid key: ${name}.`); + } + productCalls.push([name, version]); + }), + addToDefault: vi.fn(), +})); + +import { buildWarehousesClient } from "../modular"; + +describe("modular mapToClientOptions (via buildWarehousesClient)", () => { + const originalHost = process.env.DATABRICKS_HOST; + + beforeEach(() => { + ctorOpts.length = 0; + patTokens.length = 0; + productCalls.length = 0; + delete process.env.DATABRICKS_HOST; + }); + + afterEach(() => { + if (originalHost === undefined) delete process.env.DATABRICKS_HOST; + else process.env.DATABRICKS_HOST = originalHost; + }); + + test("prepends https:// to a scheme-less explicit host", () => { + buildWarehousesClient({ host: "ws.cloud.databricks.com" }); + expect(ctorOpts[0].host).toBe("https://ws.cloud.databricks.com"); + }); + + test("leaves an explicit host that already has a scheme unchanged", () => { + buildWarehousesClient({ host: "https://ws.cloud.databricks.com" }); + expect(ctorOpts[0].host).toBe("https://ws.cloud.databricks.com"); + }); + + test("falls back to DATABRICKS_HOST (scheme-normalized) when no host is passed", () => { + process.env.DATABRICKS_HOST = "envhost.cloud.databricks.com"; + buildWarehousesClient({}); + expect(ctorOpts[0].host).toBe("https://envhost.cloud.databricks.com"); + }); + + test("a token takes the PAT path and pins the resolved host", () => { + buildWarehousesClient({ token: "abc", host: "https://x" }); + expect(patTokens).toEqual(["abc"]); + expect(ctorOpts[0].host).toBe("https://x"); + expect(ctorOpts[0].credentials).toEqual({ kind: "pat", token: "abc" }); + }); + + test("an empty-string token still uses PAT (no silent fall-through to default auth)", () => { + buildWarehousesClient({ token: "", host: "https://x" }); + expect(patTokens).toEqual([""]); + expect(ctorOpts[0].credentials).toEqual({ kind: "pat", token: "" }); + }); + + test("a profile sets profileOptions and defers host to the SDK (ignores env)", () => { + process.env.DATABRICKS_HOST = "envhost.cloud.databricks.com"; + buildWarehousesClient({ profile: "myprofile" }); + expect(ctorOpts[0].profileOptions).toEqual({ profile: "myprofile" }); + expect(ctorOpts[0].host).toBeUndefined(); + expect(patTokens).toEqual([]); + }); + + test("no host, no token, no profile, no env → empty options (SDK default chain)", () => { + buildWarehousesClient({}); + expect(ctorOpts[0].host).toBeUndefined(); + expect(ctorOpts[0].credentials).toBeUndefined(); + expect(ctorOpts[0].profileOptions).toBeUndefined(); + }); + + test("client-info: sanitizes an invalid product name (e.g. @databricks/appkit) rather than crashing the client build", () => { + // Regression: the modular SDK's `setProduct` rejects `@databricks/appkit` + // (INVALID_KEY), which the legacy SDK accepted. UA stamping must be + // best-effort — a bad product string must never break client construction. + const client = buildWarehousesClient({ + clientOptions: { + product: "@databricks/appkit", + productVersion: "0.64.0", + userAgentExtra: { mode: "dev" }, + }, + } as never); + expect(client).toBeDefined(); + expect(productCalls[0]).toEqual(["databricks-appkit", "0.64.0"]); + }); +}); diff --git a/packages/shared/src/workspace-client/types.ts b/packages/shared/src/workspace-client/types.ts index 398a4afe0..6d9865ace 100644 --- a/packages/shared/src/workspace-client/types.ts +++ b/packages/shared/src/workspace-client/types.ts @@ -14,10 +14,17 @@ * as each service migrates. */ import type { LegacyWorkspaceClient } from "./legacy"; +import type { StatementExecutionClient, WarehousesClient } from "./modular"; -// SDK type namespaces, re-exported so AppKit modules import them from the -// wrapper rather than the SDK directly. +// Legacy SDK type namespaces for un-migrated services, re-exported so AppKit +// modules import them from the wrapper rather than the SDK directly. `sql` +// stays only for the dev-mode warehouse listing in service-context, which reads +// the raw (snake_case) `/api/2.0/sql/warehouses` body via the still-legacy +// `apiClient` and types it as `sql.EndpointInfo[]`. Statement + warehouse +// service types now come from `./modular`. export type { files, jobs, serving, sql } from "@databricks/sdk-experimental"; +// Modular SDK client + model types (warehouses, statementExecution). +export type * from "./modular"; /** * AppKit's workspace client facade. Mirrors the multi-client shape of the @@ -31,8 +38,8 @@ export interface WorkspaceClient { /** UC Volumes / Files API. */ readonly files: LegacyWorkspaceClient["files"]; - /** SQL Warehouses. */ - readonly warehouses: LegacyWorkspaceClient["warehouses"]; + /** SQL Warehouses (modular SDK). */ + readonly warehouses: WarehousesClient; /** Genie / dashboards. */ readonly genie: LegacyWorkspaceClient["genie"]; @@ -40,8 +47,8 @@ export interface WorkspaceClient { /** Jobs. */ readonly jobs: LegacyWorkspaceClient["jobs"]; - /** Statement Execution. */ - readonly statementExecution: LegacyWorkspaceClient["statementExecution"]; + /** Statement Execution (modular SDK). */ + readonly statementExecution: StatementExecutionClient; /** Serving Endpoints. */ readonly servingEndpoints: LegacyWorkspaceClient["servingEndpoints"]; diff --git a/patches/@databricks__sdk-statementexecution@0.46.0.patch b/patches/@databricks__sdk-statementexecution@0.46.0.patch new file mode 100644 index 000000000..c206b65c4 --- /dev/null +++ b/patches/@databricks__sdk-statementexecution@0.46.0.patch @@ -0,0 +1,34 @@ +diff --git a/dist/v1/model.d.ts b/dist/v1/model.d.ts +index e8d95659ea348b384a3d32b6a3d4f754287b38b6..705b9bed203981a2f3cde5417ed8019ff3a7065c 100644 +--- a/dist/v1/model.d.ts ++++ b/dist/v1/model.d.ts +@@ -385,6 +385,8 @@ interface QueryTag { + * link is returned.) + */ + interface ResultData { ++ /** PATCH(appkit): Reyden's non-standard INLINE ARROW_STREAM payload (base64 Arrow IPC). */ ++ attachment?: string | undefined; + externalLinks?: ExternalLink[] | undefined; + /** + * The `JSON_ARRAY` format is an array of arrays of values, where each non-null value is +diff --git a/dist/v1/model.js b/dist/v1/model.js +index fc35e28bbad5e7e873c14f6492696f9086ec9280..3bd78f3ad2dea39cdc883fa0daddb940e99e83b9 100644 +--- a/dist/v1/model.js ++++ b/dist/v1/model.js +@@ -177,10 +177,15 @@ const unmarshalResultDataSchema = z.object({ + z.string() + ]).transform((v) => BigInt(v)).optional(), + next_chunk_index: z.number().optional(), +- next_chunk_internal_link: z.string().optional() ++ next_chunk_internal_link: z.string().optional(), ++ // PATCH(appkit): preserve Reyden's non-standard INLINE ARROW_STREAM `attachment` ++ // (base64 Arrow IPC). The generated schema + rebuild-transform would otherwise ++ // strip it, breaking the inline-arrow delivery path. See patches/ for rationale. ++ attachment: z.string().optional() + }).transform((d) => ({ + externalLinks: d.external_links, + dataArray: d.data_array, ++ attachment: d.attachment, + chunkIndex: d.chunk_index, + rowOffset: d.row_offset, + rowCount: d.row_count, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aec4e33c1..cfc222fb9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,11 @@ overrides: qs@<6.15.2: 6.15.2 size-sensor: 1.0.3 +patchedDependencies: + '@databricks/sdk-statementexecution@0.46.0': + hash: a0fde44d73faf28cc107a930fea00967d00dd4e74796002c77686bb5bf56569d + path: patches/@databricks__sdk-statementexecution@0.46.0.patch + importers: .: @@ -564,9 +569,24 @@ importers: '@clack/prompts': specifier: 1.0.1 version: 1.0.1 + '@databricks/sdk-auth': + specifier: 0.46.0 + version: 0.46.0 + '@databricks/sdk-core': + specifier: 0.46.0 + version: 0.46.0 '@databricks/sdk-experimental': specifier: 0.17.0 version: 0.17.0 + '@databricks/sdk-options': + specifier: 0.46.0 + version: 0.46.0 + '@databricks/sdk-statementexecution': + specifier: 0.46.0 + version: 0.46.0(patch_hash=a0fde44d73faf28cc107a930fea00967d00dd4e74796002c77686bb5bf56569d) + '@databricks/sdk-warehouses': + specifier: 0.46.0 + version: 0.46.0 '@standard-schema/spec': specifier: 1.1.0 version: 1.1.0 @@ -1926,6 +1946,14 @@ packages: engines: {node: ^20 || ^22 || ^24 || ^25, pnpm: '>=10'} hasBin: true + '@databricks/sdk-auth@0.46.0': + resolution: {integrity: sha512-cMrwxsFtpiEKFxta5dKHchKdrgmHkQ6upJ2C4OacmlHrOHJ+ChzQBVTpAiVtjX62xj+YjNgp/29IpSdKKYUVDA==} + engines: {node: '>=22.0.0'} + + '@databricks/sdk-core@0.46.0': + resolution: {integrity: sha512-Q2LAGWYIi+jyeKR9OIqvkgyde2GdzqfSG8lewxA9Xu/C9RJBBFbSfg5Nh8ZC66TKElGIosVOecoEJdbxnNMuxw==} + engines: {node: '>=22.0.0'} + '@databricks/sdk-experimental@0.15.0': resolution: {integrity: sha512-HkoMiF7dNDt6WRW0xhi7oPlBJQfxJ9suJhEZRFt08VwLMaWcw2PiF8monfHlkD4lkufEYV6CTxi5njQkciqiHA==} engines: {node: '>=22.0', npm: '>=10.0.0'} @@ -1934,6 +1962,18 @@ packages: resolution: {integrity: sha512-dOJIt4F2nBk6HKObnv7Xbmy/qLYTy2835qhXSuW0Qw1QAXui9plmCet1KqG3yeQcMTyncWGbnhjGdQi8GEGQSA==} engines: {node: '>=22.0', npm: '>=10.0.0'} + '@databricks/sdk-options@0.46.0': + resolution: {integrity: sha512-UtADlR+41rYEoOCycZvJh1g96uDN6GVWgqQk+72cHBzcxi+koxKSJXHcYRI997Sc4Fcc1d2oyAC2I2ddVhurjA==} + engines: {node: '>=22.0.0'} + + '@databricks/sdk-statementexecution@0.46.0': + resolution: {integrity: sha512-VJA3e7UHmxRxN42/mV5VtKeINME0vCz3Na3hrwmta3tZqJWZbBU7XTfUdD1yOQ5Z1JU5UIM65OlWq8gc4IzHFg==} + engines: {node: '>=22.0.0'} + + '@databricks/sdk-warehouses@0.46.0': + resolution: {integrity: sha512-9r/gbdTb6ASiWCiibCwAOF8QizqNacidIw78uwzJYKK9dbdqmWIfNK0pF/jt3BG1sUiXz2b1I6URPdX7Qi0oLg==} + engines: {node: '>=22.0.0'} + '@date-fns/tz@1.4.1': resolution: {integrity: sha512-P5LUNhtbj6YfI3iJjw5EL9eUAG6OitD0W3fWQcpQjDRc/QIsL0tRNuO1PcDvPccWL1fSTXXdE1ds+l95DV/OFA==} @@ -2600,6 +2640,10 @@ packages: '@js-sdsl/ordered-map@4.4.2': resolution: {integrity: sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==} + '@js-temporal/polyfill@0.5.1': + resolution: {integrity: sha512-hloP58zRVCRSpgDxmqCWJNlizAlUgJFqG2ypq79DCvyv9tHjRYMDOcPFjzfl/A1/YxDvRCZz8wvZvmapQnKwFQ==} + engines: {node: '>=12'} + '@jsonjoy.com/base64@1.1.2': resolution: {integrity: sha512-q6XAnWQDIMA3+FTiOYajoYqySkO+JSat0ytXGSuRdq9uXE7o92gzuQwQM14xaCRlBLGq3v5miDGC4vkVTn54xA==} engines: {node: '>=10.0'} @@ -8516,6 +8560,9 @@ packages: resolution: {integrity: sha512-ePWsvanv0DWuDRsW8dnt+R4jQ31SCRCQ7hhNcPXZPsoBZiemuZNYGf7adZdqX2D86j6rvKp3RpCxVTSb8WQlOw==} hasBin: true + jsbi@4.3.2: + resolution: {integrity: sha512-9fqMSQbhJykSeii05nxKl4m6Eqn2P6rOlYiS+C5Dr/HPIU/7yZxu5qzbs40tgaFORiw2Amd0mirjxatXYMkIew==} + jsdom@27.0.0: resolution: {integrity: sha512-lIHeR1qlIRrIN5VMccd8tI2Sgw6ieYXSVktcSHaNe3Z5nE/tcPQYQWOq00wxMvYOsz+73eAkNenVvmPC6bba9A==} engines: {node: '>=20'} @@ -13956,6 +14003,16 @@ snapshots: transitivePeerDependencies: - supports-color + '@databricks/sdk-auth@0.46.0': + dependencies: + '@databricks/sdk-core': 0.46.0 + zod: 4.3.6 + + '@databricks/sdk-core@0.46.0': + dependencies: + json-bigint: 1.0.0 + zod: 4.3.6 + '@databricks/sdk-experimental@0.15.0': dependencies: google-auth-library: 10.5.0 @@ -13974,6 +14031,29 @@ snapshots: transitivePeerDependencies: - supports-color + '@databricks/sdk-options@0.46.0': + dependencies: + '@databricks/sdk-auth': 0.46.0 + '@databricks/sdk-core': 0.46.0 + + '@databricks/sdk-statementexecution@0.46.0(patch_hash=a0fde44d73faf28cc107a930fea00967d00dd4e74796002c77686bb5bf56569d)': + dependencies: + '@databricks/sdk-auth': 0.46.0 + '@databricks/sdk-core': 0.46.0 + '@databricks/sdk-options': 0.46.0 + '@js-temporal/polyfill': 0.5.1 + json-bigint: 1.0.0 + zod: 4.3.6 + + '@databricks/sdk-warehouses@0.46.0': + dependencies: + '@databricks/sdk-auth': 0.46.0 + '@databricks/sdk-core': 0.46.0 + '@databricks/sdk-options': 0.46.0 + '@js-temporal/polyfill': 0.5.1 + json-bigint: 1.0.0 + zod: 4.3.6 + '@date-fns/tz@1.4.1': {} '@discoveryjs/json-ext@0.5.7': {} @@ -15172,6 +15252,10 @@ snapshots: '@js-sdsl/ordered-map@4.4.2': {} + '@js-temporal/polyfill@0.5.1': + dependencies: + jsbi: 4.3.2 + '@jsonjoy.com/base64@1.1.2(tslib@2.8.1)': dependencies: tslib: 2.8.1 @@ -21579,6 +21663,8 @@ snapshots: dependencies: argparse: 2.0.1 + jsbi@4.3.2: {} + jsdom@27.0.0(bufferutil@4.0.9)(postcss@8.5.6): dependencies: '@asamuzakjp/dom-selector': 6.6.2