@databricks/sql 1.17.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/DBSQLClient.d.ts +1 -1
- package/dist/DBSQLClient.js +80 -11
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLLogger.js.map +1 -1
- package/dist/DBSQLOperation.d.ts +0 -1
- package/dist/DBSQLOperation.js.map +1 -1
- package/dist/DBSQLParameter.d.ts +1 -1
- package/dist/DBSQLParameter.js +1 -1
- package/dist/DBSQLParameter.js.map +1 -1
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/AuthorizationCode.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.d.ts +0 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js +1 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthScope.js +1 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthScope.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthToken.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/index.js.map +1 -1
- package/dist/connection/auth/tokenProvider/CachedTokenProvider.js.map +1 -1
- package/dist/connection/auth/tokenProvider/ExternalTokenProvider.js.map +1 -1
- package/dist/connection/auth/tokenProvider/FederationProvider.d.ts +3 -0
- package/dist/connection/auth/tokenProvider/FederationProvider.js +14 -1
- package/dist/connection/auth/tokenProvider/FederationProvider.js.map +1 -1
- package/dist/connection/auth/tokenProvider/Token.js.map +1 -1
- package/dist/connection/auth/tokenProvider/TokenProviderAuthenticator.js.map +1 -1
- package/dist/connection/auth/tokenProvider/utils.js +3 -4
- package/dist/connection/auth/tokenProvider/utils.js.map +1 -1
- package/dist/connection/connections/HttpConnection.d.ts +0 -1
- package/dist/connection/connections/HttpConnection.js +5 -2
- package/dist/connection/connections/HttpConnection.js.map +1 -1
- package/dist/connection/connections/HttpRetryPolicy.js.map +1 -1
- package/dist/connection/connections/ThriftHttpConnection.d.ts +0 -2
- package/dist/connection/connections/ThriftHttpConnection.js.map +1 -1
- package/dist/connection/contracts/IConnectionOptions.d.ts +2 -2
- package/dist/connection/contracts/IConnectionProvider.d.ts +0 -1
- package/dist/contracts/IClientContext.d.ts +1 -0
- package/dist/contracts/IDBSQLClient.d.ts +55 -0
- package/dist/contracts/IDBSQLLogger.js +1 -1
- package/dist/contracts/IDBSQLLogger.js.map +1 -1
- package/dist/contracts/IOperation.d.ts +0 -1
- package/dist/contracts/InternalConnectionOptions.d.ts +0 -1
- package/dist/contracts/OperationStatus.js +1 -1
- package/dist/contracts/OperationStatus.js.map +1 -1
- package/dist/contracts/ResultMetadata.d.ts +0 -1
- package/dist/contracts/ResultMetadata.js +1 -1
- package/dist/contracts/ResultMetadata.js.map +1 -1
- package/dist/dto/InfoValue.d.ts +0 -1
- package/dist/dto/InfoValue.js.map +1 -1
- package/dist/dto/Status.js.map +1 -1
- package/dist/errors/OperationStateError.js +1 -1
- package/dist/errors/OperationStateError.js.map +1 -1
- package/dist/errors/RetryError.js +1 -1
- package/dist/errors/RetryError.js.map +1 -1
- package/dist/errors/StatusError.js.map +1 -1
- package/dist/hive/Commands/BaseCommand.js.map +1 -1
- package/dist/kernel/KernelArrowIpc.d.ts +0 -1
- package/dist/kernel/KernelArrowIpc.js +4 -5
- package/dist/kernel/KernelArrowIpc.js.map +1 -1
- package/dist/kernel/KernelArrowIpcDurationFix.d.ts +0 -1
- package/dist/kernel/KernelArrowIpcDurationFix.js +2 -2
- package/dist/kernel/KernelArrowIpcDurationFix.js.map +1 -1
- package/dist/kernel/KernelAuth.d.ts +106 -25
- package/dist/kernel/KernelAuth.js +337 -82
- package/dist/kernel/KernelAuth.js.map +1 -1
- package/dist/kernel/KernelBackend.d.ts +5 -4
- package/dist/kernel/KernelBackend.js +8 -7
- package/dist/kernel/KernelBackend.js.map +1 -1
- package/dist/kernel/KernelErrorMapping.js +2 -3
- package/dist/kernel/KernelErrorMapping.js.map +1 -1
- package/dist/kernel/KernelInputValidation.js +1 -1
- package/dist/kernel/KernelInputValidation.js.map +1 -1
- package/dist/kernel/KernelLogging.js +4 -5
- package/dist/kernel/KernelLogging.js.map +1 -1
- package/dist/kernel/KernelNativeLoader.d.ts +2 -3
- package/dist/kernel/KernelNativeLoader.js +3 -3
- package/dist/kernel/KernelNativeLoader.js.map +1 -1
- package/dist/kernel/KernelOperationBackend.js +2 -1
- package/dist/kernel/KernelOperationBackend.js.map +1 -1
- package/dist/kernel/KernelOperationLifecycle.js +5 -6
- package/dist/kernel/KernelOperationLifecycle.js.map +1 -1
- package/dist/kernel/KernelPositionalParams.d.ts +6 -6
- package/dist/kernel/KernelPositionalParams.js +13 -18
- package/dist/kernel/KernelPositionalParams.js.map +1 -1
- package/dist/kernel/KernelResultsProvider.d.ts +0 -1
- package/dist/kernel/KernelResultsProvider.js.map +1 -1
- package/dist/kernel/KernelServerInfo.js +2 -2
- package/dist/kernel/KernelServerInfo.js.map +1 -1
- package/dist/kernel/KernelSessionBackend.js +4 -5
- package/dist/kernel/KernelSessionBackend.js.map +1 -1
- package/dist/polyfills.js +1 -2
- package/dist/polyfills.js.map +1 -1
- package/dist/result/ArrowResultConverter.d.ts +3 -1
- package/dist/result/ArrowResultConverter.js +11 -6
- package/dist/result/ArrowResultConverter.js.map +1 -1
- package/dist/result/ArrowResultHandler.d.ts +0 -1
- package/dist/result/ArrowResultHandler.js +1 -1
- package/dist/result/ArrowResultHandler.js.map +1 -1
- package/dist/result/CloudFetchResultHandler.js +2 -2
- package/dist/result/CloudFetchResultHandler.js.map +1 -1
- package/dist/result/JsonResultHandler.js.map +1 -1
- package/dist/result/ResultSlicer.js.map +1 -1
- package/dist/result/RowSetProvider.js +1 -1
- package/dist/result/RowSetProvider.js.map +1 -1
- package/dist/result/utils.d.ts +0 -1
- package/dist/result/utils.js +4 -5
- package/dist/result/utils.js.map +1 -1
- package/dist/telemetry/CircuitBreaker.js +1 -1
- package/dist/telemetry/CircuitBreaker.js.map +1 -1
- package/dist/telemetry/DatabricksTelemetryExporter.js.map +1 -1
- package/dist/telemetry/ExceptionClassifier.js.map +1 -1
- package/dist/telemetry/FeatureFlagCache.js.map +1 -1
- package/dist/telemetry/MetricsAggregator.js.map +1 -1
- package/dist/telemetry/TelemetryClient.js.map +1 -1
- package/dist/telemetry/TelemetryClientProvider.js.map +1 -1
- package/dist/telemetry/TelemetryEventEmitter.d.ts +0 -1
- package/dist/telemetry/TelemetryEventEmitter.js.map +1 -1
- package/dist/telemetry/telemetryTypeMappers.js +2 -3
- package/dist/telemetry/telemetryTypeMappers.js.map +1 -1
- package/dist/telemetry/telemetryUtils.d.ts +10 -0
- package/dist/telemetry/telemetryUtils.js +21 -7
- package/dist/telemetry/telemetryUtils.js.map +1 -1
- package/dist/telemetry/types.js +4 -4
- package/dist/telemetry/types.js.map +1 -1
- package/dist/thrift-backend/ThriftBackend.js.map +1 -1
- package/dist/thrift-backend/ThriftOperationBackend.js +9 -3
- package/dist/thrift-backend/ThriftOperationBackend.js.map +1 -1
- package/dist/thrift-backend/ThriftSessionBackend.js +1 -2
- package/dist/thrift-backend/ThriftSessionBackend.js.map +1 -1
- package/dist/thrift-backend/wireSynthesis.js +2 -3
- package/dist/thrift-backend/wireSynthesis.js.map +1 -1
- package/dist/utils/CloseableCollection.js.map +1 -1
- package/dist/utils/OperationIterator.js.map +1 -1
- package/dist/utils/agentDetector.js +1 -1
- package/dist/utils/agentDetector.js.map +1 -1
- package/dist/utils/buildUserAgentString.js +1 -1
- package/dist/utils/buildUserAgentString.js.map +1 -1
- package/dist/utils/definedOrError.js +1 -1
- package/dist/utils/definedOrError.js.map +1 -1
- package/dist/utils/formatProgress.js +1 -1
- package/dist/utils/formatProgress.js.map +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lz4.d.ts +5 -2
- package/dist/utils/lz4.js +31 -15
- package/dist/utils/lz4.js.map +1 -1
- package/dist/utils/normalizePemBytes.d.ts +20 -0
- package/dist/utils/normalizePemBytes.js +49 -0
- package/dist/utils/normalizePemBytes.js.map +1 -0
- package/dist/utils/protocolVersion.js +8 -9
- package/dist/utils/protocolVersion.js.map +1 -1
- package/dist/utils/queryTags.js +1 -1
- package/dist/utils/queryTags.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/native/kernel/README.md +1 -1
- package/native/kernel/index.d.ts +1112 -876
- package/native/kernel/index.js +653 -265
- package/package.json +20 -20
package/native/kernel/index.d.ts
CHANGED
|
@@ -1,505 +1,557 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
|
|
4
1
|
/* auto-generated by NAPI-RS */
|
|
5
|
-
|
|
2
|
+
/* eslint-disable */
|
|
6
3
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* (`StatementSpec.statement_conf` → SEA `parameters` /
|
|
13
|
-
* Thrift `confOverlay`)
|
|
14
|
-
* - `queryTags` — convenience wrapper over `statementConf` with
|
|
15
|
-
* key `query_tags`; serialised to the same comma-separated
|
|
16
|
-
* `key:value` wire shape NodeJS Thrift's `serializeQueryTags`
|
|
17
|
-
* produces (`lib/utils/queryTags.ts`). Backslashes in keys are
|
|
18
|
-
* doubled; backslash/colon/comma in values are backslash-escaped.
|
|
4
|
+
* Opaque result-fetch handle returned by
|
|
5
|
+
* `AsyncStatement.awaitResult()`. Wraps a kernel `ResultStream`
|
|
6
|
+
* directly; structurally analogous to the sync `Statement`'s
|
|
7
|
+
* fetch-side surface (`fetchNextBatch` / `schema` /
|
|
8
|
+
* `statementId`).
|
|
19
9
|
*
|
|
20
|
-
* `
|
|
21
|
-
* `
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
10
|
+
* `cancel()` / `close()` are not exposed: the parent
|
|
11
|
+
* `AsyncStatement` owns server-side lifecycle. A `close()` here
|
|
12
|
+
* would create dual-ownership of the same statement_id with
|
|
13
|
+
* inconsistent close semantics. Callers `close()` the parent
|
|
14
|
+
* `AsyncStatement` after they're done fetching.
|
|
25
15
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* a different key order than Thrift's `serializeQueryTags` (which
|
|
30
|
-
* iterates `Object.keys(...)` in insertion order) for the same
|
|
31
|
-
* input. The SEA server is order-insensitive on conf values, so
|
|
32
|
-
* the two are functionally equivalent. If a caller needs
|
|
33
|
-
* byte-identical Thrift parity, the JS adapter pre-serialises via
|
|
34
|
-
* `serializeQueryTags` and writes the result into
|
|
35
|
-
* `statementConf["query_tags"]` directly — see
|
|
36
|
-
* `KernelSessionBackend.executeStatement` in the NodeJS driver. This
|
|
37
|
-
* path is the one the production code uses.
|
|
16
|
+
* Schema is cached at construction so it survives the underlying
|
|
17
|
+
* stream being drained; mirrors the sync `Statement.schema()`
|
|
18
|
+
* post-close contract.
|
|
38
19
|
*/
|
|
39
|
-
export
|
|
40
|
-
/**
|
|
41
|
-
* Per-statement Spark conf overlay. Merged on top of the
|
|
42
|
-
* session-level `sessionConf` at execute time; this map wins
|
|
43
|
-
* on key collisions. Unknown keys are rejected by the server.
|
|
44
|
-
*/
|
|
45
|
-
statementConf?: Record<string, string>
|
|
46
|
-
/**
|
|
47
|
-
* Query tags as key→value pairs. Serialised to a comma-
|
|
48
|
-
* separated `key:value` string (backslash-escaping `\`, `:`,
|
|
49
|
-
* `,`) and placed into `statementConf["query_tags"]`, matching
|
|
50
|
-
* NodeJS Thrift's `serializeQueryTags` wire shape. Passing
|
|
51
|
-
* both `queryTags` AND a `query_tags` key in `statementConf`
|
|
52
|
-
* raises `InvalidArgument` — the caller's intent is ambiguous
|
|
53
|
-
* so we refuse to silently pick one over the other.
|
|
54
|
-
*
|
|
55
|
-
* A **`null`** value emits a **bare key** (no colon) — e.g.
|
|
56
|
-
* `{ production: null }` → `"production"` — matching the
|
|
57
|
-
* connectors' `key`-only tag form.
|
|
58
|
-
*
|
|
59
|
-
* See the struct-level "Tag-order caveat" for the
|
|
60
|
-
* HashMap-iteration-order vs `Object.keys`-iteration-order
|
|
61
|
-
* divergence and the byte-identical-Thrift-parity workaround.
|
|
62
|
-
*/
|
|
63
|
-
queryTags?: Record<string, string | undefined | null>
|
|
20
|
+
export declare class AsyncResultHandle {
|
|
64
21
|
/**
|
|
65
|
-
* Server-
|
|
66
|
-
*
|
|
67
|
-
* `
|
|
22
|
+
* Server-issued statement id. Cached at construction; readable
|
|
23
|
+
* for log correlation. Matches the parent `AsyncStatement`'s
|
|
24
|
+
* `statementId`.
|
|
68
25
|
*/
|
|
69
|
-
|
|
26
|
+
get statementId(): string
|
|
70
27
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* `
|
|
28
|
+
* Pull the next batch of results. Returns `null` when the
|
|
29
|
+
* stream is exhausted. The returned `ArrowBatch.ipcBytes` is a
|
|
30
|
+
* complete Arrow IPC stream (schema header + 1 record-batch
|
|
31
|
+
* message), suitable for handing to `apache-arrow`'s
|
|
32
|
+
* `RecordBatchReader`. Byte-identical to the sync
|
|
33
|
+
* `Statement.fetchNextBatch()` payload for the same query.
|
|
76
34
|
*/
|
|
77
|
-
|
|
35
|
+
fetchNextBatch(): Promise<ArrowBatch | null>
|
|
78
36
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* `
|
|
83
|
-
*
|
|
84
|
-
* positional is the documented-undocumented variant. The two are
|
|
85
|
-
* mutually exclusive at the SQL level (`?` vs `:name`).
|
|
37
|
+
* Result schema as an Arrow IPC payload (schema header only,
|
|
38
|
+
* no record-batch message). Available before any batches have
|
|
39
|
+
* been fetched. Sync because the body has no `.await` —
|
|
40
|
+
* `encode_ipc_stream` is pure CPU work over the cached
|
|
41
|
+
* `Arc<Schema>`.
|
|
86
42
|
*/
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* A named bound parameter — a [`TypedValueInput`] plus its `:name`. Kept a
|
|
91
|
-
* distinct napi object (rather than an optional `name` on `TypedValueInput`)
|
|
92
|
-
* so the positional surface stays a clean ordered list with no name field.
|
|
93
|
-
*/
|
|
94
|
-
export interface NamedTypedValueInput {
|
|
95
|
-
name: string
|
|
96
|
-
sqlType: string
|
|
97
|
-
value?: string
|
|
43
|
+
schema(): ArrowSchema
|
|
98
44
|
}
|
|
45
|
+
|
|
99
46
|
/**
|
|
100
|
-
*
|
|
101
|
-
* literals are what napi-rs emits from this `#[napi(string_enum)]` — the
|
|
102
|
-
* NodeJS SEA adapter (`KernelAuth`) matches them verbatim (`'Pat'`,
|
|
103
|
-
* `'OAuthM2m'`, `'OAuthU2m'`).
|
|
47
|
+
* Opaque async-statement handle.
|
|
104
48
|
*
|
|
105
|
-
*
|
|
106
|
-
* `
|
|
107
|
-
*
|
|
108
|
-
*
|
|
49
|
+
* Returned by `Connection.submitStatement(...)` after the kernel
|
|
50
|
+
* `Statement::submit()` returns (server sent `wait_timeout=0s`, so
|
|
51
|
+
* the response carries a `statement_id` but the statement is still
|
|
52
|
+
* `Pending`/`Running`). JS drives polling via `status()` /
|
|
53
|
+
* `awaitResult()`.
|
|
54
|
+
*
|
|
55
|
+
* Concurrency shape: `status()`, `awaitResult()`, and `close()` take
|
|
56
|
+
* `inner.lock()` and hold the guard across the kernel `.await` (tokio
|
|
57
|
+
* `Mutex` is FIFO), so `status()` / `close()` queue behind any
|
|
58
|
+
* in-flight `awaitResult()` until it returns naturally. `cancel()` is
|
|
59
|
+
* the deliberate exception: it does **not** touch `inner` — it fires
|
|
60
|
+
* through the detached `AsyncStatementCanceller` (session +
|
|
61
|
+
* statement_id, captured at construction), so an explicit
|
|
62
|
+
* `stmt.cancel()` interrupts an in-flight `awaitResult()` instead of
|
|
63
|
+
* queueing behind it. The server-side cancel flips the statement
|
|
64
|
+
* terminal, which the parked `awaitResult()` poll loop observes
|
|
65
|
+
* (`Cancelled`) and returns on. The kernel's `AwaitResultCancelGuard`
|
|
66
|
+
* still covers the drop-cancel case (Promise.race / timeout)
|
|
67
|
+
* independently — see module docs.
|
|
109
68
|
*/
|
|
110
|
-
export
|
|
111
|
-
/** Personal access token (`token`). */
|
|
112
|
-
Pat = 'Pat',
|
|
113
|
-
/** OAuth 2.0 machine-to-machine — `oauthClientId` + `oauthClientSecret`. */
|
|
114
|
-
OAuthM2m = 'OAuthM2m',
|
|
69
|
+
export declare class AsyncStatement {
|
|
115
70
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
71
|
+
* Server-issued statement id. Cached at construction; readable
|
|
72
|
+
* even after `close()` so JS-side log lines can correlate
|
|
73
|
+
* against kernel / server logs which key on the same id.
|
|
118
74
|
*/
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* A single extra HTTP header as an explicit `{ name, value }` pair.
|
|
123
|
-
*
|
|
124
|
-
* An ordered list of these (`ConnectionOptions.custom_headers`) mirrors
|
|
125
|
-
* the kernel core's `Vec<(String, String)>` and the pyo3 binding's
|
|
126
|
-
* `http_headers`: order is preserved and duplicate `name`s are allowed.
|
|
127
|
-
* A struct (rather than a raw `[name, value]` tuple) because napi-rs
|
|
128
|
-
* does not marshal Rust tuples through `#[napi(object)]` fields; the
|
|
129
|
-
* struct is the idiomatic, self-documenting equivalent and maps to a JS
|
|
130
|
-
* `{ name: string, value: string }`.
|
|
131
|
-
*/
|
|
132
|
-
export interface HeaderEntry {
|
|
133
|
-
name: string
|
|
134
|
-
value: string
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Programmatic HTTP/HTTPS proxy configuration, mirroring the kernel's
|
|
138
|
-
* internal [`ProxyConfig`]. Supplied as a structured object rather than a
|
|
139
|
-
* flattened URL so credentials never have to be percent-encoded into the URL
|
|
140
|
-
* and the bypass-host list can be expressed.
|
|
141
|
-
*
|
|
142
|
-
* - `url` — proxy endpoint, e.g. `"http://proxy.corp.example.com:8080"`. Must
|
|
143
|
-
* use the `http://` or `https://` scheme.
|
|
144
|
-
* - `username` / `password` — optional proxy basic-auth, applied via
|
|
145
|
-
* `reqwest`'s `Proxy::basic_auth` (not embedded in the URL).
|
|
146
|
-
* - `bypassHosts` — optional comma-separated host/domain list that should
|
|
147
|
-
* bypass the proxy (e.g. `"localhost,*.internal.corp"`).
|
|
148
|
-
*/
|
|
149
|
-
export interface ProxyInput {
|
|
150
|
-
url: string
|
|
151
|
-
username?: string
|
|
152
|
-
password?: string
|
|
153
|
-
bypassHosts?: string
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* JS-visible options for opening a Databricks SQL session.
|
|
157
|
-
*
|
|
158
|
-
* Authentication is selected by `authMode` (default [`AuthMode::Pat`]):
|
|
159
|
-
* - `Pat` — `token` required.
|
|
160
|
-
* - `OAuthM2m` — `oauthClientId` + `oauthClientSecret` required.
|
|
161
|
-
* - `OAuthU2m` — `oauthClientId` / `oauthRedirectPort` optional
|
|
162
|
-
* (defaults to the `databricks-sql-connector` client on port 8020).
|
|
163
|
-
*
|
|
164
|
-
* Catalog / schema / sessionConf are applied once at session creation
|
|
165
|
-
* and remain in effect for every statement run on the resulting
|
|
166
|
-
* `Connection`. The SEA wire protocol carries them on
|
|
167
|
-
* `CreateSession`, not on `ExecuteStatement` — so there is no
|
|
168
|
-
* per-statement override path on this binding.
|
|
169
|
-
*/
|
|
170
|
-
export interface ConnectionOptions {
|
|
75
|
+
get statementId(): string
|
|
171
76
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
77
|
+
* One-shot status check. Returns a string enum matching the
|
|
78
|
+
* kernel `StatementStatus` shape:
|
|
79
|
+
* `'Pending' | 'Running' | 'Succeeded' | 'Failed' |
|
|
80
|
+
* 'Cancelled' | 'Closed' | 'Unknown'`. (`'Unknown'` is the
|
|
81
|
+
* `#[non_exhaustive]` forward-compat catch-all that
|
|
82
|
+
* `StatementStatus::as_str` can return — consumers switching on
|
|
83
|
+
* the state must handle it.) Returns
|
|
84
|
+
* `KernelError(InvalidStatementHandle)` if the statement has
|
|
85
|
+
* been explicitly `close()`d.
|
|
86
|
+
*
|
|
87
|
+
* The `Failed` variant collapses to the string `'Failed'` on
|
|
88
|
+
* the JS side; the underlying error envelope (sql_state /
|
|
89
|
+
* error_code / query_id) is surfaced by `awaitResult()`'s
|
|
90
|
+
* rejection, which is where callers actually need the typed
|
|
91
|
+
* error. `status()` is intended for polling progress UIs
|
|
92
|
+
* that only need the state name.
|
|
174
93
|
*/
|
|
175
|
-
|
|
94
|
+
status(): Promise<string>
|
|
95
|
+
/** Rows modified by the statement (UPDATE / INSERT / DELETE / MERGE). */
|
|
96
|
+
numModifiedRows(): Promise<number | null>
|
|
176
97
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
98
|
+
* Server-supplied user-facing message (may contain SQL fragments —
|
|
99
|
+
* redact before centralised logging).
|
|
179
100
|
*/
|
|
180
|
-
|
|
101
|
+
displayMessage(): Promise<string | null>
|
|
102
|
+
/** Server-supplied diagnostic detail. */
|
|
103
|
+
diagnosticInfo(): Promise<string | null>
|
|
104
|
+
/** Server-supplied structured error detail (JSON), when enabled. */
|
|
105
|
+
errorDetailsJson(): Promise<string | null>
|
|
181
106
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
107
|
+
* Block until the server reaches a terminal state, then return
|
|
108
|
+
* an `AsyncResultHandle` that wraps the materialised result
|
|
109
|
+
* stream. The handle exposes `fetchNextBatch()` / `schema()`
|
|
110
|
+
* for consuming the result, plus `statementId` for log
|
|
111
|
+
* correlation.
|
|
112
|
+
*
|
|
113
|
+
* Drop-cancel safety: kernel `await_result` installs
|
|
114
|
+
* `AwaitResultCancelGuard` which fires a fire-and-forget
|
|
115
|
+
* `cancel_statement` if the future is dropped mid-poll
|
|
116
|
+
* (timeout, tokio::select! loser, JS-side `Promise.race`
|
|
117
|
+
* loser). The `util::guarded` `catch_unwind` here covers the
|
|
118
|
+
* V8-panic-across-boundary case on top. Returns
|
|
119
|
+
* `KernelError(InvalidStatementHandle)` if the statement has
|
|
120
|
+
* been explicitly `close()`d.
|
|
184
121
|
*/
|
|
185
|
-
|
|
122
|
+
awaitResult(): Promise<AsyncResultHandle>
|
|
186
123
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
*
|
|
193
|
-
*
|
|
124
|
+
* Server-side cancel. Returns
|
|
125
|
+
* `KernelError(InvalidStatementHandle)` if the statement has
|
|
126
|
+
* been explicitly `close()`d. Idempotent against a server
|
|
127
|
+
* that already reached a terminal state — the kernel's
|
|
128
|
+
* `cancel_statement` is a no-op there.
|
|
129
|
+
*
|
|
130
|
+
* **Lock-free by design.** Unlike `status()` / `awaitResult()` /
|
|
131
|
+
* `close()`, this does not take `inner.lock()` — it fires through
|
|
132
|
+
* the detached `AsyncStatementCanceller` captured at construction.
|
|
133
|
+
* That lets `stmt.cancel()` interrupt an in-flight `awaitResult()`
|
|
134
|
+
* (which holds the mutex for the whole poll) instead of queueing
|
|
135
|
+
* behind it: the server-side cancel flips the statement terminal,
|
|
136
|
+
* the parked `awaitResult()` poll loop observes `Cancelled` and
|
|
137
|
+
* returns. The closed-state check reads a lock-free flag so a
|
|
138
|
+
* cancel after an explicit `close()` still surfaces
|
|
139
|
+
* `InvalidStatementHandle`.
|
|
194
140
|
*/
|
|
195
|
-
|
|
196
|
-
/** OAuth client secret. Required for [`AuthMode::OAuthM2m`]. */
|
|
197
|
-
oauthClientSecret?: string
|
|
141
|
+
cancel(): Promise<void>
|
|
198
142
|
/**
|
|
199
|
-
*
|
|
200
|
-
*
|
|
143
|
+
* Explicit close. Idempotent — a second call on an
|
|
144
|
+
* already-closed handle returns `Ok(())`. On `Err`, the napi
|
|
145
|
+
* inner is already `None`, so a JS-side retry sees the
|
|
146
|
+
* closed-handle short-circuit and returns `Ok(())` without
|
|
147
|
+
* re-attempting the wire call. The kernel's own `Drop`
|
|
148
|
+
* fire-and-forget retry runs once in the background.
|
|
201
149
|
*/
|
|
202
|
-
|
|
150
|
+
close(): Promise<void>
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Handle returned by `Connection.executeStatementCancellable`. Owns the
|
|
155
|
+
* built-but-not-yet-executed kernel `Statement` plus a detached
|
|
156
|
+
* [`StatementCanceller`] captured before dispatch, so JS can fire a
|
|
157
|
+
* server-side cancel while the blocking `result()` is in flight.
|
|
158
|
+
*
|
|
159
|
+
* `pending` is `Arc<Mutex<Option<KernelStatement>>>` so `result()` can
|
|
160
|
+
* `.take()` the statement (the kernel `execute()` borrows it `&mut`,
|
|
161
|
+
* then it moves into the produced `Statement` wrapper to keep its
|
|
162
|
+
* `ValidityFlag` set — see `statement.rs`). A second `result()` call
|
|
163
|
+
* after the first resolved surfaces `InvalidStatementHandle`.
|
|
164
|
+
*/
|
|
165
|
+
export declare class CancellableExecution {
|
|
203
166
|
/**
|
|
204
|
-
*
|
|
205
|
-
* (`
|
|
167
|
+
* The server-issued statement id this execution targets, if the
|
|
168
|
+
* server has issued one yet (`null` before the initial submit
|
|
169
|
+
* round-trip publishes it mid-`result()`). Useful for log
|
|
170
|
+
* correlation while the blocking drive is in flight.
|
|
206
171
|
*/
|
|
207
|
-
|
|
172
|
+
get statementId(): string | null
|
|
208
173
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
174
|
+
* Drive the blocking `execute()` and resolve to a `Statement`
|
|
175
|
+
* (identical to what `executeStatement` returns) once the kernel
|
|
176
|
+
* reaches a terminal state and the result stream is ready.
|
|
177
|
+
*
|
|
178
|
+
* Consumes the pending statement: a second `result()` call returns
|
|
179
|
+
* `KernelError(InvalidStatementHandle)`. The future is
|
|
180
|
+
* drop-cancel-safe — the kernel's per-execute `MidExecuteCancelState`
|
|
181
|
+
* guard fires a fire-and-forget `cancel_statement` if this future is
|
|
182
|
+
* dropped mid-flight (`Promise.race` / timeout loser), independently
|
|
183
|
+
* of an explicit `cancel()`.
|
|
184
|
+
*
|
|
185
|
+
* On a server-side cancel the kernel's blocking `execute()` currently
|
|
186
|
+
* surfaces `InvalidArgument` (a known kernel quirk — the async path
|
|
187
|
+
* returns `Cancelled`). When this handle's `cancel()` actually dispatched a
|
|
188
|
+
* server-side cancel, we normalise that into `Cancelled` here so JS callers
|
|
189
|
+
* can rely on a single cancelled-status code regardless of execution path.
|
|
190
|
+
*
|
|
191
|
+
* Three outcomes can race the blocking drive: (1) a natural terminal state
|
|
192
|
+
* → `Ok` or the genuine error; (2) an explicit `cancel()` that dispatched a
|
|
193
|
+
* server cancel → this `result()` rejects with a `Cancelled`-coded error
|
|
194
|
+
* (the normalisation above); (3) the future being **dropped** mid-flight
|
|
195
|
+
* (`Promise.race`/timeout loser) → the kernel's `MidExecuteCancelState`
|
|
196
|
+
* drop-guard fires a fire-and-forget `cancel_statement`, but there is no
|
|
197
|
+
* `result()` left to observe a code. Only (2) yields a `Cancelled` error.
|
|
212
198
|
*/
|
|
213
|
-
|
|
199
|
+
result(): Promise<Statement>
|
|
214
200
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* `
|
|
201
|
+
* Server-side cancel of the in-flight statement.
|
|
202
|
+
*
|
|
203
|
+
* Lock-free: fires the detached `StatementCanceller` captured at
|
|
204
|
+
* construction rather than taking the mutex `result()` holds, so it
|
|
205
|
+
* interrupts a still-running blocking `result()` instead of queueing
|
|
206
|
+
* behind it. No-op (returns `Ok`) if `result()` already finished
|
|
207
|
+
* successfully, or if no statement id has been observed yet (query still
|
|
208
|
+
* in its initial submit round-trip), and idempotent against a server
|
|
209
|
+
* already in a terminal state.
|
|
218
210
|
*/
|
|
219
|
-
|
|
211
|
+
cancel(): Promise<void>
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Opaque connection handle wrapping a kernel `Session`.
|
|
216
|
+
*
|
|
217
|
+
* `inner` is `Arc<Mutex<Option<Session>>>` so:
|
|
218
|
+
* - the Drop impl can clone the `Arc` and `.take()` the session on a
|
|
219
|
+
* background tokio task without holding `&mut self` (which Drop is
|
|
220
|
+
* forbidden from doing across an `await`),
|
|
221
|
+
* - `close()` can `.take()` the session to consume it for the kernel's
|
|
222
|
+
* move-by-value `Session::close(self)` signature.
|
|
223
|
+
*
|
|
224
|
+
* **Concurrency shape** — both `executeStatement` and
|
|
225
|
+
* `submitStatement` build the kernel `Statement` under `inner.lock()`
|
|
226
|
+
* and then RELEASE the guard before the wire call
|
|
227
|
+
* (`stmt.execute().await` / `stmt.submit().await`). `Session::statement()`
|
|
228
|
+
* is `&self`-callable and only clones the session's internal `Arc`, so
|
|
229
|
+
* the built statement is independent of the guard. Concurrent
|
|
230
|
+
* `Promise.all([executeStatement(q1), submitStatement(q2)])` therefore
|
|
231
|
+
* serialise only for the microsecond statement-build, not the network
|
|
232
|
+
* round-trip, and `close()` never blocks behind an in-flight execute or
|
|
233
|
+
* submit. See
|
|
234
|
+
* `sea-workflow/jira-candidates/2026-05-24-napi-cancel-during-fetch.md`.
|
|
235
|
+
*/
|
|
236
|
+
export declare class Connection {
|
|
220
237
|
/**
|
|
221
|
-
* Server-
|
|
222
|
-
*
|
|
223
|
-
*
|
|
238
|
+
* Server-issued session id. Cached at construction; readable
|
|
239
|
+
* even after `close()` so JS-side log lines can correlate
|
|
240
|
+
* against kernel / server logs which key on the same id.
|
|
224
241
|
*/
|
|
225
|
-
|
|
242
|
+
get sessionId(): string
|
|
226
243
|
/**
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* Tunes the underlying `reqwest` connection pool — higher values
|
|
230
|
-
* reduce reconnect overhead when many statements run
|
|
231
|
-
* concurrently against the same warehouse.
|
|
244
|
+
* Execute a SQL statement and return a Statement handle that
|
|
245
|
+
* streams batches via `fetchNextBatch()`.
|
|
232
246
|
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* core's [`HttpConfig::pool_max_idle_per_host`] default is also 100
|
|
240
|
-
* (matching the same JDBC default), so napi pins its own copy rather
|
|
241
|
-
* than inheriting it. Mirrors the Python connector's
|
|
242
|
-
* `max_connections` kwarg on the SEA backend, which exposes the
|
|
243
|
-
* knob but keeps its own urllib3-aligned default of 10.
|
|
247
|
+
* Catalog / schema / sessionConf are session-level
|
|
248
|
+
* (`openSession`). Per-statement options on `ExecuteOptions`:
|
|
249
|
+
* - `statementConf` — per-statement Spark conf overlay
|
|
250
|
+
* - `queryTags` — serialised to a comma-separated `key:value`
|
|
251
|
+
* string and placed in `statement_conf["query_tags"]`,
|
|
252
|
+
* matching NodeJS Thrift's `serializeQueryTags` wire shape
|
|
244
253
|
*
|
|
245
|
-
*
|
|
246
|
-
* `
|
|
247
|
-
|
|
248
|
-
maxConnections?: number
|
|
249
|
-
/**
|
|
250
|
-
* Render `INTERVAL` / `DURATION` result columns as strings
|
|
251
|
-
* (`ResultConfig.intervals_as_string`). The kernel default is
|
|
252
|
-
* native Arrow `month_interval` / `duration[us]` types; the NodeJS
|
|
253
|
-
* Thrift driver surfaces intervals as strings, so the SEA driver
|
|
254
|
-
* sets this `true` for byte-compatible parity. Omitted ⇒ kernel
|
|
255
|
-
* default (native Arrow interval types).
|
|
256
|
-
*/
|
|
257
|
-
intervalsAsString?: boolean
|
|
258
|
-
/**
|
|
259
|
-
* Render complex (`ARRAY` / `MAP` / `STRUCT` / `VARIANT`) result
|
|
260
|
-
* columns as JSON strings (`ResultConfig.complex_types_as_json`)
|
|
261
|
-
* instead of native Arrow nested types. Omitted ⇒ kernel default
|
|
262
|
-
* (native Arrow nested types, which the NodeJS Arrow decoder
|
|
263
|
-
* already renders identically to the Thrift path).
|
|
254
|
+
* `options` is omitted/`None` for the no-options path; passing
|
|
255
|
+
* `{ statementConf: {} }` (an empty map) is treated the same as
|
|
256
|
+
* omission to keep the wire shape stable for the common case.
|
|
264
257
|
*/
|
|
265
|
-
|
|
258
|
+
executeStatement(sql: string, options?: ExecuteOptions | undefined | null): Promise<Statement>
|
|
266
259
|
/**
|
|
267
|
-
*
|
|
260
|
+
* directResults execute — the Thrift/JDBC model. Sends ExecuteStatement
|
|
261
|
+
* with no `wait_timeout` field (server applies its ~10s default inline wait
|
|
262
|
+
* and auto-closes on success) and returns WITHOUT polling past it:
|
|
268
263
|
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
264
|
+
* - a **`Statement`** (left arm) when the query finished within the inline
|
|
265
|
+
* wait — terminal, result ready inline, `close()` is a clean release;
|
|
266
|
+
* - an **`AsyncStatement`** (right arm) when it did not — a poll/cancel
|
|
267
|
+
* handle the caller drives (`status()` / `awaitResult()` / `cancel()`).
|
|
273
268
|
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
* `rejectUnauthorized: false`. Prefer pairing strict checking with
|
|
279
|
-
* `custom_ca_cert` over disabling verification entirely.
|
|
269
|
+
* JS distinguishes the arms by feature-detecting `awaitResult` (present
|
|
270
|
+
* only on `AsyncStatement`). This is the path that gives mid-run cancel for
|
|
271
|
+
* long queries WITHOUT the eager-handle / close-drives workaround: the
|
|
272
|
+
* returned handle always corresponds to a server-owned statement.
|
|
280
273
|
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* `
|
|
274
|
+
* **Load-bearing contract:** the kernel's `DirectStatement::{Completed,
|
|
275
|
+
* Running}` discriminant cannot ride on these opaque `#[napi]` classes, so
|
|
276
|
+
* consumers MUST feature-detect via `awaitResult` (the only member unique to
|
|
277
|
+
* `AsyncStatement`). `Statement` (the Completed arm) MUST NOT gain an
|
|
278
|
+
* `awaitResult` member, or every consumer silently misroutes. The pyo3
|
|
279
|
+
* binding makes the same `await_result`-probe assumption.
|
|
285
280
|
*/
|
|
286
|
-
|
|
281
|
+
executeStatementDirect(sql: string, options?: ExecuteOptions | undefined | null): Promise<Statement | AsyncStatement>
|
|
287
282
|
/**
|
|
288
|
-
*
|
|
289
|
-
*
|
|
283
|
+
* Execute a SQL statement on the blocking (sync) path, but return a
|
|
284
|
+
* `CancellableExecution` handle so a concurrent JS task can cancel
|
|
285
|
+
* the query *while it is still running server-side*.
|
|
290
286
|
*
|
|
291
|
-
*
|
|
292
|
-
* `
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* `
|
|
287
|
+
* `executeStatement` builds the kernel `Statement`, awaits the
|
|
288
|
+
* blocking `execute()`, and only then hands JS a `Statement` — so a
|
|
289
|
+
* query that runs for several seconds is uncancellable from JS on
|
|
290
|
+
* that path (there is no handle until the blocking call resolves).
|
|
291
|
+
* This method instead builds the statement, captures a detached
|
|
292
|
+
* `StatementCanceller` **before** dispatching `execute()`, and hands
|
|
293
|
+
* JS a `CancellableExecution` immediately. The caller drives the
|
|
294
|
+
* blocking execution via `result()` (resolves to the same
|
|
295
|
+
* `Statement` `executeStatement` returns) and can fire `cancel()`
|
|
296
|
+
* concurrently to interrupt a still-running query mid-COMPUTE.
|
|
297
297
|
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
|
|
301
|
-
checkServerCertificateHostname?: boolean
|
|
302
|
-
/**
|
|
303
|
-
* PEM-encoded CA certificate bytes to add to the trust store on
|
|
304
|
-
* top of the system roots. Use for corporate TLS-inspecting
|
|
305
|
-
* proxies that re-sign TLS, or on-prem deployments with an
|
|
306
|
-
* internal CA. Honoured regardless of `check_server_certificate`.
|
|
307
|
-
* Maps onto the kernel [`TlsConfig::custom_ca_cert`].
|
|
298
|
+
* Option semantics are identical to `executeStatement`.
|
|
299
|
+
* Mirrors the pyo3 `Statement.canceller()` / `Statement.execute()`
|
|
300
|
+
* split (PR #121): obtain the canceller before the blocking drive.
|
|
308
301
|
*/
|
|
309
|
-
|
|
302
|
+
executeStatementCancellable(sql: string, options?: ExecuteOptions | undefined | null): Promise<CancellableExecution>
|
|
310
303
|
/**
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
304
|
+
* Submit a SQL statement and return immediately with an
|
|
305
|
+
* `AsyncStatement` handle, without blocking until the query
|
|
306
|
+
* finishes. The kernel's `Statement::submit()` sends
|
|
307
|
+
* `wait_timeout=0s`, so the server responds as soon as it has a
|
|
308
|
+
* `statement_id` (state `Pending`/`Running`); JS drives polling
|
|
309
|
+
* via `AsyncStatement.status()` and materialises results with
|
|
310
|
+
* `AsyncStatement.awaitResult()`.
|
|
316
311
|
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
312
|
+
* This is the async-execution path the Thrift backend always
|
|
313
|
+
* uses (`runAsync: true`): the SEA backend submits, returns a
|
|
314
|
+
* pending operation handle, and polls to terminal during
|
|
315
|
+
* fetch. Option semantics (statementConf / queryTags /
|
|
316
|
+
* rowLimit / positional + named params) match `executeStatement`.
|
|
317
|
+
* Submit always sends `wait_timeout=0s` so the call returns
|
|
318
|
+
* immediately; the caller drives completion via `status()` /
|
|
319
|
+
* `awaitResult()`. Only the blocking-vs-pending return contract
|
|
320
|
+
* differs from `executeStatement`.
|
|
320
321
|
*/
|
|
321
|
-
|
|
322
|
+
submitStatement(sql: string, options?: ExecuteOptions | undefined | null): Promise<AsyncStatement>
|
|
322
323
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
324
|
+
* Explicit close. Awaits the server-side `DeleteSession` so the
|
|
325
|
+
* JS caller can observe failures (auth revoked mid-session,
|
|
326
|
+
* warehouse stopped, network error). Idempotent — a second call
|
|
327
|
+
* on an already-closed connection returns `Ok`.
|
|
328
|
+
*
|
|
329
|
+
* **Errors are terminal from the JS side.** The kernel session
|
|
330
|
+
* handle is consumed (`take()`) BEFORE the wire `DeleteSession`
|
|
331
|
+
* runs, because `Session::close` takes `self` by value. On `Err`,
|
|
332
|
+
* the napi `inner` is already `None`, so a JS-side retry sees a
|
|
333
|
+
* closed connection and returns `Ok(())` without re-attempting
|
|
334
|
+
* the wire call. The kernel's own `Drop` fire-and-forget retry
|
|
335
|
+
* runs once in the background — the JS caller can log the error
|
|
336
|
+
* but cannot drive a retry. If you need retry-on-failure
|
|
337
|
+
* semantics for `DeleteSession`, layer them above this method.
|
|
327
338
|
*/
|
|
328
|
-
|
|
339
|
+
close(): Promise<void>
|
|
329
340
|
/**
|
|
330
|
-
*
|
|
331
|
-
* caller-supplied headers (the NodeJS driver's `customHeaders` and
|
|
332
|
-
* the composed `User-Agent`). Maps onto the kernel
|
|
333
|
-
* [`HttpConfig::custom_headers`].
|
|
341
|
+
* All catalogs visible to the session.
|
|
334
342
|
*
|
|
335
|
-
*
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
*
|
|
343
|
+
* JDBC `getCatalogs` shape: `TABLE_CAT: Utf8`.
|
|
344
|
+
*/
|
|
345
|
+
listCatalogs(): Promise<Statement>
|
|
346
|
+
/**
|
|
347
|
+
* Schemas filtered by catalog (exact) and schema name pattern.
|
|
340
348
|
*
|
|
341
|
-
*
|
|
342
|
-
* - `Authorization` / `x-databricks-org-id` are **reserved** — a
|
|
343
|
-
* caller entry for either is silently dropped (skip-and-warn) so
|
|
344
|
-
* auth and multi-tenant routing can't be hijacked by a custom
|
|
345
|
-
* header. (The NodeJS driver also drops these before they cross
|
|
346
|
-
* the FFI, matching the Python connector's double-wall.)
|
|
347
|
-
* - `User-Agent` is **appended** to the kernel base UA (rather than
|
|
348
|
-
* replacing it), preserving the `DatabricksJDBCDriverOSS/...`
|
|
349
|
-
* token the SEA server keys on while still surfacing the caller's
|
|
350
|
-
* identity. The NodeJS driver folds its `userAgentEntry` into a
|
|
351
|
-
* `User-Agent` entry here.
|
|
349
|
+
* JDBC `getSchemas` shape: `TABLE_SCHEM, TABLE_CATALOG`.
|
|
352
350
|
*/
|
|
353
|
-
|
|
351
|
+
listSchemas(catalog?: string | undefined | null, schemaPattern?: string | undefined | null): Promise<Statement>
|
|
354
352
|
/**
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
* budget). Mirrors the pyo3 binding's `retry_*` kwargs so the Node.js
|
|
358
|
-
* driver can forward the same retry knobs the Python connector does.
|
|
353
|
+
* Tables filtered by catalog (**pattern**), schema (pattern), table
|
|
354
|
+
* (pattern).
|
|
359
355
|
*
|
|
360
|
-
*
|
|
361
|
-
* `
|
|
356
|
+
* The catalog is an ODBC/JDBC LIKE pattern (`%` / `_`), matching
|
|
357
|
+
* Thrift `getTables`: a wildcard catalog matches multiple catalogs;
|
|
358
|
+
* a literal name (or an escaped `\_` / `\%`) takes the fast exact
|
|
359
|
+
* path. `undefined`/omitted catalog means "all catalogs", while an
|
|
360
|
+
* **empty string** means "match nothing" (zero rows) — pass
|
|
361
|
+
* `undefined`, not `""`, for all catalogs. The catalog pattern is
|
|
362
|
+
* validated (whitespace-only / NUL / >255 bytes are rejected with an
|
|
363
|
+
* error).
|
|
364
|
+
*
|
|
365
|
+
* JDBC `getTables` shape: 10 columns. `tableTypes`, when provided,
|
|
366
|
+
* filters rows by `TABLE_TYPE` kernel-side.
|
|
367
|
+
*
|
|
368
|
+
* `tableTypes` is an advisory filter. Databricks `SHOW TABLES` does
|
|
369
|
+
* NOT honour the table-type filter server-side; the kernel applies
|
|
370
|
+
* it client-side after the result returns. Callers expecting
|
|
371
|
+
* server-side rejection of off-type tables should not rely on this.
|
|
362
372
|
*/
|
|
363
|
-
|
|
373
|
+
listTables(catalog?: string | undefined | null, schemaPattern?: string | undefined | null, tablePattern?: string | undefined | null, tableTypes?: Array<string> | undefined | null): Promise<Statement>
|
|
364
374
|
/**
|
|
365
|
-
*
|
|
366
|
-
*
|
|
375
|
+
* Columns of tables matching the filter.
|
|
376
|
+
*
|
|
377
|
+
* JDBC `getColumns` shape: 23 columns.
|
|
367
378
|
*/
|
|
368
|
-
|
|
379
|
+
listColumns(catalog?: string | undefined | null, schemaPattern?: string | undefined | null, tablePattern?: string | undefined | null, columnPattern?: string | undefined | null): Promise<Statement>
|
|
369
380
|
/**
|
|
370
|
-
*
|
|
371
|
-
* `
|
|
372
|
-
* kernel's [`HttpConfig::retry_max_retries`] counts retries *after* the
|
|
373
|
-
* first attempt, so this is converted with `max(0, attempts - 1)` in
|
|
374
|
-
* [`build_http_config`] — `0` / `1` both mean a single attempt, no retry.
|
|
381
|
+
* Functions visible to the session. `catalog` is exact;
|
|
382
|
+
* `schemaPattern` and `functionPattern` are SQL LIKE.
|
|
375
383
|
*/
|
|
376
|
-
|
|
384
|
+
listFunctions(catalog?: string | undefined | null, schemaPattern?: string | undefined | null, functionPattern?: string | undefined | null): Promise<Statement>
|
|
377
385
|
/**
|
|
378
|
-
*
|
|
379
|
-
*
|
|
386
|
+
* Procedures visible to the session. `catalog` is exact;
|
|
387
|
+
* `schemaPattern` and `procedurePattern` are SQL LIKE.
|
|
380
388
|
*/
|
|
381
|
-
|
|
389
|
+
listProcedures(catalog?: string | undefined | null, schemaPattern?: string | undefined | null, procedurePattern?: string | undefined | null): Promise<Statement>
|
|
382
390
|
/**
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
* `username` / `password`, and an optional `bypassHosts` list — mapped
|
|
386
|
-
* field-for-field onto the kernel [`ProxyConfig`].
|
|
387
|
-
*
|
|
388
|
-
* Omitted ⇒ the kernel does NOT configure a proxy explicitly and
|
|
389
|
-
* `reqwest`'s standard behaviour applies — the `HTTPS_PROXY` /
|
|
390
|
-
* `HTTP_PROXY` / `NO_PROXY` environment variables are still honoured.
|
|
391
|
-
* Setting this **overrides** those env vars. This complements the env-var
|
|
392
|
-
* path: callers who cannot set process env vars (e.g. a long-lived Node
|
|
393
|
-
* server) can now route a single connection through a proxy
|
|
394
|
-
* programmatically.
|
|
391
|
+
* All table types (`TABLE`, `VIEW`, `SYSTEM TABLE`, …).
|
|
392
|
+
* No wire call — static in-memory result.
|
|
395
393
|
*/
|
|
396
|
-
|
|
394
|
+
listTableTypes(): Promise<Statement>
|
|
397
395
|
/**
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
* before the request errors out. Maps onto the kernel
|
|
401
|
-
* [`HttpConfig::request_timeout`] (the internal reqwest
|
|
402
|
-
* `Client::timeout`).
|
|
403
|
-
*
|
|
404
|
-
* Omitted ⇒ kernel default (120 000 ms / 120 s). Napi-rs
|
|
405
|
-
* serialises `u32` as JS `number`; the largest representable value
|
|
406
|
-
* (~49.7 days) far exceeds any sensible socket timeout.
|
|
396
|
+
* SQL data types supported by the workspace.
|
|
397
|
+
* No wire call — static in-memory result.
|
|
407
398
|
*/
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* One kernel log event, as handed to JS. `level` is a lower-case string
|
|
422
|
-
* (`error`/`warn`/`info`/`debug`/`trace`) the Node side maps onto its
|
|
423
|
-
* `LogLevel`; `target` is the originating `tracing` target (e.g.
|
|
424
|
-
* `databricks::sql::kernel`); `message` is the rendered event plus any
|
|
425
|
-
* structured `key=value` fields.
|
|
426
|
-
*/
|
|
427
|
-
export interface LogRecord {
|
|
428
|
-
level: string
|
|
429
|
-
target: string
|
|
430
|
-
message: string
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Install (idempotently) the kernel→JS log bridge and set its level.
|
|
434
|
-
*
|
|
435
|
-
* `callback` is invoked with **an array of [`LogRecord`]s** (`(err, records)`)
|
|
436
|
-
* for each forwarded batch. `level` is one of
|
|
437
|
-
* `off`/`error`/`warn`/`info`/`debug`/`trace` (case-insensitive); unknown
|
|
438
|
-
* values fall back to `warn`.
|
|
439
|
-
*
|
|
440
|
-
* Safe to call more than once: the process-global subscriber is installed on
|
|
441
|
-
* the first call only, while every call refreshes the sink + level (last
|
|
442
|
-
* writer wins — see module docs).
|
|
443
|
-
*/
|
|
444
|
-
export declare function initKernelLogging(callback: (err: Error | null, arg: Array<LogRecord>) => any, level: string): void
|
|
445
|
-
/**
|
|
446
|
-
* Snapshot of the bridge's runtime state for observability.
|
|
447
|
-
*
|
|
448
|
-
* `installed` is `true` only when the process-global subscriber was
|
|
449
|
-
* successfully installed by *this* bridge (and the drain thread started);
|
|
450
|
-
* `false` means another global subscriber was already set or the drain
|
|
451
|
-
* thread could not be spawned, so kernel logs are NOT reaching the JS sink.
|
|
452
|
-
* `dropped` is the cumulative count of records discarded because the
|
|
453
|
-
* bounded channel was full during a burst (drop-newest) — a nonzero,
|
|
454
|
-
* growing value signals the sink can't keep up.
|
|
455
|
-
*/
|
|
456
|
-
export interface KernelLoggingStats {
|
|
457
|
-
installed: boolean
|
|
458
|
-
dropped: number
|
|
399
|
+
listTypeInfo(): Promise<Statement>
|
|
400
|
+
/**
|
|
401
|
+
* Primary keys for the given table. All three identifiers are
|
|
402
|
+
* exact — ODBC `SQLPrimaryKeys` does not support patterns.
|
|
403
|
+
*/
|
|
404
|
+
getPrimaryKeys(catalog: string, schema: string, table: string): Promise<Statement>
|
|
405
|
+
/**
|
|
406
|
+
* Foreign-key relationships. The foreign side must be fully
|
|
407
|
+
* specified (catalog + schema + table); the parent side is
|
|
408
|
+
* optional. All identifiers are exact — no LIKE patterns.
|
|
409
|
+
*/
|
|
410
|
+
getCrossReference(parentCatalog: string | undefined | null, parentSchema: string | undefined | null, parentTable: string | undefined | null, foreignCatalog: string, foreignSchema: string, foreignTable: string): Promise<Statement>
|
|
459
411
|
}
|
|
412
|
+
|
|
460
413
|
/**
|
|
461
|
-
*
|
|
462
|
-
* `initKernelLogging` (reports `installed: false`, `dropped: 0`).
|
|
463
|
-
*/
|
|
464
|
-
export declare function kernelLoggingStats(): KernelLoggingStats
|
|
465
|
-
/**
|
|
466
|
-
* Live-retarget the bridge's level (one of
|
|
467
|
-
* `off`/`error`/`warn`/`info`/`debug`/`trace`, case-insensitive).
|
|
468
|
-
*/
|
|
469
|
-
export declare function setKernelLogLevel(level: string): void
|
|
470
|
-
/**
|
|
471
|
-
* JS-visible binding for a single positional parameter.
|
|
414
|
+
* Opaque executed-statement handle.
|
|
472
415
|
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
416
|
+
* **Current concurrency shape** — every method takes `inner.lock()`
|
|
417
|
+
* and holds the guard across the kernel `.await`. tokio `Mutex` is
|
|
418
|
+
* FIFO, so cancel/close queue behind any in-flight `fetchNextBatch`
|
|
419
|
+
* until it returns naturally. This is a known limitation that exists
|
|
420
|
+
* because the napi shape has not yet been split into an
|
|
421
|
+
* `Arc<dyn ExecutedStatementHandle>` (for cancel/close, which the
|
|
422
|
+
* kernel exposes as `&self`-callable) plus a `Mutex<Option<…>>` only
|
|
423
|
+
* for the borrowed-mut fetch path. The lock-shape refactor needs a
|
|
424
|
+
* small kernel-side accessor and lands in a follow-up PR — see
|
|
425
|
+
* `sea-workflow/jira-candidates/2026-05-24-napi-cancel-during-fetch.md`.
|
|
478
426
|
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
* dynamic dispatch on the Rust side. The Node-driver adapter already
|
|
483
|
-
* stringifies before calling the binding (see `DBSQLParameter` and the
|
|
484
|
-
* existing pyo3 wrapper), so the string-in / string-parsed contract
|
|
485
|
-
* adds no JS-side complexity and keeps the kernel-side validation in
|
|
486
|
-
* one place.
|
|
427
|
+
* `schema` and `statement_id` are cached at construction so they
|
|
428
|
+
* survive `close()` — JS callers building error reports against a
|
|
429
|
+
* disposed statement can still read them.
|
|
487
430
|
*/
|
|
488
|
-
export
|
|
431
|
+
export declare class Statement {
|
|
489
432
|
/**
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
* precision/scale.
|
|
433
|
+
* Server-issued statement id. Cached at construction; readable
|
|
434
|
+
* even after `close()` so JS-side log lines can correlate against
|
|
435
|
+
* kernel / server logs which key on the same id.
|
|
494
436
|
*/
|
|
495
|
-
|
|
437
|
+
get statementId(): string
|
|
496
438
|
/**
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
439
|
+
* Number of rows modified by the statement (UPDATE / INSERT /
|
|
440
|
+
* DELETE / MERGE). `null` for SELECT and on warehouses that don't
|
|
441
|
+
* surface the counter. Mirrors Thrift's
|
|
442
|
+
* `TGetOperationStatusResp.numModifiedRows`.
|
|
500
443
|
*/
|
|
501
|
-
|
|
444
|
+
numModifiedRows(): Promise<number | null>
|
|
445
|
+
/**
|
|
446
|
+
* Server-supplied user-facing message. Mirrors Thrift's
|
|
447
|
+
* `TGetOperationStatusResp.displayMessage`. **PII / sensitive-
|
|
448
|
+
* data note:** may contain SQL fragments or parameter values —
|
|
449
|
+
* redact before centralised logging.
|
|
450
|
+
*
|
|
451
|
+
* Populated on `Succeeded` / `Closed` paths (incl. an empty `Closed`).
|
|
452
|
+
* On terminal-error states (`Failed` / `Cancelled`) the kernel returns
|
|
453
|
+
* an Error instead of a `Statement`, and the same field rides on the JS
|
|
454
|
+
* Error envelope under the same `displayMessage` key.
|
|
455
|
+
*/
|
|
456
|
+
displayMessage(): Promise<string | null>
|
|
457
|
+
/**
|
|
458
|
+
* Server-supplied diagnostic detail — multi-line operator /
|
|
459
|
+
* stack context. Mirrors Thrift's
|
|
460
|
+
* `TGetOperationStatusResp.diagnosticInfo`. For support surfaces,
|
|
461
|
+
* not user-facing. Same reachability + PII caveats as
|
|
462
|
+
* `displayMessage`.
|
|
463
|
+
*/
|
|
464
|
+
diagnosticInfo(): Promise<string | null>
|
|
465
|
+
/**
|
|
466
|
+
* Server-supplied JSON blob with extended error details. Mirrors
|
|
467
|
+
* Thrift's `TGetOperationStatusResp.errorDetailsJson`.
|
|
468
|
+
* Pass-through string — JS callers parse with `JSON.parse` if
|
|
469
|
+
* they need structured access.
|
|
470
|
+
*
|
|
471
|
+
* **Server-side gating:** populated only when the workspace has
|
|
472
|
+
* `spark.databricks.sql.errorDetailsJson.enabled = true` on the
|
|
473
|
+
* underlying SQL cluster. The flag is internal-only / default-
|
|
474
|
+
* false in the Databricks runtime, so for most JS callers this
|
|
475
|
+
* will return `null`. Admin-enabled workspaces return content
|
|
476
|
+
* shaped like `{"errorClass": "...", "messageTemplate": "..."}`.
|
|
477
|
+
*
|
|
478
|
+
* **Unbounded:** when populated, server can return a multi-MB
|
|
479
|
+
* blob; size before logging.
|
|
480
|
+
*/
|
|
481
|
+
errorDetailsJson(): Promise<string | null>
|
|
482
|
+
/**
|
|
483
|
+
* Pull the next batch of results. Returns `null` when the stream
|
|
484
|
+
* is exhausted. The returned `ArrowBatch.ipcBytes` is a complete
|
|
485
|
+
* Arrow IPC stream (schema header + 1 record-batch message)
|
|
486
|
+
* suitable for handing to `apache-arrow`'s `RecordBatchReader`.
|
|
487
|
+
*
|
|
488
|
+
* On `Err`, the stream is in an unspecified state — call
|
|
489
|
+
* `close()` and discard the `Statement`. Subsequent
|
|
490
|
+
* `fetchNextBatch()` calls after an error are not guaranteed to
|
|
491
|
+
* succeed or fail consistently.
|
|
492
|
+
*/
|
|
493
|
+
fetchNextBatch(): Promise<ArrowBatch | null>
|
|
494
|
+
/**
|
|
495
|
+
* Result schema as an Arrow IPC payload (schema header only, no
|
|
496
|
+
* record-batch message). Available before any batches have been
|
|
497
|
+
* fetched, and remains available after `close()` — the kernel
|
|
498
|
+
* materialises the schema eagerly so JS callers can build error
|
|
499
|
+
* reports against a disposed statement.
|
|
500
|
+
*
|
|
501
|
+
* Sync because the body has no `.await` — `encode_ipc_stream` is
|
|
502
|
+
* pure CPU work over an `Arc<Schema>` already cached on the
|
|
503
|
+
* wrapper. Mirrors `pyo3/src/statement.rs::arrow_schema` (sync).
|
|
504
|
+
* napi-rs converts a panic in a sync `#[napi]` entry point into a
|
|
505
|
+
* thrown JS error via its own macro-expanded boundary, so the
|
|
506
|
+
* `util::guarded` `catch_unwind` wrapper that the `async fn`
|
|
507
|
+
* entry points use is not required for this method.
|
|
508
|
+
*/
|
|
509
|
+
schema(): ArrowSchema
|
|
510
|
+
/**
|
|
511
|
+
* Server-side cancel.
|
|
512
|
+
*
|
|
513
|
+
* For executed statements: short-circuits to `Ok(())` if
|
|
514
|
+
* `fetchNextBatch` has already returned `null` (stream
|
|
515
|
+
* naturally exhausted) — matches the JDBC `Statement.cancel()`
|
|
516
|
+
* no-op-after-completion contract, so JS callers can fire cancel
|
|
517
|
+
* defensively without distinguishing "real cancel" from "raced
|
|
518
|
+
* with natural completion."
|
|
519
|
+
*
|
|
520
|
+
* For metadata streams: no-op (the kernel has no in-flight
|
|
521
|
+
* cancellation surface for metadata calls today).
|
|
522
|
+
*
|
|
523
|
+
* Returns `KernelError(InvalidStatementHandle)` if the statement
|
|
524
|
+
* has been explicitly `close()`d.
|
|
525
|
+
*/
|
|
526
|
+
cancel(): Promise<void>
|
|
527
|
+
/**
|
|
528
|
+
* Explicit close.
|
|
529
|
+
*
|
|
530
|
+
* For executed statements: awaits the server-side `CloseStatement`
|
|
531
|
+
* so the JS caller can observe failures (auth revoked mid-session,
|
|
532
|
+
* network error, server-side error). Idempotent — a second call
|
|
533
|
+
* on an already-closed statement returns `Ok`.
|
|
534
|
+
*
|
|
535
|
+
* **Errors are terminal from the JS side.** The kernel executed
|
|
536
|
+
* handle is taken out of `inner` BEFORE the wire `CloseStatement`
|
|
537
|
+
* runs (so `Drop` knows there's nothing left to clean up). On
|
|
538
|
+
* `Err`, the napi `inner` is already `None`, so a JS-side retry
|
|
539
|
+
* sees a closed statement and returns `Ok(())` without re-
|
|
540
|
+
* attempting the wire call. The kernel-level `ExecutedStatement`
|
|
541
|
+
* has been consumed at that point and the value is dropped on
|
|
542
|
+
* the way out of the closure — the kernel's `ExecutedStatement::
|
|
543
|
+
* Drop` then fires-and-forgets a single retry on the captured
|
|
544
|
+
* runtime. The JS caller can log the error but cannot drive a
|
|
545
|
+
* further retry. If you need retry-on-failure semantics for
|
|
546
|
+
* `CloseStatement`, layer them above this method.
|
|
547
|
+
*
|
|
548
|
+
* For metadata streams: drops the stream (no server round-trip
|
|
549
|
+
* needed — metadata results have no in-flight server-side
|
|
550
|
+
* resource to release).
|
|
551
|
+
*/
|
|
552
|
+
close(): Promise<void>
|
|
502
553
|
}
|
|
554
|
+
|
|
503
555
|
/**
|
|
504
556
|
* A single Arrow IPC stream payload encoding one record batch (plus
|
|
505
557
|
* the schema header so the JS-side reader is stateless).
|
|
@@ -511,6 +563,7 @@ export interface ArrowBatch {
|
|
|
511
563
|
*/
|
|
512
564
|
ipcBytes: Buffer
|
|
513
565
|
}
|
|
566
|
+
|
|
514
567
|
/**
|
|
515
568
|
* An Arrow IPC stream payload encoding just the result schema (no
|
|
516
569
|
* record-batch messages). Returned by `Statement.schema()`.
|
|
@@ -523,547 +576,730 @@ export interface ArrowSchema {
|
|
|
523
576
|
*/
|
|
524
577
|
ipcBytes: Buffer
|
|
525
578
|
}
|
|
579
|
+
|
|
526
580
|
/**
|
|
527
|
-
*
|
|
581
|
+
* Authentication mode selector crossing the napi boundary. The string
|
|
582
|
+
* literals are what napi-rs emits from this `#[napi(string_enum)]` — the
|
|
583
|
+
* NodeJS SEA adapter (`KernelAuth`) matches them verbatim (`'Pat'`,
|
|
584
|
+
* `'OAuthM2m'`, `'OAuthU2m'`, `'AzureSpM2m'`).
|
|
528
585
|
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
586
|
+
* Mirrors the kernel [`AuthConfig`] variants this binding supports.
|
|
587
|
+
* `OAuthFederation` / `External` are intentionally not exposed yet — the
|
|
588
|
+
* kernel marks federation as not-yet-implemented and `External` is a
|
|
589
|
+
* Rust-trait escape hatch with no JS-callback bridge.
|
|
531
590
|
*/
|
|
532
|
-
export declare
|
|
591
|
+
export declare const enum AuthMode {
|
|
592
|
+
/** Personal access token (`token`). */
|
|
593
|
+
Pat = 'Pat',
|
|
594
|
+
/** OAuth 2.0 machine-to-machine — `oauthClientId` + `oauthClientSecret`. */
|
|
595
|
+
OAuthM2m = 'OAuthM2m',
|
|
596
|
+
/**
|
|
597
|
+
* OAuth 2.0 machine-to-machine with a JWT private-key client
|
|
598
|
+
* assertion — `oauthClientId` + `jwtKeyFile` + `jwtKid`.
|
|
599
|
+
*/
|
|
600
|
+
OAuthM2mJwt = 'OAuthM2mJwt',
|
|
601
|
+
/**
|
|
602
|
+
* OAuth 2.0 user-to-machine (browser flow) — optional `oauthClientId`
|
|
603
|
+
* + `oauthRedirectPort`.
|
|
604
|
+
*/
|
|
605
|
+
OAuthU2m = 'OAuthU2m',
|
|
606
|
+
/**
|
|
607
|
+
* Azure Entra service-principal M2M — `azureClientId` +
|
|
608
|
+
* `azureClientSecret` (+ optional `azureTenantId` /
|
|
609
|
+
* `azureWorkspaceResourceId`). The kernel builds the Entra token
|
|
610
|
+
* endpoint + `.default` scope, auto-discovers the tenant from the
|
|
611
|
+
* workspace when `azureTenantId` is omitted, and — when
|
|
612
|
+
* `azureWorkspaceResourceId` is set — additionally sends the SP
|
|
613
|
+
* management token for an RBAC-only service principal.
|
|
614
|
+
*/
|
|
615
|
+
AzureSpM2m = 'AzureSpM2m'
|
|
616
|
+
}
|
|
617
|
+
|
|
533
618
|
/**
|
|
534
|
-
*
|
|
619
|
+
* JS-visible options for opening a Databricks SQL session.
|
|
535
620
|
*
|
|
536
|
-
*
|
|
537
|
-
* `
|
|
538
|
-
*
|
|
539
|
-
* `
|
|
540
|
-
* `
|
|
621
|
+
* Authentication is selected by `authMode` (default [`AuthMode::Pat`]):
|
|
622
|
+
* - `Pat` — `token` required.
|
|
623
|
+
* - `OAuthM2m` — `oauthClientId` + `oauthClientSecret` required.
|
|
624
|
+
* - `OAuthU2m` — `oauthClientId` / `oauthRedirectPort` optional
|
|
625
|
+
* (defaults to the `databricks-sql-connector` client on port 8030).
|
|
626
|
+
* - `AzureSpM2m` — `azureClientId` + `azureClientSecret` required
|
|
627
|
+
* (+ optional `azureTenantId` / `azureWorkspaceResourceId`).
|
|
541
628
|
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
* `
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
* through the detached `AsyncStatementCanceller` (session +
|
|
548
|
-
* statement_id, captured at construction), so an explicit
|
|
549
|
-
* `stmt.cancel()` interrupts an in-flight `awaitResult()` instead of
|
|
550
|
-
* queueing behind it. The server-side cancel flips the statement
|
|
551
|
-
* terminal, which the parked `awaitResult()` poll loop observes
|
|
552
|
-
* (`Cancelled`) and returns on. The kernel's `AwaitResultCancelGuard`
|
|
553
|
-
* still covers the drop-cancel case (Promise.race / timeout)
|
|
554
|
-
* independently — see module docs.
|
|
629
|
+
* Catalog / schema / sessionConf are applied once at session creation
|
|
630
|
+
* and remain in effect for every statement run on the resulting
|
|
631
|
+
* `Connection`. The SEA wire protocol carries them on
|
|
632
|
+
* `CreateSession`, not on `ExecuteStatement` — so there is no
|
|
633
|
+
* per-statement override path on this binding.
|
|
555
634
|
*/
|
|
556
|
-
export
|
|
635
|
+
export interface ConnectionOptions {
|
|
557
636
|
/**
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
* against kernel / server logs which key on the same id.
|
|
637
|
+
* Workspace host, e.g. `adb-…azuredatabricks.net`. The kernel
|
|
638
|
+
* normalises this — bare hostnames get `https://` prepended.
|
|
561
639
|
*/
|
|
562
|
-
|
|
640
|
+
hostName: string
|
|
563
641
|
/**
|
|
564
|
-
*
|
|
565
|
-
* kernel
|
|
566
|
-
* `'Pending' | 'Running' | 'Succeeded' | 'Failed' |
|
|
567
|
-
* 'Cancelled' | 'Closed' | 'Unknown'`. (`'Unknown'` is the
|
|
568
|
-
* `#[non_exhaustive]` forward-compat catch-all that
|
|
569
|
-
* `StatementStatus::as_str` can return — consumers switching on
|
|
570
|
-
* the state must handle it.) Returns
|
|
571
|
-
* `KernelError(InvalidStatementHandle)` if the statement has
|
|
572
|
-
* been explicitly `close()`d.
|
|
573
|
-
*
|
|
574
|
-
* The `Failed` variant collapses to the string `'Failed'` on
|
|
575
|
-
* the JS side; the underlying error envelope (sql_state /
|
|
576
|
-
* error_code / query_id) is surfaced by `awaitResult()`'s
|
|
577
|
-
* rejection, which is where callers actually need the typed
|
|
578
|
-
* error. `status()` is intended for polling progress UIs
|
|
579
|
-
* that only need the state name.
|
|
642
|
+
* JDBC-style HTTP path, e.g. `/sql/1.0/warehouses/abc123`. The
|
|
643
|
+
* kernel parses out the warehouse id.
|
|
580
644
|
*/
|
|
581
|
-
|
|
582
|
-
/** Rows modified by the statement (UPDATE / INSERT / DELETE / MERGE). */
|
|
583
|
-
numModifiedRows(): Promise<number | null>
|
|
645
|
+
httpPath: string
|
|
584
646
|
/**
|
|
585
|
-
*
|
|
586
|
-
*
|
|
647
|
+
* Authentication mode. Omitted ⇒ [`AuthMode::Pat`] (back-compat:
|
|
648
|
+
* existing PAT callers pass only `token`).
|
|
587
649
|
*/
|
|
588
|
-
|
|
589
|
-
/** Server-supplied diagnostic detail. */
|
|
590
|
-
diagnosticInfo(): Promise<string | null>
|
|
591
|
-
/** Server-supplied structured error detail (JSON), when enabled. */
|
|
592
|
-
errorDetailsJson(): Promise<string | null>
|
|
650
|
+
authMode?: AuthMode
|
|
593
651
|
/**
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
* stream. The handle exposes `fetchNextBatch()` / `schema()`
|
|
597
|
-
* for consuming the result, plus `statementId` for log
|
|
598
|
-
* correlation.
|
|
599
|
-
*
|
|
600
|
-
* Drop-cancel safety: kernel `await_result` installs
|
|
601
|
-
* `AwaitResultCancelGuard` which fires a fire-and-forget
|
|
602
|
-
* `cancel_statement` if the future is dropped mid-poll
|
|
603
|
-
* (timeout, tokio::select! loser, JS-side `Promise.race`
|
|
604
|
-
* loser). The `util::guarded` `catch_unwind` here covers the
|
|
605
|
-
* V8-panic-across-boundary case on top. Returns
|
|
606
|
-
* `KernelError(InvalidStatementHandle)` if the statement has
|
|
607
|
-
* been explicitly `close()`d.
|
|
652
|
+
* Personal access token. Required (and non-empty) for
|
|
653
|
+
* [`AuthMode::Pat`]; ignored otherwise.
|
|
608
654
|
*/
|
|
609
|
-
|
|
655
|
+
token?: string
|
|
610
656
|
/**
|
|
611
|
-
*
|
|
612
|
-
* `
|
|
613
|
-
* been explicitly `close()`d. Idempotent against a server
|
|
614
|
-
* that already reached a terminal state — the kernel's
|
|
615
|
-
* `cancel_statement` is a no-op there.
|
|
616
|
-
*
|
|
617
|
-
* **Lock-free by design.** Unlike `status()` / `awaitResult()` /
|
|
618
|
-
* `close()`, this does not take `inner.lock()` — it fires through
|
|
619
|
-
* the detached `AsyncStatementCanceller` captured at construction.
|
|
620
|
-
* That lets `stmt.cancel()` interrupt an in-flight `awaitResult()`
|
|
621
|
-
* (which holds the mutex for the whole poll) instead of queueing
|
|
622
|
-
* behind it: the server-side cancel flips the statement terminal,
|
|
623
|
-
* the parked `awaitResult()` poll loop observes `Cancelled` and
|
|
624
|
-
* returns. The closed-state check reads a lock-free flag so a
|
|
625
|
-
* cancel after an explicit `close()` still surfaces
|
|
626
|
-
* `InvalidStatementHandle`.
|
|
657
|
+
* OAuth client id. Required for [`AuthMode::OAuthM2m`]; optional for
|
|
658
|
+
* [`AuthMode::OAuthU2m`] (defaults to `databricks-sql-connector`).
|
|
627
659
|
*/
|
|
628
|
-
|
|
660
|
+
oauthClientId?: string
|
|
661
|
+
/** OAuth client secret. Required for [`AuthMode::OAuthM2m`]. */
|
|
662
|
+
oauthClientSecret?: string
|
|
629
663
|
/**
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
* inner is already `None`, so a JS-side retry sees the
|
|
633
|
-
* closed-handle short-circuit and returns `Ok(())` without
|
|
634
|
-
* re-attempting the wire call. The kernel's own `Drop`
|
|
635
|
-
* fire-and-forget retry runs once in the background.
|
|
664
|
+
* Localhost callback port for the [`AuthMode::OAuthU2m`] browser
|
|
665
|
+
* flow. Omitted ⇒ kernel default (8030).
|
|
636
666
|
*/
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Opaque result-fetch handle returned by
|
|
641
|
-
* `AsyncStatement.awaitResult()`. Wraps a kernel `ResultStream`
|
|
642
|
-
* directly; structurally analogous to the sync `Statement`'s
|
|
643
|
-
* fetch-side surface (`fetchNextBatch` / `schema` /
|
|
644
|
-
* `statementId`).
|
|
645
|
-
*
|
|
646
|
-
* `cancel()` / `close()` are not exposed: the parent
|
|
647
|
-
* `AsyncStatement` owns server-side lifecycle. A `close()` here
|
|
648
|
-
* would create dual-ownership of the same statement_id with
|
|
649
|
-
* inconsistent close semantics. Callers `close()` the parent
|
|
650
|
-
* `AsyncStatement` after they're done fetching.
|
|
651
|
-
*
|
|
652
|
-
* Schema is cached at construction so it survives the underlying
|
|
653
|
-
* stream being drained; mirrors the sync `Statement.schema()`
|
|
654
|
-
* post-close contract.
|
|
655
|
-
*/
|
|
656
|
-
export declare class AsyncResultHandle {
|
|
667
|
+
oauthRedirectPort?: number
|
|
657
668
|
/**
|
|
658
|
-
*
|
|
659
|
-
* for
|
|
660
|
-
* `statementId`.
|
|
669
|
+
* OAuth scopes override (M2M / U2M). Omitted ⇒ kernel defaults
|
|
670
|
+
* (`["all-apis"]` for M2M; `["sql", "offline_access"]` for U2M).
|
|
661
671
|
*/
|
|
662
|
-
|
|
672
|
+
oauthScopes?: Array<string>
|
|
663
673
|
/**
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
*
|
|
674
|
+
* OAuth token endpoint override. When omitted the kernel discovers the
|
|
675
|
+
* endpoint via the workspace's OIDC configuration. Set it to point the
|
|
676
|
+
* client-credentials / JWT client-assertion grant at the workspace's
|
|
677
|
+
* configured IdP token endpoint (e.g. Entra ID for Azure Databricks),
|
|
678
|
+
* which is required when that IdP — not Databricks-native OIDC — is the
|
|
679
|
+
* authority for [`AuthMode::OAuthM2m`] / [`AuthMode::OAuthM2mJwt`].
|
|
670
680
|
*/
|
|
671
|
-
|
|
681
|
+
tokenUrl?: string
|
|
672
682
|
/**
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
* `
|
|
677
|
-
* `Arc<Schema>`.
|
|
683
|
+
* U2M on-disk token-cache control (kernel path). Omitted ⇒ the kernel
|
|
684
|
+
* default (cache enabled, encrypted under a machine-local key, survives
|
|
685
|
+
* restarts). `false` disables on-disk persistence (re-login each fresh
|
|
686
|
+
* process); `true` keeps it enabled. Applies to [`AuthMode::OAuthU2m`].
|
|
678
687
|
*/
|
|
679
|
-
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* Handle returned by `Connection.executeStatementCancellable`. Owns the
|
|
683
|
-
* built-but-not-yet-executed kernel `Statement` plus a detached
|
|
684
|
-
* [`StatementCanceller`] captured before dispatch, so JS can fire a
|
|
685
|
-
* server-side cancel while the blocking `result()` is in flight.
|
|
686
|
-
*
|
|
687
|
-
* `pending` is `Arc<Mutex<Option<KernelStatement>>>` so `result()` can
|
|
688
|
-
* `.take()` the statement (the kernel `execute()` borrows it `&mut`,
|
|
689
|
-
* then it moves into the produced `Statement` wrapper to keep its
|
|
690
|
-
* `ValidityFlag` set — see `statement.rs`). A second `result()` call
|
|
691
|
-
* after the first resolved surfaces `InvalidStatementHandle`.
|
|
692
|
-
*/
|
|
693
|
-
export declare class CancellableExecution {
|
|
688
|
+
tokenCacheEnabled?: boolean
|
|
694
689
|
/**
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
*
|
|
690
|
+
* Optional passphrase for the U2M on-disk token cache (AES-256 key).
|
|
691
|
+
* Omitted/blank ⇒ a machine-local derived key. Supplying one is stronger.
|
|
692
|
+
* A passphrase with no explicit `tokenCacheEnabled` implies enabled.
|
|
693
|
+
* Applies to [`AuthMode::OAuthU2m`].
|
|
699
694
|
*/
|
|
700
|
-
|
|
695
|
+
tokenCachePassphrase?: string
|
|
701
696
|
/**
|
|
702
|
-
*
|
|
703
|
-
*
|
|
704
|
-
* reaches a terminal state and the result stream is ready.
|
|
705
|
-
*
|
|
706
|
-
* Consumes the pending statement: a second `result()` call returns
|
|
707
|
-
* `KernelError(InvalidStatementHandle)`. The future is
|
|
708
|
-
* drop-cancel-safe — the kernel's per-execute `MidExecuteCancelState`
|
|
709
|
-
* guard fires a fire-and-forget `cancel_statement` if this future is
|
|
710
|
-
* dropped mid-flight (`Promise.race` / timeout loser), independently
|
|
711
|
-
* of an explicit `cancel()`.
|
|
712
|
-
*
|
|
713
|
-
* On a server-side cancel the kernel's blocking `execute()` currently
|
|
714
|
-
* surfaces `InvalidArgument` (a known kernel quirk — the async path
|
|
715
|
-
* returns `Cancelled`). When this handle's `cancel()` actually dispatched a
|
|
716
|
-
* server-side cancel, we normalise that into `Cancelled` here so JS callers
|
|
717
|
-
* can rely on a single cancelled-status code regardless of execution path.
|
|
718
|
-
*
|
|
719
|
-
* Three outcomes can race the blocking drive: (1) a natural terminal state
|
|
720
|
-
* → `Ok` or the genuine error; (2) an explicit `cancel()` that dispatched a
|
|
721
|
-
* server cancel → this `result()` rejects with a `Cancelled`-coded error
|
|
722
|
-
* (the normalisation above); (3) the future being **dropped** mid-flight
|
|
723
|
-
* (`Promise.race`/timeout loser) → the kernel's `MidExecuteCancelState`
|
|
724
|
-
* drop-guard fires a fire-and-forget `cancel_statement`, but there is no
|
|
725
|
-
* `result()` left to observe a code. Only (2) yields a `Cancelled` error.
|
|
697
|
+
* Path to the PEM private-key file. Required for
|
|
698
|
+
* [`AuthMode::OAuthM2mJwt`].
|
|
726
699
|
*/
|
|
727
|
-
|
|
700
|
+
jwtKeyFile?: string
|
|
701
|
+
/** JWT key id (`kid`). Required for [`AuthMode::OAuthM2mJwt`]. */
|
|
702
|
+
jwtKid?: string
|
|
728
703
|
/**
|
|
729
|
-
*
|
|
730
|
-
*
|
|
731
|
-
* Lock-free: fires the detached `StatementCanceller` captured at
|
|
732
|
-
* construction rather than taking the mutex `result()` holds, so it
|
|
733
|
-
* interrupts a still-running blocking `result()` instead of queueing
|
|
734
|
-
* behind it. No-op (returns `Ok`) if `result()` already finished
|
|
735
|
-
* successfully, or if no statement id has been observed yet (query still
|
|
736
|
-
* in its initial submit round-trip), and idempotent against a server
|
|
737
|
-
* already in a terminal state.
|
|
704
|
+
* Passphrase for an encrypted PKCS#8 key. Optional for
|
|
705
|
+
* [`AuthMode::OAuthM2mJwt`] (omit for an unencrypted key).
|
|
738
706
|
*/
|
|
739
|
-
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* Opaque connection handle wrapping a kernel `Session`.
|
|
743
|
-
*
|
|
744
|
-
* `inner` is `Arc<Mutex<Option<Session>>>` so:
|
|
745
|
-
* - the Drop impl can clone the `Arc` and `.take()` the session on a
|
|
746
|
-
* background tokio task without holding `&mut self` (which Drop is
|
|
747
|
-
* forbidden from doing across an `await`),
|
|
748
|
-
* - `close()` can `.take()` the session to consume it for the kernel's
|
|
749
|
-
* move-by-value `Session::close(self)` signature.
|
|
750
|
-
*
|
|
751
|
-
* **Concurrency shape** — both `executeStatement` and
|
|
752
|
-
* `submitStatement` build the kernel `Statement` under `inner.lock()`
|
|
753
|
-
* and then RELEASE the guard before the wire call
|
|
754
|
-
* (`stmt.execute().await` / `stmt.submit().await`). `Session::statement()`
|
|
755
|
-
* is `&self`-callable and only clones the session's internal `Arc`, so
|
|
756
|
-
* the built statement is independent of the guard. Concurrent
|
|
757
|
-
* `Promise.all([executeStatement(q1), submitStatement(q2)])` therefore
|
|
758
|
-
* serialise only for the microsecond statement-build, not the network
|
|
759
|
-
* round-trip, and `close()` never blocks behind an in-flight execute or
|
|
760
|
-
* submit. See
|
|
761
|
-
* `sea-workflow/jira-candidates/2026-05-24-napi-cancel-during-fetch.md`.
|
|
762
|
-
*/
|
|
763
|
-
export declare class Connection {
|
|
707
|
+
jwtPassphrase?: string
|
|
764
708
|
/**
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
709
|
+
* JWT signing algorithm (`RS256`/`384`/`512`, `PS256`/`384`/`512`,
|
|
710
|
+
* `ES256`, `ES384`). Optional for [`AuthMode::OAuthM2mJwt`]
|
|
711
|
+
* (omitted ⇒ kernel default `RS256`).
|
|
768
712
|
*/
|
|
769
|
-
|
|
713
|
+
jwtAlgorithm?: string
|
|
770
714
|
/**
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
* Catalog / schema / sessionConf are session-level
|
|
775
|
-
* (`openSession`). Per-statement options on `ExecuteOptions`:
|
|
776
|
-
* - `statementConf` — per-statement Spark conf overlay
|
|
777
|
-
* - `queryTags` — serialised to a comma-separated `key:value`
|
|
778
|
-
* string and placed in `statement_conf["query_tags"]`,
|
|
779
|
-
* matching NodeJS Thrift's `serializeQueryTags` wire shape
|
|
780
|
-
*
|
|
781
|
-
* `options` is omitted/`None` for the no-options path; passing
|
|
782
|
-
* `{ statementConf: {} }` (an empty map) is treated the same as
|
|
783
|
-
* omission to keep the wire shape stable for the common case.
|
|
715
|
+
* SP-wide Workload Identity Federation client id used during mandatory
|
|
716
|
+
* token exchange. Omitted selects BYOT / account-wide WIF.
|
|
784
717
|
*/
|
|
785
|
-
|
|
718
|
+
identityFederationClientId?: string
|
|
786
719
|
/**
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
* and auto-closes on success) and returns WITHOUT polling past it:
|
|
790
|
-
*
|
|
791
|
-
* - a **`Statement`** (left arm) when the query finished within the inline
|
|
792
|
-
* wait — terminal, result ready inline, `close()` is a clean release;
|
|
793
|
-
* - an **`AsyncStatement`** (right arm) when it did not — a poll/cancel
|
|
794
|
-
* handle the caller drives (`status()` / `awaitResult()` / `cancel()`).
|
|
795
|
-
*
|
|
796
|
-
* JS distinguishes the arms by feature-detecting `awaitResult` (present
|
|
797
|
-
* only on `AsyncStatement`). This is the path that gives mid-run cancel for
|
|
798
|
-
* long queries WITHOUT the eager-handle / close-drives workaround: the
|
|
799
|
-
* returned handle always corresponds to a server-owned statement.
|
|
800
|
-
*
|
|
801
|
-
* **Load-bearing contract:** the kernel's `DirectStatement::{Completed,
|
|
802
|
-
* Running}` discriminant cannot ride on these opaque `#[napi]` classes, so
|
|
803
|
-
* consumers MUST feature-detect via `awaitResult` (the only member unique to
|
|
804
|
-
* `AsyncStatement`). `Statement` (the Completed arm) MUST NOT gain an
|
|
805
|
-
* `awaitResult` member, or every consumer silently misroutes. The pyo3
|
|
806
|
-
* binding makes the same `await_result`-probe assumption.
|
|
720
|
+
* Azure Entra app-registration client id. Required for
|
|
721
|
+
* [`AuthMode::AzureSpM2m`]; ignored otherwise.
|
|
807
722
|
*/
|
|
808
|
-
|
|
723
|
+
azureClientId?: string
|
|
809
724
|
/**
|
|
810
|
-
*
|
|
811
|
-
* `
|
|
812
|
-
* the query *while it is still running server-side*.
|
|
813
|
-
*
|
|
814
|
-
* `executeStatement` builds the kernel `Statement`, awaits the
|
|
815
|
-
* blocking `execute()`, and only then hands JS a `Statement` — so a
|
|
816
|
-
* query that runs for several seconds is uncancellable from JS on
|
|
817
|
-
* that path (there is no handle until the blocking call resolves).
|
|
818
|
-
* This method instead builds the statement, captures a detached
|
|
819
|
-
* `StatementCanceller` **before** dispatching `execute()`, and hands
|
|
820
|
-
* JS a `CancellableExecution` immediately. The caller drives the
|
|
821
|
-
* blocking execution via `result()` (resolves to the same
|
|
822
|
-
* `Statement` `executeStatement` returns) and can fire `cancel()`
|
|
823
|
-
* concurrently to interrupt a still-running query mid-COMPUTE.
|
|
824
|
-
*
|
|
825
|
-
* Option semantics are identical to `executeStatement`.
|
|
826
|
-
* Mirrors the pyo3 `Statement.canceller()` / `Statement.execute()`
|
|
827
|
-
* split (PR #121): obtain the canceller before the blocking drive.
|
|
725
|
+
* Azure Entra app-registration client secret. Required for
|
|
726
|
+
* [`AuthMode::AzureSpM2m`].
|
|
828
727
|
*/
|
|
829
|
-
|
|
728
|
+
azureClientSecret?: string
|
|
830
729
|
/**
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
834
|
-
* `wait_timeout=0s`, so the server responds as soon as it has a
|
|
835
|
-
* `statement_id` (state `Pending`/`Running`); JS drives polling
|
|
836
|
-
* via `AsyncStatement.status()` and materialises results with
|
|
837
|
-
* `AsyncStatement.awaitResult()`.
|
|
838
|
-
*
|
|
839
|
-
* This is the async-execution path the Thrift backend always
|
|
840
|
-
* uses (`runAsync: true`): the SEA backend submits, returns a
|
|
841
|
-
* pending operation handle, and polls to terminal during
|
|
842
|
-
* fetch. Option semantics (statementConf / queryTags /
|
|
843
|
-
* rowLimit / positional + named params) match `executeStatement`.
|
|
844
|
-
* Submit always sends `wait_timeout=0s` so the call returns
|
|
845
|
-
* immediately; the caller drives completion via `status()` /
|
|
846
|
-
* `awaitResult()`. Only the blocking-vs-pending return contract
|
|
847
|
-
* differs from `executeStatement`.
|
|
730
|
+
* Azure Entra tenant id. Optional for [`AuthMode::AzureSpM2m`];
|
|
731
|
+
* omitted ⇒ the kernel auto-discovers it from the workspace's
|
|
732
|
+
* `/aad/auth` redirect (matching the Thrift connector).
|
|
848
733
|
*/
|
|
849
|
-
|
|
734
|
+
azureTenantId?: string
|
|
850
735
|
/**
|
|
851
|
-
*
|
|
852
|
-
*
|
|
853
|
-
*
|
|
854
|
-
*
|
|
855
|
-
*
|
|
856
|
-
*
|
|
857
|
-
* handle is consumed (`take()`) BEFORE the wire `DeleteSession`
|
|
858
|
-
* runs, because `Session::close` takes `self` by value. On `Err`,
|
|
859
|
-
* the napi `inner` is already `None`, so a JS-side retry sees a
|
|
860
|
-
* closed connection and returns `Ok(())` without re-attempting
|
|
861
|
-
* the wire call. The kernel's own `Drop` fire-and-forget retry
|
|
862
|
-
* runs once in the background — the JS caller can log the error
|
|
863
|
-
* but cannot drive a retry. If you need retry-on-failure
|
|
864
|
-
* semantics for `DeleteSession`, layer them above this method.
|
|
736
|
+
* Azure workspace ARM resource id. Optional for [`AuthMode::AzureSpM2m`];
|
|
737
|
+
* when set the kernel also sends the SP management token
|
|
738
|
+
* (`X-Databricks-Azure-SP-Management-Token`) + the
|
|
739
|
+
* `X-Databricks-Azure-Workspace-Resource-Id` header, so a service
|
|
740
|
+
* principal with an Azure RBAC role but no workspace membership can
|
|
741
|
+
* authenticate. Omitted ⇒ the data token authenticates alone.
|
|
865
742
|
*/
|
|
866
|
-
|
|
743
|
+
azureWorkspaceResourceId?: string
|
|
867
744
|
/**
|
|
868
|
-
*
|
|
869
|
-
*
|
|
870
|
-
*
|
|
745
|
+
* Default catalog for statements executed on this session.
|
|
746
|
+
* Routed through the kernel's `DefaultOpts` and onto the SEA
|
|
747
|
+
* `CreateSession.catalog` wire field.
|
|
871
748
|
*/
|
|
872
|
-
|
|
749
|
+
catalog?: string
|
|
873
750
|
/**
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
*
|
|
751
|
+
* Default schema for statements executed on this session.
|
|
752
|
+
* Routed through the kernel's `DefaultOpts` and onto the SEA
|
|
753
|
+
* `CreateSession.schema` wire field.
|
|
877
754
|
*/
|
|
878
|
-
|
|
755
|
+
schema?: string
|
|
879
756
|
/**
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
*
|
|
883
|
-
* filters rows by `TABLE_TYPE` kernel-side.
|
|
884
|
-
*
|
|
885
|
-
* `tableTypes` is an advisory filter. Databricks `SHOW TABLES` does
|
|
886
|
-
* NOT honour the table-type filter server-side; the kernel applies
|
|
887
|
-
* it client-side after the result returns. Callers expecting
|
|
888
|
-
* server-side rejection of off-type tables should not rely on this.
|
|
757
|
+
* Server-bound session conf (Spark conf, `ANSI_MODE`, `TIMEZONE`,
|
|
758
|
+
* query-tag presets, …). Forwarded verbatim to SEA
|
|
759
|
+
* `session_confs`. Unknown keys are rejected server-side.
|
|
889
760
|
*/
|
|
890
|
-
|
|
761
|
+
sessionConf?: Record<string, string>
|
|
891
762
|
/**
|
|
892
|
-
*
|
|
893
|
-
*
|
|
894
|
-
* JDBC `getColumns` shape: 23 columns.
|
|
763
|
+
* Driver name reported in telemetry system configuration. Omitted ⇒
|
|
764
|
+
* kernel default.
|
|
895
765
|
*/
|
|
896
|
-
|
|
766
|
+
driverName?: string
|
|
897
767
|
/**
|
|
898
|
-
*
|
|
899
|
-
*
|
|
768
|
+
* Driver version reported in telemetry system configuration. Omitted ⇒
|
|
769
|
+
* kernel default.
|
|
900
770
|
*/
|
|
901
|
-
|
|
771
|
+
driverVersion?: string
|
|
902
772
|
/**
|
|
903
|
-
*
|
|
904
|
-
*
|
|
773
|
+
* Runtime name reported in telemetry system configuration. Omitted ⇒
|
|
774
|
+
* kernel default.
|
|
905
775
|
*/
|
|
906
|
-
|
|
776
|
+
runtimeName?: string
|
|
907
777
|
/**
|
|
908
|
-
*
|
|
909
|
-
*
|
|
778
|
+
* Runtime version reported in telemetry system configuration. Omitted ⇒
|
|
779
|
+
* kernel default.
|
|
910
780
|
*/
|
|
911
|
-
|
|
781
|
+
runtimeVersion?: string
|
|
912
782
|
/**
|
|
913
|
-
*
|
|
914
|
-
*
|
|
783
|
+
* Runtime vendor reported in telemetry system configuration. Omitted ⇒
|
|
784
|
+
* kernel default.
|
|
915
785
|
*/
|
|
916
|
-
|
|
786
|
+
runtimeVendor?: string
|
|
917
787
|
/**
|
|
918
|
-
*
|
|
919
|
-
*
|
|
788
|
+
* Operating system name reported in telemetry system configuration.
|
|
789
|
+
* Omitted ⇒ kernel default.
|
|
920
790
|
*/
|
|
921
|
-
|
|
791
|
+
osName?: string
|
|
922
792
|
/**
|
|
923
|
-
*
|
|
924
|
-
*
|
|
925
|
-
* optional. All identifiers are exact — no LIKE patterns.
|
|
793
|
+
* Operating system version reported in telemetry system configuration.
|
|
794
|
+
* Omitted ⇒ kernel default.
|
|
926
795
|
*/
|
|
927
|
-
|
|
928
|
-
}
|
|
929
|
-
/**
|
|
930
|
-
* Opaque executed-statement handle.
|
|
931
|
-
*
|
|
932
|
-
* **Current concurrency shape** — every method takes `inner.lock()`
|
|
933
|
-
* and holds the guard across the kernel `.await`. tokio `Mutex` is
|
|
934
|
-
* FIFO, so cancel/close queue behind any in-flight `fetchNextBatch`
|
|
935
|
-
* until it returns naturally. This is a known limitation that exists
|
|
936
|
-
* because the napi shape has not yet been split into an
|
|
937
|
-
* `Arc<dyn ExecutedStatementHandle>` (for cancel/close, which the
|
|
938
|
-
* kernel exposes as `&self`-callable) plus a `Mutex<Option<…>>` only
|
|
939
|
-
* for the borrowed-mut fetch path. The lock-shape refactor needs a
|
|
940
|
-
* small kernel-side accessor and lands in a follow-up PR — see
|
|
941
|
-
* `sea-workflow/jira-candidates/2026-05-24-napi-cancel-during-fetch.md`.
|
|
942
|
-
*
|
|
943
|
-
* `schema` and `statement_id` are cached at construction so they
|
|
944
|
-
* survive `close()` — JS callers building error reports against a
|
|
945
|
-
* disposed statement can still read them.
|
|
946
|
-
*/
|
|
947
|
-
export declare class Statement {
|
|
796
|
+
osVersion?: string
|
|
948
797
|
/**
|
|
949
|
-
*
|
|
950
|
-
*
|
|
951
|
-
* kernel / server logs which key on the same id.
|
|
798
|
+
* Operating system architecture reported in telemetry system
|
|
799
|
+
* configuration. Omitted ⇒ kernel default.
|
|
952
800
|
*/
|
|
953
|
-
|
|
801
|
+
osArch?: string
|
|
954
802
|
/**
|
|
955
|
-
*
|
|
956
|
-
*
|
|
957
|
-
* surface the counter. Mirrors Thrift's
|
|
958
|
-
* `TGetOperationStatusResp.numModifiedRows`.
|
|
803
|
+
* Client application name reported in telemetry system configuration.
|
|
804
|
+
* Omitted ⇒ absent unless the kernel can infer a default.
|
|
959
805
|
*/
|
|
960
|
-
|
|
806
|
+
clientAppName?: string
|
|
961
807
|
/**
|
|
962
|
-
*
|
|
963
|
-
*
|
|
964
|
-
* data note:** may contain SQL fragments or parameter values —
|
|
965
|
-
* redact before centralised logging.
|
|
966
|
-
*
|
|
967
|
-
* Populated on `Succeeded` / `Closed` paths (incl. an empty `Closed`).
|
|
968
|
-
* On terminal-error states (`Failed` / `Cancelled`) the kernel returns
|
|
969
|
-
* an Error instead of a `Statement`, and the same field rides on the JS
|
|
970
|
-
* Error envelope under the same `displayMessage` key.
|
|
808
|
+
* Locale name reported in telemetry system configuration. Omitted ⇒
|
|
809
|
+
* kernel default.
|
|
971
810
|
*/
|
|
972
|
-
|
|
811
|
+
localeName?: string
|
|
973
812
|
/**
|
|
974
|
-
*
|
|
975
|
-
*
|
|
976
|
-
* `TGetOperationStatusResp.diagnosticInfo`. For support surfaces,
|
|
977
|
-
* not user-facing. Same reachability + PII caveats as
|
|
978
|
-
* `displayMessage`.
|
|
813
|
+
* Character-set encoding reported in telemetry system configuration.
|
|
814
|
+
* Omitted ⇒ kernel default.
|
|
979
815
|
*/
|
|
980
|
-
|
|
816
|
+
charSetEncoding?: string
|
|
981
817
|
/**
|
|
982
|
-
*
|
|
983
|
-
*
|
|
984
|
-
|
|
985
|
-
|
|
818
|
+
* Process name reported in telemetry system configuration. Omitted ⇒
|
|
819
|
+
* kernel default.
|
|
820
|
+
*/
|
|
821
|
+
processName?: string
|
|
822
|
+
/**
|
|
823
|
+
* Maximum number of pooled HTTP connections per host. Routes
|
|
824
|
+
* through the kernel's [`HttpConfig::pool_max_idle_per_host`].
|
|
825
|
+
* Tunes the underlying `reqwest` connection pool — higher values
|
|
826
|
+
* reduce reconnect overhead when many statements run
|
|
827
|
+
* concurrently against the same warehouse.
|
|
986
828
|
*
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
*
|
|
992
|
-
*
|
|
829
|
+
* When the JS caller does NOT provide `maxConnections`, the napi
|
|
830
|
+
* binding applies a NodeJS-driver-appropriate default of
|
|
831
|
+
* [`NAPI_DEFAULT_POOL_MAX_IDLE_PER_HOST`] (100) — chosen to match
|
|
832
|
+
* the JDBC driver's `HttpConnectionPoolSize` default and to close
|
|
833
|
+
* the throughput gap vs the NodeJS Thrift driver's
|
|
834
|
+
* `maxSockets: Infinity` pool for bursty workloads. The kernel
|
|
835
|
+
* core's [`HttpConfig::pool_max_idle_per_host`] default is also 100
|
|
836
|
+
* (matching the same JDBC default), so napi pins its own copy rather
|
|
837
|
+
* than inheriting it. Mirrors the Python connector's
|
|
838
|
+
* `max_connections` kwarg on the SEA backend, which exposes the
|
|
839
|
+
* knob but keeps its own urllib3-aligned default of 10.
|
|
993
840
|
*
|
|
994
|
-
*
|
|
995
|
-
*
|
|
841
|
+
* Napi-rs serialises `u32` as JS `number`; values up to
|
|
842
|
+
* `2^32 - 1` round-trip safely (any reasonable pool size fits).
|
|
996
843
|
*/
|
|
997
|
-
|
|
844
|
+
maxConnections?: number
|
|
998
845
|
/**
|
|
999
|
-
*
|
|
1000
|
-
*
|
|
1001
|
-
* Arrow
|
|
1002
|
-
*
|
|
1003
|
-
*
|
|
1004
|
-
*
|
|
1005
|
-
* `close()` and discard the `Statement`. Subsequent
|
|
1006
|
-
* `fetchNextBatch()` calls after an error are not guaranteed to
|
|
1007
|
-
* succeed or fail consistently.
|
|
846
|
+
* Render `INTERVAL` / `DURATION` result columns as strings
|
|
847
|
+
* (`ResultConfig.intervals_as_string`). The kernel default is
|
|
848
|
+
* native Arrow `month_interval` / `duration[us]` types; the NodeJS
|
|
849
|
+
* Thrift driver surfaces intervals as strings, so the SEA driver
|
|
850
|
+
* sets this `true` for byte-compatible parity. Omitted ⇒ kernel
|
|
851
|
+
* default (native Arrow interval types).
|
|
1008
852
|
*/
|
|
1009
|
-
|
|
853
|
+
intervalsAsString?: boolean
|
|
1010
854
|
/**
|
|
1011
|
-
*
|
|
1012
|
-
*
|
|
1013
|
-
*
|
|
1014
|
-
*
|
|
1015
|
-
*
|
|
855
|
+
* Render complex (`ARRAY` / `MAP` / `STRUCT` / `VARIANT`) result
|
|
856
|
+
* columns as JSON strings (`ResultConfig.complex_types_as_json`)
|
|
857
|
+
* instead of native Arrow nested types. Omitted ⇒ kernel default
|
|
858
|
+
* (native Arrow nested types, which the NodeJS Arrow decoder
|
|
859
|
+
* already renders identically to the Thrift path).
|
|
860
|
+
*/
|
|
861
|
+
complexTypesAsJson?: boolean
|
|
862
|
+
/**
|
|
863
|
+
* Whether to verify the server's TLS certificate.
|
|
1016
864
|
*
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
1020
|
-
*
|
|
1021
|
-
*
|
|
1022
|
-
* `
|
|
1023
|
-
*
|
|
865
|
+
* Omitted / `true` ⇒ strict validation against the system / Mozilla
|
|
866
|
+
* trust store (full chain + expiry + hostname), matching JDBC / ODBC
|
|
867
|
+
* and every modern HTTPS client. This is the **default** for the SEA
|
|
868
|
+
* backend — secure by default.
|
|
869
|
+
*
|
|
870
|
+
* `false` ⇒ permissive: accept self-signed / untrusted / expired
|
|
871
|
+
* certs AND skip the hostname-vs-SNI check. This is **insecure** (no
|
|
872
|
+
* protection against active MITM); it exists only as an opt-out for
|
|
873
|
+
* parity with the legacy NodeJS Thrift driver, which hard-codes
|
|
874
|
+
* `rejectUnauthorized: false`. Prefer pairing strict checking with
|
|
875
|
+
* `custom_ca_cert` over disabling verification entirely.
|
|
876
|
+
*
|
|
877
|
+
* This is the master verify toggle: `false` disables chain validation
|
|
878
|
+
* (`TlsConfig::accept_self_signed`) **and** subsumes the hostname
|
|
879
|
+
* check (`skip_hostname_verification`), regardless of
|
|
880
|
+
* `check_server_certificate_hostname`.
|
|
1024
881
|
*/
|
|
1025
|
-
|
|
882
|
+
checkServerCertificate?: boolean
|
|
1026
883
|
/**
|
|
1027
|
-
*
|
|
884
|
+
* Whether to verify that the server certificate matches the host
|
|
885
|
+
* (hostname-vs-SNI check), **independently** of full chain validation.
|
|
1028
886
|
*
|
|
1029
|
-
*
|
|
1030
|
-
* `
|
|
1031
|
-
*
|
|
1032
|
-
*
|
|
1033
|
-
*
|
|
1034
|
-
*
|
|
887
|
+
* Omitted / `true` ⇒ the hostname check runs (the secure default).
|
|
888
|
+
* `false` ⇒ skip only the hostname check while still validating the
|
|
889
|
+
* chain + expiry against the trust store — for connecting via an IP
|
|
890
|
+
* literal or a host the cert wasn't issued for, without dropping all
|
|
891
|
+
* validation. Ignored (already implied) when
|
|
892
|
+
* `check_server_certificate` is `false`, which disables everything.
|
|
1035
893
|
*
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
894
|
+
* Mirrors the Python connector's `_tls_verify_hostname` knob and the
|
|
895
|
+
* kernel's [`TlsConfig::skip_hostname_verification`] (= `!check`).
|
|
896
|
+
*/
|
|
897
|
+
checkServerCertificateHostname?: boolean
|
|
898
|
+
/**
|
|
899
|
+
* PEM-encoded CA certificate bytes to add to the trust store on
|
|
900
|
+
* top of the system roots. Use for corporate TLS-inspecting
|
|
901
|
+
* proxies that re-sign TLS, or on-prem deployments with an
|
|
902
|
+
* internal CA. Honoured regardless of `check_server_certificate`.
|
|
903
|
+
* Maps onto the kernel [`TlsConfig::custom_ca_cert`].
|
|
904
|
+
*/
|
|
905
|
+
customCaCert?: Buffer
|
|
906
|
+
/**
|
|
907
|
+
* PEM-encoded client certificate for mutual TLS (mTLS). Set this
|
|
908
|
+
* together with `client_key_pem` when the server requires the
|
|
909
|
+
* client to present a certificate. A PEM carrying a leaf cert
|
|
910
|
+
* optionally followed by its intermediate chain is accepted.
|
|
911
|
+
* Maps onto the kernel [`TlsConfig::client_cert_pem`].
|
|
1038
912
|
*
|
|
1039
|
-
*
|
|
1040
|
-
*
|
|
913
|
+
* `client_cert_pem` and `client_key_pem` must be supplied together;
|
|
914
|
+
* the kernel rejects setting only one at `open_session` with
|
|
915
|
+
* `InvalidArgument`.
|
|
1041
916
|
*/
|
|
1042
|
-
|
|
917
|
+
clientCertPem?: Buffer
|
|
1043
918
|
/**
|
|
1044
|
-
*
|
|
919
|
+
* PEM-encoded private key for the mTLS client certificate. Set this
|
|
920
|
+
* together with `client_cert_pem`. For portability across the
|
|
921
|
+
* kernel's TLS backends supply a PKCS#8 key (`BEGIN PRIVATE KEY`).
|
|
922
|
+
* Maps onto the kernel [`TlsConfig::client_key_pem`].
|
|
923
|
+
*/
|
|
924
|
+
clientKeyPem?: Buffer
|
|
925
|
+
/**
|
|
926
|
+
* Extra HTTP headers to send on every request — the route for
|
|
927
|
+
* caller-supplied headers (the NodeJS driver's `customHeaders` and
|
|
928
|
+
* the composed `User-Agent`). Maps onto the kernel
|
|
929
|
+
* [`HttpConfig::custom_headers`].
|
|
1045
930
|
*
|
|
1046
|
-
*
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
931
|
+
* An **ordered list** of `(name, value)` pairs, mirroring the kernel
|
|
932
|
+
* core's `Vec<(String, String)>` and the pyo3 binding's
|
|
933
|
+
* `http_headers` — order is preserved and duplicate names are
|
|
934
|
+
* allowed (the kernel emits each entry, and for `User-Agent` folds
|
|
935
|
+
* the **last** one into its base UA).
|
|
1050
936
|
*
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
*
|
|
1054
|
-
*
|
|
1055
|
-
*
|
|
1056
|
-
*
|
|
1057
|
-
*
|
|
1058
|
-
*
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1061
|
-
*
|
|
1062
|
-
|
|
937
|
+
* Three names are handled specially by the kernel:
|
|
938
|
+
* - `Authorization` / `x-databricks-org-id` are **reserved** — a
|
|
939
|
+
* caller entry for either is silently dropped (skip-and-warn) so
|
|
940
|
+
* auth and multi-tenant routing can't be hijacked by a custom
|
|
941
|
+
* header. (The NodeJS driver also drops these before they cross
|
|
942
|
+
* the FFI, matching the Python connector's double-wall.)
|
|
943
|
+
* - `User-Agent` is **appended** to the kernel base UA (rather than
|
|
944
|
+
* replacing it), preserving the `DatabricksJDBCDriverOSS/...`
|
|
945
|
+
* token the SEA server keys on while still surfacing the caller's
|
|
946
|
+
* identity. The NodeJS driver folds its `userAgentEntry` into a
|
|
947
|
+
* `User-Agent` entry here.
|
|
948
|
+
*/
|
|
949
|
+
customHeaders?: Array<HeaderEntry>
|
|
950
|
+
/**
|
|
951
|
+
* Retry/backoff tuning — all optional. An unset field keeps the kernel's
|
|
952
|
+
* built-in policy (1s/60s exponential backoff, 6 total attempts, 900s
|
|
953
|
+
* budget). Mirrors the pyo3 binding's `retry_*` kwargs so the Node.js
|
|
954
|
+
* driver can forward the same retry knobs the Python connector does.
|
|
1063
955
|
*
|
|
1064
|
-
*
|
|
1065
|
-
*
|
|
1066
|
-
* resource to release).
|
|
956
|
+
* Lower bound of the exponential backoff (also clamps a server
|
|
957
|
+
* `Retry-After`). Maps onto [`HttpConfig::retry_min_wait`].
|
|
1067
958
|
*/
|
|
1068
|
-
|
|
1069
|
-
|
|
959
|
+
retryMinWaitSecs?: number
|
|
960
|
+
/**
|
|
961
|
+
* Upper bound of the exponential backoff. Maps onto
|
|
962
|
+
* [`HttpConfig::retry_max_wait`].
|
|
963
|
+
*/
|
|
964
|
+
retryMaxWaitSecs?: number
|
|
965
|
+
/**
|
|
966
|
+
* **Total** number of attempts (matching the connector's
|
|
967
|
+
* `_retry_stop_after_attempts_count` and JDBC count semantics). The
|
|
968
|
+
* kernel's [`HttpConfig::retry_max_retries`] counts retries *after* the
|
|
969
|
+
* first attempt, so this is converted with `max(0, attempts - 1)` in
|
|
970
|
+
* [`build_http_config`] — `0` / `1` both mean a single attempt, no retry.
|
|
971
|
+
*/
|
|
972
|
+
retryMaxAttempts?: number
|
|
973
|
+
/**
|
|
974
|
+
* Overall retry budget in whole seconds. Maps onto
|
|
975
|
+
* [`HttpConfig::overall_timeout`].
|
|
976
|
+
*/
|
|
977
|
+
retryOverallTimeoutSecs?: number
|
|
978
|
+
/**
|
|
979
|
+
* Enable kernel telemetry export. Omitted / `false` keeps telemetry
|
|
980
|
+
* disabled. When enabled, the kernel records operation telemetry below the
|
|
981
|
+
* binding layer and exports through the Databricks SQL driver telemetry
|
|
982
|
+
* endpoint.
|
|
983
|
+
*/
|
|
984
|
+
telemetryEnabled?: boolean
|
|
985
|
+
/**
|
|
986
|
+
* Number of telemetry events buffered before a flush. Omitted ⇒ kernel
|
|
987
|
+
* default. Must be greater than zero when supplied.
|
|
988
|
+
*/
|
|
989
|
+
telemetryBatchSize?: number
|
|
990
|
+
/**
|
|
991
|
+
* Periodic telemetry flush interval in milliseconds. Omitted ⇒ kernel
|
|
992
|
+
* default. Must be greater than zero when supplied.
|
|
993
|
+
*/
|
|
994
|
+
telemetryFlushIntervalMs?: number
|
|
995
|
+
/** Maximum telemetry export retries. `0` disables telemetry export retries. */
|
|
996
|
+
telemetryMaxRetries?: number
|
|
997
|
+
/** Fixed telemetry retry delay in milliseconds. `0` means immediate retry. */
|
|
998
|
+
telemetryRetryDelayMs?: number
|
|
999
|
+
/**
|
|
1000
|
+
* Maximum time explicit close waits for telemetry final flush, in
|
|
1001
|
+
* milliseconds. Omitted ⇒ kernel default. Must be greater than zero when
|
|
1002
|
+
* supplied.
|
|
1003
|
+
*/
|
|
1004
|
+
telemetryCloseFlushTimeoutMs?: number
|
|
1005
|
+
/** Enable telemetry circuit-breaker protection. Omitted ⇒ kernel default. */
|
|
1006
|
+
telemetryCircuitBreakerEnabled?: boolean
|
|
1007
|
+
/**
|
|
1008
|
+
* Consecutive telemetry export failures before opening the circuit.
|
|
1009
|
+
* Omitted ⇒ kernel default. Must be greater than zero when the circuit
|
|
1010
|
+
* breaker is enabled.
|
|
1011
|
+
*/
|
|
1012
|
+
telemetryCircuitBreakerThreshold?: number
|
|
1013
|
+
/**
|
|
1014
|
+
* Time the telemetry circuit stays open before a half-open probe, in
|
|
1015
|
+
* milliseconds. Omitted ⇒ kernel default. Must be greater than zero when
|
|
1016
|
+
* supplied.
|
|
1017
|
+
*/
|
|
1018
|
+
telemetryCircuitBreakerTimeoutMs?: number
|
|
1019
|
+
/**
|
|
1020
|
+
* Programmatic HTTP/HTTPS proxy ([`ProxyInput`]) to route all kernel
|
|
1021
|
+
* traffic through. Carries the proxy `url`, optional basic-auth
|
|
1022
|
+
* `username` / `password`, and an optional `bypassHosts` list — mapped
|
|
1023
|
+
* field-for-field onto the kernel [`ProxyConfig`].
|
|
1024
|
+
*
|
|
1025
|
+
* Omitted ⇒ the kernel does NOT configure a proxy explicitly and
|
|
1026
|
+
* `reqwest`'s standard behaviour applies — the `HTTPS_PROXY` /
|
|
1027
|
+
* `HTTP_PROXY` / `NO_PROXY` environment variables are still honoured.
|
|
1028
|
+
* Setting this **overrides** those env vars. This complements the env-var
|
|
1029
|
+
* path: callers who cannot set process env vars (e.g. a long-lived Node
|
|
1030
|
+
* server) can now route a single connection through a proxy
|
|
1031
|
+
* programmatically.
|
|
1032
|
+
*/
|
|
1033
|
+
proxy?: ProxyInput
|
|
1034
|
+
/**
|
|
1035
|
+
* Per-connection socket read timeout, in milliseconds. Caps how
|
|
1036
|
+
* long a single HTTP round-trip may block waiting on the server
|
|
1037
|
+
* before the request errors out. Maps onto the kernel
|
|
1038
|
+
* [`HttpConfig::request_timeout`] (the internal reqwest
|
|
1039
|
+
* `Client::timeout`).
|
|
1040
|
+
*
|
|
1041
|
+
* Omitted ⇒ kernel default (120 000 ms / 120 s). Napi-rs
|
|
1042
|
+
* serialises `u32` as JS `number`; the largest representable value
|
|
1043
|
+
* (~49.7 days) far exceeds any sensible socket timeout.
|
|
1044
|
+
*/
|
|
1045
|
+
socketTimeoutMs?: number
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* Per-statement options for `Connection.executeStatement`.
|
|
1050
|
+
*
|
|
1051
|
+
* Mirrors the kernel `StatementSpec` knobs that are safe to thread
|
|
1052
|
+
* through napi without a kernel-side change. Today this covers:
|
|
1053
|
+
* - `statementConf` — per-statement Spark conf overlay
|
|
1054
|
+
* (`StatementSpec.statement_conf` → SEA `parameters` /
|
|
1055
|
+
* Thrift `confOverlay`)
|
|
1056
|
+
* - `queryTags` — convenience wrapper over `statementConf` with
|
|
1057
|
+
* key `query_tags`; serialised to the same comma-separated
|
|
1058
|
+
* `key:value` wire shape NodeJS Thrift's `serializeQueryTags`
|
|
1059
|
+
* produces (`lib/utils/queryTags.ts`). Backslashes in keys are
|
|
1060
|
+
* doubled; backslash/colon/comma in values are backslash-escaped.
|
|
1061
|
+
*
|
|
1062
|
+
* `rowLimit` (SEA `row_limit`) is exposed here and threaded onto the kernel
|
|
1063
|
+
* `StatementSpec`. `positionalParams` (`?`) and `namedParams` (`:name`)
|
|
1064
|
+
* carry bound query parameters, decoded via `params::parse_typed_value`.
|
|
1065
|
+
* `rawParams` forwards pre-marshalled SEA parameters unchanged.
|
|
1066
|
+
* (There is no `queryTimeoutSecs`: it abused the SEA `wait_timeout` inline-hold
|
|
1067
|
+
* window and was removed — a real per-statement timeout is `STATEMENT_TIMEOUT`.)
|
|
1068
|
+
*
|
|
1069
|
+
* **Tag-order caveat (M4 parity note).** The napi `queryTags` field
|
|
1070
|
+
* is a Rust `HashMap<String, String>` whose iteration order is
|
|
1071
|
+
* non-deterministic, so the serialised `query_tags` value may have
|
|
1072
|
+
* a different key order than Thrift's `serializeQueryTags` (which
|
|
1073
|
+
* iterates `Object.keys(...)` in insertion order) for the same
|
|
1074
|
+
* input. The SEA server is order-insensitive on conf values, so
|
|
1075
|
+
* the two are functionally equivalent. If a caller needs
|
|
1076
|
+
* byte-identical Thrift parity, the JS adapter pre-serialises via
|
|
1077
|
+
* `serializeQueryTags` and writes the result into
|
|
1078
|
+
* `statementConf["query_tags"]` directly — see
|
|
1079
|
+
* `KernelSessionBackend.executeStatement` in the NodeJS driver. This
|
|
1080
|
+
* path is the one the production code uses.
|
|
1081
|
+
*/
|
|
1082
|
+
export interface ExecuteOptions {
|
|
1083
|
+
/**
|
|
1084
|
+
* Per-statement Spark conf overlay. Merged on top of the
|
|
1085
|
+
* session-level `sessionConf` at execute time; this map wins
|
|
1086
|
+
* on key collisions. Unknown keys are rejected by the server.
|
|
1087
|
+
*/
|
|
1088
|
+
statementConf?: Record<string, string>
|
|
1089
|
+
/**
|
|
1090
|
+
* Query tags as key→value pairs. Serialised to a comma-
|
|
1091
|
+
* separated `key:value` string (backslash-escaping `\`, `:`,
|
|
1092
|
+
* `,`) and placed into `statementConf["query_tags"]`, matching
|
|
1093
|
+
* NodeJS Thrift's `serializeQueryTags` wire shape. Passing
|
|
1094
|
+
* both `queryTags` AND a `query_tags` key in `statementConf`
|
|
1095
|
+
* raises `InvalidArgument` — the caller's intent is ambiguous
|
|
1096
|
+
* so we refuse to silently pick one over the other.
|
|
1097
|
+
*
|
|
1098
|
+
* A **`null`** value emits a **bare key** (no colon) — e.g.
|
|
1099
|
+
* `{ production: null }` → `"production"` — matching the
|
|
1100
|
+
* connectors' `key`-only tag form.
|
|
1101
|
+
*
|
|
1102
|
+
* See the struct-level "Tag-order caveat" for the
|
|
1103
|
+
* HashMap-iteration-order vs `Object.keys`-iteration-order
|
|
1104
|
+
* divergence and the byte-identical-Thrift-parity workaround.
|
|
1105
|
+
*/
|
|
1106
|
+
queryTags?: Record<string, string | undefined | null>
|
|
1107
|
+
/**
|
|
1108
|
+
* Server-side cap on the number of rows this statement returns
|
|
1109
|
+
* (SEA `row_limit`), independent of any SQL `LIMIT`. Maps to
|
|
1110
|
+
* `StatementSpec.row_limit`. Omitted ⇒ no driver-imposed cap.
|
|
1111
|
+
*/
|
|
1112
|
+
rowLimit?: number
|
|
1113
|
+
/**
|
|
1114
|
+
* Positional parameters, in 1-based wire order. Index `i` in this
|
|
1115
|
+
* Vec corresponds to the `i+1`-th `?` placeholder in the SQL.
|
|
1116
|
+
* Each entry is a `{ sqlType, value }` pair — `value` is the
|
|
1117
|
+
* string-encoded literal or `null` for SQL NULL. Mirrors
|
|
1118
|
+
* `StatementSpec::positional_params`; decoded via [`parse_typed_value`].
|
|
1119
|
+
*/
|
|
1120
|
+
positionalParams?: Array<TypedValueInput>
|
|
1121
|
+
/**
|
|
1122
|
+
* Named parameters (`:name` placeholders). Each carries its `name`
|
|
1123
|
+
* alongside the `{ sqlType, value? }` pair. Mapped to a kernel
|
|
1124
|
+
* `TypedValue` via the same [`parse_typed_value`] codec and bound with
|
|
1125
|
+
* `StatementSpec::param_named`. Named is the SEA-spec-required public
|
|
1126
|
+
* param form (`StatementParameter.name` is `openapi_required`);
|
|
1127
|
+
* positional is the documented-undocumented variant. The two are
|
|
1128
|
+
* mutually exclusive at the SQL level (`?` vs `:name`).
|
|
1129
|
+
*/
|
|
1130
|
+
namedParams?: Array<NamedTypedValueInput>
|
|
1131
|
+
/**
|
|
1132
|
+
* Pre-marshalled parameters passed through `StatementSpec::param_raw`.
|
|
1133
|
+
* Omit `name` for positional values. Raw parameters cannot be mixed with
|
|
1134
|
+
* typed parameters or combine named and positional markers.
|
|
1135
|
+
*/
|
|
1136
|
+
rawParams?: Array<RawParameterInput>
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* A single extra HTTP header as an explicit `{ name, value }` pair.
|
|
1141
|
+
*
|
|
1142
|
+
* An ordered list of these (`ConnectionOptions.custom_headers`) mirrors
|
|
1143
|
+
* the kernel core's `Vec<(String, String)>` and the pyo3 binding's
|
|
1144
|
+
* `http_headers`: order is preserved and duplicate `name`s are allowed.
|
|
1145
|
+
* A struct (rather than a raw `[name, value]` tuple) because napi-rs
|
|
1146
|
+
* does not marshal Rust tuples through `#[napi(object)]` fields; the
|
|
1147
|
+
* struct is the idiomatic, self-documenting equivalent and maps to a JS
|
|
1148
|
+
* `{ name: string, value: string }`.
|
|
1149
|
+
*/
|
|
1150
|
+
export interface HeaderEntry {
|
|
1151
|
+
name: string
|
|
1152
|
+
value: string
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* Install (idempotently) the kernel→JS log bridge and set its level.
|
|
1157
|
+
*
|
|
1158
|
+
* `callback` is invoked with **an array of [`LogRecord`]s** (`(err, records)`)
|
|
1159
|
+
* for each forwarded batch. `level` is one of
|
|
1160
|
+
* `off`/`error`/`warn`/`info`/`debug`/`trace` (case-insensitive); unknown
|
|
1161
|
+
* values fall back to `warn`.
|
|
1162
|
+
*
|
|
1163
|
+
* Safe to call more than once: the process-global subscriber is installed on
|
|
1164
|
+
* the first call only, while every call refreshes the sink + level (last
|
|
1165
|
+
* writer wins — see module docs).
|
|
1166
|
+
*/
|
|
1167
|
+
export declare function initKernelLogging(callback: ((err: Error | null, arg: Array<LogRecord>) => any), level: string): void
|
|
1168
|
+
|
|
1169
|
+
/**
|
|
1170
|
+
* Return the bridge's [`KernelLoggingStats`]. Safe to call before
|
|
1171
|
+
* `initKernelLogging` (reports `installed: false`, `dropped: 0`).
|
|
1172
|
+
*/
|
|
1173
|
+
export declare function kernelLoggingStats(): KernelLoggingStats
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* Snapshot of the bridge's runtime state for observability.
|
|
1177
|
+
*
|
|
1178
|
+
* `installed` is `true` only when the process-global subscriber was
|
|
1179
|
+
* successfully installed by *this* bridge (and the drain thread started);
|
|
1180
|
+
* `false` means another global subscriber was already set or the drain
|
|
1181
|
+
* thread could not be spawned, so kernel logs are NOT reaching the JS sink.
|
|
1182
|
+
* `dropped` is the cumulative count of records discarded because the
|
|
1183
|
+
* bounded channel was full during a burst (drop-newest) — a nonzero,
|
|
1184
|
+
* growing value signals the sink can't keep up.
|
|
1185
|
+
*/
|
|
1186
|
+
export interface KernelLoggingStats {
|
|
1187
|
+
installed: boolean
|
|
1188
|
+
dropped: number
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
/**
|
|
1192
|
+
* One kernel log event, as handed to JS. `level` is a lower-case string
|
|
1193
|
+
* (`error`/`warn`/`info`/`debug`/`trace`) the Node side maps onto its
|
|
1194
|
+
* `LogLevel`; `target` is the originating `tracing` target (e.g.
|
|
1195
|
+
* `databricks::sql::kernel`); `message` is the rendered event plus any
|
|
1196
|
+
* structured `key=value` fields.
|
|
1197
|
+
*/
|
|
1198
|
+
export interface LogRecord {
|
|
1199
|
+
level: string
|
|
1200
|
+
target: string
|
|
1201
|
+
message: string
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* A named bound parameter — a [`TypedValueInput`] plus its `:name`. Kept a
|
|
1206
|
+
* distinct napi object (rather than an optional `name` on `TypedValueInput`)
|
|
1207
|
+
* so the positional surface stays a clean ordered list with no name field.
|
|
1208
|
+
*/
|
|
1209
|
+
export interface NamedTypedValueInput {
|
|
1210
|
+
name: string
|
|
1211
|
+
sqlType: string
|
|
1212
|
+
value?: string
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* Open a Databricks SQL session and return an opaque `Connection`
|
|
1217
|
+
* wrapping the kernel `Session`. Authentication is selected by
|
|
1218
|
+
* `options.auth_mode` (PAT / OAuth M2M / OAuth U2M) — see
|
|
1219
|
+
* [`build_auth_config`].
|
|
1220
|
+
*
|
|
1221
|
+
* The JS-visible name is `openSession` (napi-rs converts snake_case
|
|
1222
|
+
* to camelCase for free functions).
|
|
1223
|
+
*/
|
|
1224
|
+
export declare function openSession(options: ConnectionOptions): Promise<Connection>
|
|
1225
|
+
|
|
1226
|
+
/**
|
|
1227
|
+
* Programmatic HTTP/HTTPS proxy configuration, mirroring the kernel's
|
|
1228
|
+
* internal [`ProxyConfig`]. Supplied as a structured object rather than a
|
|
1229
|
+
* flattened URL so credentials never have to be percent-encoded into the URL
|
|
1230
|
+
* and the bypass-host list can be expressed.
|
|
1231
|
+
*
|
|
1232
|
+
* - `url` — proxy endpoint, e.g. `"http://proxy.corp.example.com:8080"`. Must
|
|
1233
|
+
* use the `http://` or `https://` scheme.
|
|
1234
|
+
* - `username` / `password` — optional proxy basic-auth, applied via
|
|
1235
|
+
* `reqwest`'s `Proxy::basic_auth` (not embedded in the URL).
|
|
1236
|
+
* - `bypassHosts` — optional comma-separated host/domain list that should
|
|
1237
|
+
* bypass the proxy (e.g. `"localhost,*.internal.corp"`).
|
|
1238
|
+
*/
|
|
1239
|
+
export interface ProxyInput {
|
|
1240
|
+
url: string
|
|
1241
|
+
username?: string
|
|
1242
|
+
password?: string
|
|
1243
|
+
bypassHosts?: string
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* A pre-marshalled SEA parameter that preserves `sql_type` verbatim.
|
|
1248
|
+
* Omit `name` for positional markers; the kernel assigns their ordinals.
|
|
1249
|
+
*/
|
|
1250
|
+
export interface RawParameterInput {
|
|
1251
|
+
/** Named marker name. Omit for a positional marker. */
|
|
1252
|
+
name?: string
|
|
1253
|
+
/** Databricks SQL type name sent verbatim to SEA. */
|
|
1254
|
+
sqlType: string
|
|
1255
|
+
/** String-encoded value. `None` represents SQL NULL. */
|
|
1256
|
+
value?: string
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* Live-retarget the bridge's level (one of
|
|
1261
|
+
* `off`/`error`/`warn`/`info`/`debug`/`trace`, case-insensitive).
|
|
1262
|
+
*/
|
|
1263
|
+
export declare function setKernelLogLevel(level: string): void
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* JS-visible binding for a single positional parameter.
|
|
1267
|
+
*
|
|
1268
|
+
* Shape mirrors the `TSparkParameter` wire object the Thrift backend
|
|
1269
|
+
* already emits via `DBSQLParameter.toSparkParameter()` — `type` is the
|
|
1270
|
+
* canonical Databricks SQL type name (`"INT"`, `"STRING"`,
|
|
1271
|
+
* `"DECIMAL(10,2)"`, ...), `value` is the string-encoded literal or
|
|
1272
|
+
* `None` for SQL NULL.
|
|
1273
|
+
*
|
|
1274
|
+
* Why a string for `value` instead of a tagged JS union: round-tripping
|
|
1275
|
+
* arbitrary JS values across the FFI requires either (a) a custom
|
|
1276
|
+
* napi `FromNapiValue` per arm, or (b) a `serde_json::Value`-style
|
|
1277
|
+
* dynamic dispatch on the Rust side. The Node-driver adapter already
|
|
1278
|
+
* stringifies before calling the binding (see `DBSQLParameter` and the
|
|
1279
|
+
* existing pyo3 wrapper), so the string-in / string-parsed contract
|
|
1280
|
+
* adds no JS-side complexity and keeps the kernel-side validation in
|
|
1281
|
+
* one place.
|
|
1282
|
+
*/
|
|
1283
|
+
export interface TypedValueInput {
|
|
1284
|
+
/**
|
|
1285
|
+
* Canonical Databricks SQL type name. Case-insensitive for the
|
|
1286
|
+
* simple variants; for DECIMAL the parenthesised form
|
|
1287
|
+
* (`"DECIMAL(10,2)"`) is required so the kernel can extract
|
|
1288
|
+
* precision/scale.
|
|
1289
|
+
*/
|
|
1290
|
+
sqlType: string
|
|
1291
|
+
/**
|
|
1292
|
+
* String-encoded value. `None` always produces `TypedValue::Null`
|
|
1293
|
+
* regardless of `sql_type` — matches the connector's
|
|
1294
|
+
* `VoidParameter` shape and the pyo3 binding's contract.
|
|
1295
|
+
*/
|
|
1296
|
+
value?: string
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
/**
|
|
1300
|
+
* Returns the native binding's crate version (`CARGO_PKG_VERSION`).
|
|
1301
|
+
*
|
|
1302
|
+
* Originally the round-1b smoke test; kept as a cheap "is the binding
|
|
1303
|
+
* loaded?" probe for the JS-side loader's structured diagnostics.
|
|
1304
|
+
*/
|
|
1305
|
+
export declare function version(): string
|