@databricks/sql 1.15.0 → 1.16.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.
Files changed (118) hide show
  1. package/dist/DBSQLClient.d.ts +3 -0
  2. package/dist/DBSQLClient.js +97 -56
  3. package/dist/DBSQLClient.js.map +1 -1
  4. package/dist/DBSQLLogger.d.ts +3 -0
  5. package/dist/DBSQLLogger.js +25 -0
  6. package/dist/DBSQLLogger.js.map +1 -1
  7. package/dist/DBSQLOperation.d.ts +36 -17
  8. package/dist/DBSQLOperation.js +133 -214
  9. package/dist/DBSQLOperation.js.map +1 -1
  10. package/dist/DBSQLParameter.d.ts +2 -0
  11. package/dist/DBSQLParameter.js +63 -7
  12. package/dist/DBSQLParameter.js.map +1 -1
  13. package/dist/DBSQLSession.d.ts +24 -17
  14. package/dist/DBSQLSession.js +45 -263
  15. package/dist/DBSQLSession.js.map +1 -1
  16. package/dist/connection/connections/HttpRetryPolicy.d.ts +3 -0
  17. package/dist/connection/connections/HttpRetryPolicy.js +116 -21
  18. package/dist/connection/connections/HttpRetryPolicy.js.map +1 -1
  19. package/dist/connection/connections/ThriftHttpConnection.js +18 -3
  20. package/dist/connection/connections/ThriftHttpConnection.js.map +1 -1
  21. package/dist/contracts/IBackend.d.ts +31 -0
  22. package/dist/contracts/IBackend.js +3 -0
  23. package/dist/contracts/IBackend.js.map +1 -0
  24. package/dist/contracts/IClientContext.d.ts +1 -0
  25. package/dist/contracts/IDBSQLClient.d.ts +31 -0
  26. package/dist/contracts/IDBSQLLogger.d.ts +17 -0
  27. package/dist/contracts/IDBSQLLogger.js.map +1 -1
  28. package/dist/contracts/IDBSQLSession.d.ts +24 -1
  29. package/dist/contracts/IOperation.d.ts +10 -1
  30. package/dist/contracts/IOperationBackend.d.ts +98 -0
  31. package/dist/contracts/IOperationBackend.js +3 -0
  32. package/dist/contracts/IOperationBackend.js.map +1 -0
  33. package/dist/contracts/ISessionBackend.d.ts +36 -0
  34. package/dist/contracts/ISessionBackend.js +3 -0
  35. package/dist/contracts/ISessionBackend.js.map +1 -0
  36. package/dist/contracts/InternalConnectionOptions.d.ts +72 -0
  37. package/dist/contracts/InternalConnectionOptions.js +3 -0
  38. package/dist/contracts/InternalConnectionOptions.js.map +1 -0
  39. package/dist/contracts/OperationStatus.d.ts +76 -0
  40. package/dist/contracts/OperationStatus.js +28 -0
  41. package/dist/contracts/OperationStatus.js.map +1 -0
  42. package/dist/contracts/ResultMetadata.d.ts +34 -0
  43. package/dist/contracts/ResultMetadata.js +16 -0
  44. package/dist/contracts/ResultMetadata.js.map +1 -0
  45. package/dist/errors/AuthenticationError.d.ts +1 -0
  46. package/dist/errors/AuthenticationError.js +4 -0
  47. package/dist/errors/AuthenticationError.js.map +1 -1
  48. package/dist/kernel/KernelArrowIpc.d.ts +54 -0
  49. package/dist/kernel/KernelArrowIpc.js +292 -0
  50. package/dist/kernel/KernelArrowIpc.js.map +1 -0
  51. package/dist/kernel/KernelArrowIpcDurationFix.d.ts +29 -0
  52. package/dist/kernel/KernelArrowIpcDurationFix.js +605 -0
  53. package/dist/kernel/KernelArrowIpcDurationFix.js.map +1 -0
  54. package/dist/kernel/KernelAuth.d.ts +300 -0
  55. package/dist/kernel/KernelAuth.js +463 -0
  56. package/dist/kernel/KernelAuth.js.map +1 -0
  57. package/dist/kernel/KernelBackend.d.ts +53 -0
  58. package/dist/kernel/KernelBackend.js +164 -0
  59. package/dist/kernel/KernelBackend.js.map +1 -0
  60. package/dist/kernel/KernelErrorMapping.d.ts +109 -0
  61. package/dist/kernel/KernelErrorMapping.js +249 -0
  62. package/dist/kernel/KernelErrorMapping.js.map +1 -0
  63. package/dist/kernel/KernelInputValidation.d.ts +16 -0
  64. package/dist/kernel/KernelInputValidation.js +49 -0
  65. package/dist/kernel/KernelInputValidation.js.map +1 -0
  66. package/dist/kernel/KernelLogging.d.ts +63 -0
  67. package/dist/kernel/KernelLogging.js +128 -0
  68. package/dist/kernel/KernelLogging.js.map +1 -0
  69. package/dist/kernel/KernelNativeLoader.d.ts +77 -0
  70. package/dist/kernel/KernelNativeLoader.js +178 -0
  71. package/dist/kernel/KernelNativeLoader.js.map +1 -0
  72. package/dist/kernel/KernelOperationBackend.d.ts +154 -0
  73. package/dist/kernel/KernelOperationBackend.js +640 -0
  74. package/dist/kernel/KernelOperationBackend.js.map +1 -0
  75. package/dist/kernel/KernelOperationLifecycle.d.ts +130 -0
  76. package/dist/kernel/KernelOperationLifecycle.js +245 -0
  77. package/dist/kernel/KernelOperationLifecycle.js.map +1 -0
  78. package/dist/kernel/KernelPositionalParams.d.ts +16 -0
  79. package/dist/kernel/KernelPositionalParams.js +120 -0
  80. package/dist/kernel/KernelPositionalParams.js.map +1 -0
  81. package/dist/kernel/KernelResultsProvider.d.ts +44 -0
  82. package/dist/kernel/KernelResultsProvider.js +102 -0
  83. package/dist/kernel/KernelResultsProvider.js.map +1 -0
  84. package/dist/kernel/KernelServerInfo.d.ts +44 -0
  85. package/dist/kernel/KernelServerInfo.js +73 -0
  86. package/dist/kernel/KernelServerInfo.js.map +1 -0
  87. package/dist/kernel/KernelSessionBackend.d.ts +100 -0
  88. package/dist/kernel/KernelSessionBackend.js +384 -0
  89. package/dist/kernel/KernelSessionBackend.js.map +1 -0
  90. package/dist/result/ArrowResultConverter.d.ts +31 -2
  91. package/dist/result/ArrowResultConverter.js +226 -14
  92. package/dist/result/ArrowResultConverter.js.map +1 -1
  93. package/dist/result/CloudFetchResultHandler.js +36 -8
  94. package/dist/result/CloudFetchResultHandler.js.map +1 -1
  95. package/dist/telemetry/DatabricksTelemetryExporter.js +34 -1
  96. package/dist/telemetry/DatabricksTelemetryExporter.js.map +1 -1
  97. package/dist/telemetry/telemetryTypeMappers.d.ts +1 -1
  98. package/dist/telemetry/telemetryTypeMappers.js +1 -1
  99. package/dist/telemetry/telemetryTypeMappers.js.map +1 -1
  100. package/dist/telemetry/types.d.ts +15 -0
  101. package/dist/thrift-backend/ThriftBackend.d.ts +17 -0
  102. package/dist/thrift-backend/ThriftBackend.js +80 -0
  103. package/dist/thrift-backend/ThriftBackend.js.map +1 -0
  104. package/dist/thrift-backend/ThriftOperationBackend.d.ts +70 -0
  105. package/dist/thrift-backend/ThriftOperationBackend.js +330 -0
  106. package/dist/thrift-backend/ThriftOperationBackend.js.map +1 -0
  107. package/dist/thrift-backend/ThriftSessionBackend.d.ts +36 -0
  108. package/dist/thrift-backend/ThriftSessionBackend.js +266 -0
  109. package/dist/thrift-backend/ThriftSessionBackend.js.map +1 -0
  110. package/dist/thrift-backend/wireSynthesis.d.ts +30 -0
  111. package/dist/thrift-backend/wireSynthesis.js +128 -0
  112. package/dist/thrift-backend/wireSynthesis.js.map +1 -0
  113. package/dist/version.d.ts +1 -1
  114. package/dist/version.js +1 -1
  115. package/native/kernel/README.md +97 -0
  116. package/native/kernel/index.d.ts +1069 -0
  117. package/native/kernel/index.js +325 -0
  118. package/package.json +13 -2
@@ -0,0 +1,384 @@
1
+ "use strict";
2
+ // Copyright (c) 2026 Databricks, Inc.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ const uuid_1 = require("uuid");
20
+ const Status_1 = __importDefault(require("../dto/Status"));
21
+ const InfoValue_1 = __importDefault(require("../dto/InfoValue"));
22
+ const HiveDriverError_1 = __importDefault(require("../errors/HiveDriverError"));
23
+ const ParameterError_1 = __importDefault(require("../errors/ParameterError"));
24
+ const IDBSQLLogger_1 = require("../contracts/IDBSQLLogger");
25
+ const KernelErrorMapping_1 = require("./KernelErrorMapping");
26
+ const KernelOperationBackend_1 = __importDefault(require("./KernelOperationBackend"));
27
+ const KernelPositionalParams_1 = require("./KernelPositionalParams");
28
+ const KernelServerInfo_1 = require("./KernelServerInfo");
29
+ const utils_1 = require("../utils");
30
+ /**
31
+ * kernel-backed implementation of `ISessionBackend`.
32
+ *
33
+ * **Scope:** `executeStatement` (sync + async), `close`, `getInfo`, and the
34
+ * full metadata surface (`getCatalogs`, `getSchemas`, `getTables`,
35
+ * `getColumns`, `getFunctions`, `getTableTypes`, `getTypeInfo`,
36
+ * `getPrimaryKeys`, `getCrossReference`) — each forwards to the kernel's napi
37
+ * metadata calls (see `runMetadata`). The Thrift backend remains the default;
38
+ * callers opt into the kernel path via `ConnectionOptions.useKernel`.
39
+ *
40
+ * **Session config flow:** catalog / schema / sessionConf are applied
41
+ * once at session creation (kernel `Session::builder().defaults()` +
42
+ * `.session_conf()` → SEA `CreateSession.catalog` / `.schema` /
43
+ * `.session_confs`) and remain in effect for every statement run on
44
+ * the resulting napi `Connection`. No per-statement forwarding is
45
+ * needed — that pattern was removed when the napi binding moved these
46
+ * onto `openSession` to match pyo3.
47
+ */
48
+ /**
49
+ * Narrow the directResults union (`executeStatementDirect`'s
50
+ * `Statement | AsyncStatement`) to the Running `AsyncStatement` arm. Only that
51
+ * arm exposes `awaitResult`; the terminal `Statement` (Completed arm) does not.
52
+ * Mirrors the kernel `DirectStatement::{Completed, Running}` discriminant, which
53
+ * the opaque napi classes can't carry on the wire — the `awaitResult` probe is
54
+ * the load-bearing feature-detect (see databricks-sql-kernel#140).
55
+ */
56
+ function isKernelAsyncStatement(x) {
57
+ return typeof x.awaitResult === 'function';
58
+ }
59
+ class KernelSessionBackend {
60
+ constructor({ connection, context, id }) {
61
+ this.closed = false;
62
+ this.connection = connection;
63
+ this.context = context;
64
+ this._id = id !== null && id !== void 0 ? id : (0, uuid_1.v4)();
65
+ }
66
+ get id() {
67
+ return this._id;
68
+ }
69
+ /**
70
+ * `getInfo` (JDBC `DatabaseMetaData` / ODBC `SQLGetInfo`) has no kernel
71
+ * endpoint, so — exactly as JDBC does for `DatabaseMetaData` — we synthesize
72
+ * the answer client-side for the three `TGetInfoType`s the Databricks server
73
+ * answers (server name / DBMS name / DBMS version) and reject the rest.
74
+ *
75
+ * This is NOT a kernel-only contract narrowing: probing the live warehouse over
76
+ * the Thrift path confirms the server itself returns an error for every
77
+ * other `TGetInfoType` (CLI_MAX_DRIVER_CONNECTIONS, CLI_DATA_SOURCE_NAME, …),
78
+ * and the three values it does answer are byte-identical to the constants we
79
+ * synthesize (`"Spark SQL"` / `"Spark SQL"` / `"3.1.1"`, re-verified live).
80
+ * So rejecting an unsupported type matches Thrift's effective behaviour — we
81
+ * just surface a clearer, typed error than the server's opaque one. See
82
+ * {@link kernelServerInfoValue}.
83
+ */
84
+ async getInfo(infoType) {
85
+ this.failIfClosed();
86
+ const value = (0, KernelServerInfo_1.kernelServerInfoValue)(infoType);
87
+ if (value === undefined) {
88
+ throw new HiveDriverError_1.default(`kernel getInfo: unsupported TGetInfoType ${infoType}. Only the info types the Databricks ` +
89
+ `server itself answers are supported: CLI_SERVER_NAME (13), CLI_DBMS_NAME (17), ` +
90
+ `CLI_DBMS_VER (18). The server rejects every other type on the Thrift path too, so this ` +
91
+ `is not a kernel-specific restriction.`);
92
+ }
93
+ return new InfoValue_1.default(value);
94
+ }
95
+ /**
96
+ * Execute a SQL statement through the napi binding.
97
+ *
98
+ * Catalog / schema / sessionConf are session-level (applied at open).
99
+ * Per-statement options forwarded to the kernel `ExecuteOptions`:
100
+ * - `ordinalParameters` / `namedParameters` → bound params (mutually
101
+ * exclusive — the kernel binds one placeholder style per statement);
102
+ * - `queryTimeout` → NO-OP on kernel (SQL Warehouses use `STATEMENT_TIMEOUT`);
103
+ * never forwarded to the kernel and never applied as a client-side
104
+ * deadline — see the note in `executeStatement`;
105
+ * - `rowLimit` → `rowLimit` (kernel-only server-side row cap);
106
+ * - `queryTags` → serialised into the conf overlay's reserved
107
+ * `query_tags` key (the same wire shape Thrift's `serializeQueryTags`
108
+ * produces), merged with any explicit `statementConf`.
109
+ *
110
+ * Still rejected (genuinely unsupported on kernel, rather than silently
111
+ * dropped): `useCloudFetch` (governed by the kernel `ResultConfig`, not a
112
+ * per-statement knob), `useLZ4Compression` (kernel owns result compression),
113
+ * and `stagingAllowedLocalPath` (volume operations). `maxRows` is applied by
114
+ * the facade at fetch time, so it is intentionally not handled here.
115
+ */
116
+ async executeStatement(statement, options) {
117
+ var _a;
118
+ this.failIfClosed();
119
+ // Per-statement options the kernel backend doesn't honour are treated as
120
+ // NO-OPs (logged at warn), not errors — so call sites written for the Thrift
121
+ // backend are drop-in on the kernel path. These are perf/format hints the
122
+ // kernel governs internally (useCloudFetch / useLZ4Compression) or a feature
123
+ // it doesn't expose yet (staging); ignoring them cannot change query results.
124
+ // NB: parameter binding (compound/BINARY) is deliberately NOT no-op'd — a
125
+ // dropped param would silently change results, so it still throws.
126
+ if (options.useCloudFetch !== undefined) {
127
+ this.context
128
+ .getLogger()
129
+ .log(IDBSQLLogger_1.LogLevel.warn, 'kernel executeStatement: ignoring per-statement `useCloudFetch` — result fetching is governed by the kernel result configuration (no-op on kernel).');
130
+ }
131
+ if (options.useLZ4Compression !== undefined) {
132
+ this.context
133
+ .getLogger()
134
+ .log(IDBSQLLogger_1.LogLevel.warn, 'kernel executeStatement: ignoring per-statement `useLZ4Compression` — result compression is governed by the kernel (no-op on kernel).');
135
+ }
136
+ if (options.stagingAllowedLocalPath !== undefined) {
137
+ this.context
138
+ .getLogger()
139
+ .log(IDBSQLLogger_1.LogLevel.warn, 'kernel executeStatement: ignoring `stagingAllowedLocalPath` — volume/staging operations are not yet supported on the kernel backend (no-op).');
140
+ }
141
+ // `runAsync` selects the kernel execution path. NOTE: this is a kernel-
142
+ // specific use of the option — the Thrift backend hardcodes `runAsync: true`
143
+ // on the wire and never reads `options.runAsync`, so the field is a no-op
144
+ // there. The only observable difference between the two kernel paths is WHEN
145
+ // `executeStatement` resolves; the public API, result shape, schema, and
146
+ // error classes are identical on both (and to Thrift). See the option's
147
+ // JSDoc in `IDBSQLSession` for the cross-backend contract.
148
+ //
149
+ // - DEFAULT (`runAsync` false/undefined) — SYNC. Route through
150
+ // `executeStatementDirect` (the directResults model): the kernel sends
151
+ // ExecuteStatement with the server's inline wait and returns WITHOUT
152
+ // polling past it — a terminal `Statement` (result inline) for a fast
153
+ // query, or a still-running `AsyncStatement` (poll/cancel handle) for a
154
+ // slow one. The handle is server-owned, so a long query stays cancellable
155
+ // via `op.cancel()` and `close()` is a clean release (no client-side
156
+ // drive-to-terminal). `queryTimeout` is a no-op here (see the note
157
+ // below) — it is NOT mapped to the server `wait_timeout`.
158
+ //
159
+ // - `runAsync: true` — ASYNC. Submit (`wait_timeout=0s`): the server
160
+ // returns a pending `AsyncStatement` immediately while the query runs;
161
+ // the backend polls `status()` to terminal in `waitUntilReady()` and
162
+ // materialises results via `awaitResult()`. `queryTimeout` is a no-op
163
+ // here too.
164
+ const runAsync = (_a = options.runAsync) !== null && _a !== void 0 ? _a : false;
165
+ // `queryTimeout` is a NO-OP on the kernel (kernel) backend. It is the JDBC
166
+ // `setQueryTimeout` knob which — per the option's JSDoc — is effective only
167
+ // on Compute clusters; SQL Warehouses (what kernel targets) use the
168
+ // `STATEMENT_TIMEOUT` SQL/session conf instead. We deliberately do NOT map it
169
+ // to the kernel `wait_timeout` field: `wait_timeout` is the server's inline-hold
170
+ // window (the time the POST blocks for results, capped 5–50s), NOT a
171
+ // statement-execution timeout — mapping it there silently caps the timeout at
172
+ // 50s, rejects <5s with HTTP 400, and conflates the inline wait with
173
+ // execution. So `queryTimeout` is neither forwarded to the kernel nor used as
174
+ // a client-side deadline.
175
+ if (!runAsync) {
176
+ // DEFAULT — directResults (the Thrift/JDBC model). The kernel's
177
+ // `executeStatementDirect` runs ExecuteStatement with a bounded server
178
+ // inline wait and returns WITHOUT polling past it:
179
+ // - a terminal `Statement` (result inline) for a fast query, or
180
+ // - an `AsyncStatement` (a poll/cancel handle) for a slow one.
181
+ // Either way the handle is tied to a server-owned statement, so a long
182
+ // query stays cancellable via `op.cancel()` and `close()` is a clean
183
+ // release (no client-side drive-to-terminal). Fire-and-forget DDL/DML
184
+ // commits because the server runs it inline during the POST.
185
+ const execOptions = this.buildExecuteOptions(options);
186
+ let direct;
187
+ try {
188
+ direct =
189
+ execOptions === undefined
190
+ ? await this.connection.executeStatementDirect(statement)
191
+ : await this.connection.executeStatementDirect(statement, execOptions);
192
+ }
193
+ catch (err) {
194
+ throw this.logAndMapError('executeStatement', err);
195
+ }
196
+ // The kernel contract (`Promise<Statement | AsyncStatement>`) never yields
197
+ // null/undefined; reject a non-handle up front so a contract violation
198
+ // surfaces as a mapped driver error here rather than an opaque `TypeError`
199
+ // deferred to first fetch/close.
200
+ if (direct === null || direct === undefined) {
201
+ throw this.logAndMapError('executeStatement', new HiveDriverError_1.default('kernel executeStatementDirect returned no statement handle'));
202
+ }
203
+ // Feature-detect the arm via a type guard: only the Running `AsyncStatement`
204
+ // exposes `awaitResult`; the terminal `Statement` (Completed arm) does not.
205
+ if (isKernelAsyncStatement(direct)) {
206
+ return new KernelOperationBackend_1.default({ asyncStatement: direct, context: this.context });
207
+ }
208
+ return new KernelOperationBackend_1.default({ statement: direct, context: this.context });
209
+ }
210
+ // Async path: submit (`wait_timeout=0s`) returns a pending handle the
211
+ // backend polls. (`queryTimeout` is a no-op on kernel — see the note above.)
212
+ const execOptions = this.buildExecuteOptions(options);
213
+ let asyncStatement;
214
+ try {
215
+ asyncStatement =
216
+ execOptions === undefined
217
+ ? await this.connection.submitStatement(statement)
218
+ : await this.connection.submitStatement(statement, execOptions);
219
+ }
220
+ catch (err) {
221
+ throw this.logAndMapError('executeStatement', err);
222
+ }
223
+ // `queryTimeout` is a no-op on kernel (see the note at the top of this method);
224
+ // not forwarded to the kernel and not applied as a client-side deadline.
225
+ return new KernelOperationBackend_1.default({
226
+ asyncStatement: asyncStatement,
227
+ context: this.context,
228
+ });
229
+ }
230
+ /**
231
+ * Translate the public `ExecuteStatementOptions` into the kernel napi
232
+ * `ExecuteOptions`, returning `undefined` when nothing is set so the
233
+ * no-options call shape (`executeStatement(sql)`) is preserved.
234
+ */
235
+ buildExecuteOptions(options) {
236
+ var _a;
237
+ // Positional (`?`) and named (`:name`) parameters are mutually exclusive —
238
+ // the kernel binds one placeholder style per statement. Use the SAME error
239
+ // type and message as the Thrift backend (`ThriftSessionBackend`) so a
240
+ // caller catching `ParameterError` behaves identically across backends.
241
+ const positionalParams = (0, KernelPositionalParams_1.buildKernelPositionalParams)(options.ordinalParameters);
242
+ const namedParams = (0, KernelPositionalParams_1.buildKernelNamedParams)(options.namedParameters);
243
+ if (positionalParams !== undefined && namedParams !== undefined) {
244
+ throw new ParameterError_1.default('Driver does not support both ordinal and named parameters.');
245
+ }
246
+ const execOptions = {};
247
+ if (positionalParams !== undefined) {
248
+ execOptions.positionalParams = positionalParams;
249
+ }
250
+ if (namedParams !== undefined) {
251
+ execOptions.namedParams = namedParams;
252
+ }
253
+ // NB: `queryTimeout` is intentionally NOT forwarded — it is a no-op on kernel
254
+ // (SQL Warehouses use `STATEMENT_TIMEOUT`; mapping it to `wait_timeout` would
255
+ // abuse the inline-hold window). See the note in `executeStatement`.
256
+ if (options.rowLimit !== undefined) {
257
+ execOptions.rowLimit = Number(options.rowLimit);
258
+ }
259
+ // Per-statement conf overlay plus query tags. Tags are serialised JS-side
260
+ // into the reserved `query_tags` key (the same wire shape the Thrift
261
+ // backend produces via `serializeQueryTags` → `confOverlay`), rather than
262
+ // via the napi `queryTags` field: napi's `HashMap<String,String>` can't
263
+ // represent a null-valued tag, and the kernel rejects setting both the
264
+ // `queryTags` field and a `query_tags` conf key.
265
+ const serializedQueryTags = (0, utils_1.serializeQueryTags)(options.queryTags);
266
+ if (options.statementConf !== undefined || serializedQueryTags !== undefined) {
267
+ const statementConf = { ...((_a = options.statementConf) !== null && _a !== void 0 ? _a : {}) };
268
+ if (serializedQueryTags !== undefined) {
269
+ statementConf.query_tags = serializedQueryTags;
270
+ }
271
+ if (Object.keys(statementConf).length > 0) {
272
+ execOptions.statementConf = statementConf;
273
+ }
274
+ }
275
+ return Object.keys(execOptions).length > 0 ? execOptions : undefined;
276
+ }
277
+ /** Wrap a napi metadata `Statement` (already terminal) as an operation backend. */
278
+ wrapStatement(nativeStatement) {
279
+ return new KernelOperationBackend_1.default({
280
+ statement: nativeStatement,
281
+ context: this.context,
282
+ id: nativeStatement.statementId,
283
+ });
284
+ }
285
+ /**
286
+ * Metadata calls forward to the kernel's metadata surface (`listCatalogs`,
287
+ * `listTables`, …), each of which returns a napi `Statement` whose result
288
+ * carries the JDBC-shaped columns. We wrap that handle exactly like an
289
+ * executed statement. The kernel owns the SQL synthesis, the column
290
+ * projection, and (for `listTables`) the client-side `TABLE_TYPE` filter —
291
+ * the driver only maps the request fields to positional arguments.
292
+ *
293
+ * The `runAsync` / `maxRows` request fields are not threaded here: `runAsync`
294
+ * is deprecated, and `maxRows` is applied by the facade at fetch time (same
295
+ * as the Thrift path), so the napi call takes only the filter arguments.
296
+ */
297
+ async getTypeInfo(_request) {
298
+ this.failIfClosed();
299
+ return this.runMetadata(() => this.connection.listTypeInfo());
300
+ }
301
+ async getCatalogs(_request) {
302
+ this.failIfClosed();
303
+ return this.runMetadata(() => this.connection.listCatalogs());
304
+ }
305
+ async getSchemas(request) {
306
+ this.failIfClosed();
307
+ return this.runMetadata(() => this.connection.listSchemas(request.catalogName, request.schemaName));
308
+ }
309
+ async getTables(request) {
310
+ this.failIfClosed();
311
+ return this.runMetadata(() => this.connection.listTables(request.catalogName, request.schemaName, request.tableName, request.tableTypes));
312
+ }
313
+ async getTableTypes(_request) {
314
+ this.failIfClosed();
315
+ return this.runMetadata(() => this.connection.listTableTypes());
316
+ }
317
+ async getColumns(request) {
318
+ this.failIfClosed();
319
+ return this.runMetadata(() => this.connection.listColumns(request.catalogName, request.schemaName, request.tableName, request.columnName));
320
+ }
321
+ async getFunctions(request) {
322
+ this.failIfClosed();
323
+ return this.runMetadata(() => this.connection.listFunctions(request.catalogName, request.schemaName, request.functionName));
324
+ }
325
+ async getPrimaryKeys(request) {
326
+ this.failIfClosed();
327
+ // The kernel requires a catalog for primary-key lookup (`Identifier::new`
328
+ // rejects an empty string). The Thrift backend can forward an undefined
329
+ // catalog and let the server resolve a default; the kernel path cannot,
330
+ // so reject up front with a clear, actionable message rather than passing
331
+ // `''` and surfacing the kernel's opaque "identifier must not be empty".
332
+ if (request.catalogName === undefined || request.catalogName === '') {
333
+ throw new HiveDriverError_1.default('kernel getPrimaryKeys requires a catalog — pass `catalogName` explicitly. (The Thrift backend ' +
334
+ 'can omit it and let the server resolve a default; the kernel kernel path requires it.)');
335
+ }
336
+ return this.runMetadata(() => this.connection.getPrimaryKeys(request.catalogName, request.schemaName, request.tableName));
337
+ }
338
+ async getCrossReference(request) {
339
+ this.failIfClosed();
340
+ return this.runMetadata(() => this.connection.getCrossReference(request.parentCatalogName, request.parentSchemaName, request.parentTableName, request.foreignCatalogName, request.foreignSchemaName, request.foreignTableName));
341
+ }
342
+ /** Run a napi metadata call, mapping kernel errors and wrapping the result handle. */
343
+ async runMetadata(call) {
344
+ let nativeStatement;
345
+ try {
346
+ nativeStatement = await call();
347
+ }
348
+ catch (err) {
349
+ throw this.logAndMapError('metadata', err);
350
+ }
351
+ return this.wrapStatement(nativeStatement);
352
+ }
353
+ /**
354
+ * Map a napi/kernel error to a typed driver error and emit a debug breadcrumb
355
+ * first, matching the rest of the kernel backend's logging convention
356
+ * (`KernelOperationLifecycle` / `KernelOperationBackend`). Metadata and bound-param
357
+ * execute failures otherwise threw with no on-call signal.
358
+ */
359
+ logAndMapError(op, err) {
360
+ const mapped = (0, KernelErrorMapping_1.decodeNapiKernelError)(err);
361
+ this.context.getLogger().log(IDBSQLLogger_1.LogLevel.debug, `kernel ${op} failed for session ${this._id}: ${mapped.message}`);
362
+ return mapped;
363
+ }
364
+ async close() {
365
+ if (this.closed) {
366
+ return Status_1.default.success();
367
+ }
368
+ try {
369
+ await this.connection.close();
370
+ }
371
+ catch (err) {
372
+ throw (0, KernelErrorMapping_1.decodeNapiKernelError)(err);
373
+ }
374
+ this.closed = true;
375
+ return Status_1.default.success();
376
+ }
377
+ failIfClosed() {
378
+ if (this.closed) {
379
+ throw new HiveDriverError_1.default('KernelSessionBackend: session is closed');
380
+ }
381
+ }
382
+ }
383
+ exports.default = KernelSessionBackend;
384
+ //# sourceMappingURL=KernelSessionBackend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KernelSessionBackend.js","sourceRoot":"","sources":["../../lib/kernel/KernelSessionBackend.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;AAEjC,+BAAoC;AAgBpC,2DAAmC;AACnC,iEAAyC;AACzC,gFAAwD;AACxD,8EAAsD;AACtD,4DAAqD;AAOrD,6DAA6D;AAC7D,sFAA8D;AAC9D,qEAA+F;AAC/F,yDAA2D;AAC3D,oCAA8C;AAU9C;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;GAOG;AACH,SAAS,sBAAsB,CAAC,CAA+C;IAC7E,OAAO,OAAQ,CAAgC,CAAC,WAAW,KAAK,UAAU,CAAC;AAC7E,CAAC;AAED,MAAqB,oBAAoB;IASvC,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,EAA+B;QAF5D,WAAM,GAAG,KAAK,CAAC;QAGrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,EAAE,aAAF,EAAE,cAAF,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AY;QAClB,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,MAAM,IAAI,yBAAe,CAAC,yCAAyC,CAAC,CAAC;SACtE;IACH,CAAC;CACF;AA7XD,uCA6XC"}
@@ -1,15 +1,44 @@
1
- import { TGetResultSetMetadataResp } from '../../thrift/TCLIService_types';
1
+ import { TTableSchema } from '../../thrift/TCLIService_types';
2
2
  import IClientContext from '../contracts/IClientContext';
3
3
  import IResultsProvider, { ResultsProviderFetchNextOptions } from './IResultsProvider';
4
4
  import { ArrowBatch } from './utils';
5
+ /**
6
+ * Metadata key carrying the original Arrow `Duration` time unit on fields
7
+ * rewritten to `Int64` by the kernel IPC pre-processor
8
+ * (`lib/kernel/KernelArrowIpcDurationFix.ts`). Re-declared here (rather than
9
+ * imported) to keep this generic `lib/result` converter free of a
10
+ * compile-time dependency on `lib/kernel`.
11
+ *
12
+ * **kernel-gated by construction — NOT shared with Thrift.** This key (and the
13
+ * `DataType.isInterval` / duration branches below) only ever execute on the
14
+ * kernel path. The Thrift backend sets `intervalTypesAsArrow: false` and maps
15
+ * both INTERVAL `TTypeId`s to `ArrowString` (`lib/result/utils.ts`), so the
16
+ * server pre-formats intervals to strings and this logic is never reached.
17
+ * `export`ed so `KernelIntervalParity.test` can pin it equal to the kernel-side
18
+ * declaration and catch a rename/typo that would silently no-op the consumer.
19
+ */
20
+ export declare const DURATION_UNIT_METADATA_KEY = "databricks.arrow.duration_unit";
21
+ /**
22
+ * Render an Arrow `Decimal` value — supplied as its unscaled integer (from
23
+ * `bigNumToBigInt`) plus the column `scale` — as an exact decimal string,
24
+ * e.g. unscaled `1234567890` / scale `5` → `"12345.67890"`. Used by the
25
+ * precision-preserving path so high-precision DECIMALs survive the round-trip
26
+ * instead of being flattened to an IEEE-754 double.
27
+ */
28
+ export declare function bigNumDecimalToString(unscaled: bigint, scale: number): string;
5
29
  export default class ArrowResultConverter implements IResultsProvider<Array<any>> {
6
30
  private readonly context;
7
31
  private readonly source;
8
32
  private readonly schema;
33
+ private readonly preserveBigNumericPrecision;
9
34
  private recordBatchReader?;
10
35
  private remainingRows;
11
36
  private prefetchedRecordBatch?;
12
- constructor(context: IClientContext, source: IResultsProvider<ArrowBatch>, { schema }: TGetResultSetMetadataResp);
37
+ constructor(context: IClientContext, source: IResultsProvider<ArrowBatch>, { schema }: {
38
+ schema?: TTableSchema;
39
+ }, { preserveBigNumericPrecision }?: {
40
+ preserveBigNumericPrecision?: boolean;
41
+ });
13
42
  hasMore(): Promise<boolean>;
14
43
  fetchNext(options: ResultsProviderFetchNextOptions): Promise<any[]>;
15
44
  private prefetch;