@databricks/sql 1.15.0 → 1.16.0-rc.1

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 (119) 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/dist/version.js.map +1 -1
  116. package/native/kernel/README.md +97 -0
  117. package/native/kernel/index.d.ts +1069 -0
  118. package/native/kernel/index.js +325 -0
  119. package/package.json +13 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KernelOperationBackend.js","sourceRoot":"","sources":["../../lib/kernel/KernelOperationBackend.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;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,+BAAoC;AAGpC,kEAA+E;AAC/E,gEAA2E;AAE3E,4DAAqD;AAErD,gFAAwD;AACxD,qFAA6F;AAC7F,0FAAkE;AAClE,0EAAkD;AAClD,oFAA4D;AAC5D,qDAA6F;AAC7F,6DAA6D;AAO7D,yEAQoC;AA+CpC,uFAAuF;AACvF,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,SAAS,KAAK,CAAC,EAAU;I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1B;QACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC3C,8EAA8E;QAC9E,0DAA0D;QAC1D,IAAI,CAAC,eAAe,GAAG,IAAI,+BAAqB,CAAC,MAAoC,CAAC,CAAC;QACvF,0DAA0D;QAC1D,4EAA4E;QAC5E,uEAAuE;QACvE,yEAAyE;QACzE,MAAM,SAAS,GAAG,IAAI,8BAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,EAAE;YACvF,2BAA2B,EAAE,MAAA,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,2BAA2B,mCAAI,KAAK;SAC3F,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,GAAG,IAAI,sBAAY,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;CACF;AA/mBD,yCA+mBC"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * kernel operation lifecycle helpers (M0).
3
+ *
4
+ * The three methods exposed here (`cancel`, `close`, `finished`) are
5
+ * standalone functions that the `KernelOperationBackend` implementation
6
+ * delegates to. Keeping them in this dedicated file lets the parallel
7
+ * impl-results work (which owns the fetch-* methods on
8
+ * `KernelOperationBackend`) land independently — at merge time it can
9
+ * either import these helpers from here or inline them, with no
10
+ * conflicts on the call sites.
11
+ *
12
+ * Mapping to the existing `DBSQLOperation` semantics:
13
+ * - `cancel()` → ` driver.cancelOperation(...)` on Thrift today
14
+ * (`lib/DBSQLOperation.ts:241-259`). For kernel this is a one-shot
15
+ * forward to the napi `Statement.cancel()` which in turn calls
16
+ * `ExecutedStatementHandle::cancel(&self).await` in the kernel.
17
+ * - `close()` → `driver.closeOperation(...)` on Thrift today
18
+ * (`lib/DBSQLOperation.ts:265-284`). For kernel this is the napi
19
+ * `Statement.close()` which awaits the server-side delete.
20
+ * - `finished({progress, callback})` → the 100ms polling loop in
21
+ * `DBSQLOperation.waitUntilReady` today (`lib/DBSQLOperation.ts:337-391`).
22
+ * For M0 the kernel's `Statement::execute().await` already blocks
23
+ * until the statement is in a terminal state, so by the time the JS
24
+ * side has an `ExecutedStatement` (and therefore a binding-level
25
+ * `Statement`) the underlying operation is already finished. The
26
+ * M0 implementation here therefore resolves immediately, optionally
27
+ * firing the progress callback once with a synthesized "finished"
28
+ * response so callers that wire a progress UI still see a single
29
+ * completion tick.
30
+ */
31
+ import Status from '../dto/Status';
32
+ import { OperationStatus } from '../contracts/OperationStatus';
33
+ import IClientContext from '../contracts/IClientContext';
34
+ /**
35
+ * Minimal shape of the napi `Statement` that the lifecycle helpers
36
+ * depend on. Declared structurally so unit tests can hand in a mock
37
+ * without pulling the real native binding into the test process.
38
+ *
39
+ * The real binding's `Statement` (see `native/kernel/index.d.ts`) has
40
+ * additional methods (`fetchNextBatch`, `schema`) which the lifecycle
41
+ * helpers deliberately don't touch — those belong to the results
42
+ * feature's surface.
43
+ */
44
+ export interface KernelStatementHandle {
45
+ cancel(): Promise<void>;
46
+ close(): Promise<void>;
47
+ }
48
+ /**
49
+ * Internal lifecycle state shared between the operation backend and
50
+ * these helpers. `KernelOperationBackend` keeps an instance of this and
51
+ * passes it to each helper call. Centralising the flags here means
52
+ * the helpers stay pure (no `this`) and the backend stays
53
+ * straightforward.
54
+ */
55
+ export interface KernelOperationLifecycleState {
56
+ /** True once `cancel()` has succeeded — subsequent fetch* must throw. */
57
+ isCancelled: boolean;
58
+ /** True once `close()` has been called (idempotent). */
59
+ isClosed: boolean;
60
+ }
61
+ /**
62
+ * Factory for a fresh lifecycle-state record. Helps keep test setup
63
+ * tidy.
64
+ */
65
+ export declare function createLifecycleState(): KernelOperationLifecycleState;
66
+ /**
67
+ * Cancel an in-flight kernel operation.
68
+ *
69
+ * Mirrors `DBSQLOperation.cancel` semantics
70
+ * (`lib/DBSQLOperation.ts:241-259`):
71
+ * - idempotent: returns success if already cancelled or closed
72
+ * (no-ops are not bubbled to the kernel because the binding's
73
+ * `Statement::cancel` already treats already-finished statements as
74
+ * a no-op, but we still want to avoid a network round-trip here),
75
+ * - sets the cancelled flag _before_ awaiting the napi call so that a
76
+ * concurrent `fetchChunk()` observing the flag short-circuits as
77
+ * soon as the await yields (matches the Thrift flag-set ordering
78
+ * at `lib/DBSQLOperation.ts:254`),
79
+ * - returns a `Status.success()` on success (no rich Thrift status
80
+ * payload is available from the kernel side).
81
+ */
82
+ export declare function kernelCancel(state: KernelOperationLifecycleState, statement: KernelStatementHandle, context: IClientContext, operationId: string): Promise<Status>;
83
+ /**
84
+ * Close a kernel operation.
85
+ *
86
+ * Mirrors `DBSQLOperation.close` semantics
87
+ * (`lib/DBSQLOperation.ts:265-284`) without the Thrift-only
88
+ * direct-results-prefetch optimisation:
89
+ * - idempotent: a second call is a no-op,
90
+ * - awaits the binding's `Statement::close` (which goes through to
91
+ * the kernel's `delete_statement` RPC),
92
+ * - sets the closed flag _before_ awaiting so a concurrent fetch
93
+ * sees the closed state as soon as the await yields.
94
+ */
95
+ export declare function kernelClose(state: KernelOperationLifecycleState, statement: KernelStatementHandle, context: IClientContext, operationId: string): Promise<Status>;
96
+ /**
97
+ * `IOperation.finished({progress, callback})` M0 implementation.
98
+ *
99
+ * The Thrift implementation is a 100ms polling loop over
100
+ * `getOperationStatus` (`lib/DBSQLOperation.ts:337-391`). For kernel M0,
101
+ * the kernel's `Statement::execute().await` already blocks until the
102
+ * statement reaches a terminal state — by the time the JS layer has
103
+ * a `Statement` handle, the operation has already finished.
104
+ *
105
+ * Therefore the M0 implementation resolves immediately. If the
106
+ * caller supplied a progress callback we still invoke it once (a
107
+ * single completion tick) so progress-UI consumers see the same
108
+ * "operation is now finished" signal they'd get from the polling
109
+ * Thrift path — just without the intermediate `RUNNING_STATE`
110
+ * notifications.
111
+ *
112
+ * If the operation is already cancelled or closed, this is a no-op
113
+ * (matches the Thrift `failIfClosed` / cancelled-state semantics
114
+ * without throwing; throwing is the responsibility of subsequent
115
+ * fetch calls).
116
+ */
117
+ export declare function kernelFinished(state: KernelOperationLifecycleState, options?: {
118
+ progress?: boolean;
119
+ callback?: (status: OperationStatus) => unknown;
120
+ }, richFields?: () => Promise<Partial<OperationStatus>>): Promise<void>;
121
+ /**
122
+ * Pre-flight check used by fetch* methods on `KernelOperationBackend`.
123
+ * If the operation has been cancelled or closed, throw the same
124
+ * `OperationStateError` classes the facade uses. Keeping these typed lets
125
+ * callers branch on `OperationStateErrorCode` consistently for Thrift and kernel.
126
+ *
127
+ * Exported so impl-results can call it at the top of every fetch
128
+ * call without duplicating the if/throw logic.
129
+ */
130
+ export declare function failIfNotActive(state: KernelOperationLifecycleState): void;
@@ -0,0 +1,245 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
27
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
28
+ }) : function(o, v) {
29
+ o["default"] = v;
30
+ });
31
+ var __importStar = (this && this.__importStar) || function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.failIfNotActive = exports.kernelFinished = exports.kernelClose = exports.kernelCancel = exports.createLifecycleState = void 0;
43
+ /**
44
+ * kernel operation lifecycle helpers (M0).
45
+ *
46
+ * The three methods exposed here (`cancel`, `close`, `finished`) are
47
+ * standalone functions that the `KernelOperationBackend` implementation
48
+ * delegates to. Keeping them in this dedicated file lets the parallel
49
+ * impl-results work (which owns the fetch-* methods on
50
+ * `KernelOperationBackend`) land independently — at merge time it can
51
+ * either import these helpers from here or inline them, with no
52
+ * conflicts on the call sites.
53
+ *
54
+ * Mapping to the existing `DBSQLOperation` semantics:
55
+ * - `cancel()` → ` driver.cancelOperation(...)` on Thrift today
56
+ * (`lib/DBSQLOperation.ts:241-259`). For kernel this is a one-shot
57
+ * forward to the napi `Statement.cancel()` which in turn calls
58
+ * `ExecutedStatementHandle::cancel(&self).await` in the kernel.
59
+ * - `close()` → `driver.closeOperation(...)` on Thrift today
60
+ * (`lib/DBSQLOperation.ts:265-284`). For kernel this is the napi
61
+ * `Statement.close()` which awaits the server-side delete.
62
+ * - `finished({progress, callback})` → the 100ms polling loop in
63
+ * `DBSQLOperation.waitUntilReady` today (`lib/DBSQLOperation.ts:337-391`).
64
+ * For M0 the kernel's `Statement::execute().await` already blocks
65
+ * until the statement is in a terminal state, so by the time the JS
66
+ * side has an `ExecutedStatement` (and therefore a binding-level
67
+ * `Statement`) the underlying operation is already finished. The
68
+ * M0 implementation here therefore resolves immediately, optionally
69
+ * firing the progress callback once with a synthesized "finished"
70
+ * response so callers that wire a progress UI still see a single
71
+ * completion tick.
72
+ */
73
+ const Status_1 = __importDefault(require("../dto/Status"));
74
+ const OperationStatus_1 = require("../contracts/OperationStatus");
75
+ const IDBSQLLogger_1 = require("../contracts/IDBSQLLogger");
76
+ const KernelErrorMapping_1 = require("./KernelErrorMapping");
77
+ const OperationStateError_1 = __importStar(require("../errors/OperationStateError"));
78
+ /**
79
+ * Factory for a fresh lifecycle-state record. Helps keep test setup
80
+ * tidy.
81
+ */
82
+ function createLifecycleState() {
83
+ return { isCancelled: false, isClosed: false };
84
+ }
85
+ exports.createLifecycleState = createLifecycleState;
86
+ /**
87
+ * Normalise an error thrown by the napi `Statement` into one of the
88
+ * driver's typed error classes, then throw it.
89
+ *
90
+ * Delegates to the canonical {@link decodeNapiKernelError} so cancel /
91
+ * close errors get exactly the same fidelity as fetch errors: the
92
+ * `sqlState` remap (the envelope field is `sqlState`, not `sqlstate`),
93
+ * the `kernelMetadata` namespace (vendorCode / httpStatus / retryable /
94
+ * queryId), and the strict `startsWith` sentinel match. The previous
95
+ * hand-rolled reimplementation here dropped SQLSTATE and metadata and
96
+ * used a looser substring match.
97
+ */
98
+ function rethrowKernelError(err) {
99
+ throw (0, KernelErrorMapping_1.decodeNapiKernelError)(err);
100
+ }
101
+ /**
102
+ * Cancel an in-flight kernel operation.
103
+ *
104
+ * Mirrors `DBSQLOperation.cancel` semantics
105
+ * (`lib/DBSQLOperation.ts:241-259`):
106
+ * - idempotent: returns success if already cancelled or closed
107
+ * (no-ops are not bubbled to the kernel because the binding's
108
+ * `Statement::cancel` already treats already-finished statements as
109
+ * a no-op, but we still want to avoid a network round-trip here),
110
+ * - sets the cancelled flag _before_ awaiting the napi call so that a
111
+ * concurrent `fetchChunk()` observing the flag short-circuits as
112
+ * soon as the await yields (matches the Thrift flag-set ordering
113
+ * at `lib/DBSQLOperation.ts:254`),
114
+ * - returns a `Status.success()` on success (no rich Thrift status
115
+ * payload is available from the kernel side).
116
+ */
117
+ async function kernelCancel(state, statement, context, operationId) {
118
+ if (state.isCancelled || state.isClosed) {
119
+ return Status_1.default.success();
120
+ }
121
+ context.getLogger().log(IDBSQLLogger_1.LogLevel.debug, `Cancelling kernel operation with id: ${operationId}`);
122
+ // Set the intent BEFORE the RPC and keep it set even if the cancel RPC
123
+ // fails: the caller asked to cancel, so the operation must stay cancelled
124
+ // (subsequent fetches fail fast, and any poll-loop observer that already saw
125
+ // the flag stays consistent). The RPC failure is surfaced via the rethrow —
126
+ // we do NOT roll the flag back, which would silently resurrect a cancelled
127
+ // operation while the kernel-side statement may still be running.
128
+ state.isCancelled = true;
129
+ try {
130
+ await statement.cancel();
131
+ }
132
+ catch (err) {
133
+ rethrowKernelError(err);
134
+ }
135
+ return Status_1.default.success();
136
+ }
137
+ exports.kernelCancel = kernelCancel;
138
+ /**
139
+ * Close a kernel operation.
140
+ *
141
+ * Mirrors `DBSQLOperation.close` semantics
142
+ * (`lib/DBSQLOperation.ts:265-284`) without the Thrift-only
143
+ * direct-results-prefetch optimisation:
144
+ * - idempotent: a second call is a no-op,
145
+ * - awaits the binding's `Statement::close` (which goes through to
146
+ * the kernel's `delete_statement` RPC),
147
+ * - sets the closed flag _before_ awaiting so a concurrent fetch
148
+ * sees the closed state as soon as the await yields.
149
+ */
150
+ async function kernelClose(state, statement, context, operationId) {
151
+ if (state.isClosed) {
152
+ return Status_1.default.success();
153
+ }
154
+ context.getLogger().log(IDBSQLLogger_1.LogLevel.debug, `Closing kernel operation with id: ${operationId}`);
155
+ state.isClosed = true;
156
+ try {
157
+ await statement.close();
158
+ }
159
+ catch (err) {
160
+ state.isClosed = false;
161
+ rethrowKernelError(err);
162
+ }
163
+ return Status_1.default.success();
164
+ }
165
+ exports.kernelClose = kernelClose;
166
+ /**
167
+ * Synthesize an {@link OperationStatus} reporting the "finished" state.
168
+ * `IOperationBackend.waitUntilReady` is backend-neutral surface — its
169
+ * `callback` receives an {@link OperationStatus}, not a Thrift wire struct
170
+ * (the public Thrift-shaped `OperationStatusCallback` is adapted at the
171
+ * `DBSQLOperation` facade boundary). We report `Succeeded`, and merge in any
172
+ * rich status fields (`numModifiedRows` / `displayMessage` / `diagnosticInfo`
173
+ * / `errorDetailsJson`) the backend resolved off the terminal kernel
174
+ * statement, so a `finished({callback})` consumer sees the same surface as a
175
+ * subsequent `getOperationStatus()` call.
176
+ */
177
+ function synthesizeFinishedStatus(extra) {
178
+ return {
179
+ state: OperationStatus_1.OperationState.Succeeded,
180
+ hasResultSet: true,
181
+ ...extra,
182
+ };
183
+ }
184
+ /**
185
+ * `IOperation.finished({progress, callback})` M0 implementation.
186
+ *
187
+ * The Thrift implementation is a 100ms polling loop over
188
+ * `getOperationStatus` (`lib/DBSQLOperation.ts:337-391`). For kernel M0,
189
+ * the kernel's `Statement::execute().await` already blocks until the
190
+ * statement reaches a terminal state — by the time the JS layer has
191
+ * a `Statement` handle, the operation has already finished.
192
+ *
193
+ * Therefore the M0 implementation resolves immediately. If the
194
+ * caller supplied a progress callback we still invoke it once (a
195
+ * single completion tick) so progress-UI consumers see the same
196
+ * "operation is now finished" signal they'd get from the polling
197
+ * Thrift path — just without the intermediate `RUNNING_STATE`
198
+ * notifications.
199
+ *
200
+ * If the operation is already cancelled or closed, this is a no-op
201
+ * (matches the Thrift `failIfClosed` / cancelled-state semantics
202
+ * without throwing; throwing is the responsibility of subsequent
203
+ * fetch calls).
204
+ */
205
+ async function kernelFinished(state, options,
206
+ // Rich status fields the backend read off the terminal statement, merged into
207
+ // the synthesised completion tick so callback consumers see them. Lazy (a
208
+ // thunk) so the (potentially RPC-backed) read only happens when a callback is
209
+ // actually wired.
210
+ richFields) {
211
+ if (state.isCancelled || state.isClosed) {
212
+ return;
213
+ }
214
+ if (options === null || options === void 0 ? void 0 : options.callback) {
215
+ const extra = richFields ? await richFields() : undefined;
216
+ const response = synthesizeFinishedStatus(extra);
217
+ // Await the callback in case it returns a promise — matches the
218
+ // Thrift code path at `lib/DBSQLOperation.ts:348-351`.
219
+ await Promise.resolve(options.callback(response));
220
+ }
221
+ }
222
+ exports.kernelFinished = kernelFinished;
223
+ /**
224
+ * Pre-flight check used by fetch* methods on `KernelOperationBackend`.
225
+ * If the operation has been cancelled or closed, throw the same
226
+ * `OperationStateError` classes the facade uses. Keeping these typed lets
227
+ * callers branch on `OperationStateErrorCode` consistently for Thrift and kernel.
228
+ *
229
+ * Exported so impl-results can call it at the top of every fetch
230
+ * call without duplicating the if/throw logic.
231
+ */
232
+ function failIfNotActive(state) {
233
+ if (state.isCancelled) {
234
+ // Use the canonical `OperationStateError(Canceled)` (message "The operation
235
+ // was canceled by a client") rather than a custom string, so the message
236
+ // matches the Thrift path verbatim and the code branch stays consistent
237
+ // with the Closed case below.
238
+ throw new OperationStateError_1.default(OperationStateError_1.OperationStateErrorCode.Canceled);
239
+ }
240
+ if (state.isClosed) {
241
+ throw new OperationStateError_1.default(OperationStateError_1.OperationStateErrorCode.Closed);
242
+ }
243
+ }
244
+ exports.failIfNotActive = failIfNotActive;
245
+ //# sourceMappingURL=KernelOperationLifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KernelOperationLifecycle.js","sourceRoot":"","sources":["../../lib/kernel/KernelOperationLifecycle.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,2DAAmC;AACnC,kEAA+E;AAC/E,4DAAqD;AAErD,6DAA6D;AAC7D,qFAA6F;AA+B7F;;;GAGG;AACH,SAAgB,oBAAoB;IAClC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,E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uB,CAAC,MAAM,CAAC,CAAC;KAC/D;AACH,CAAC;AAXD,0CAWC"}
@@ -0,0 +1,16 @@
1
+ import { DBSQLParameter, DBSQLParameterValue } from '../DBSQLParameter';
2
+ import { KernelNativeTypedValueInput, KernelNativeNamedTypedValueInput } from './KernelNativeLoader';
3
+ /**
4
+ * Convert the public `ordinalParameters` option into the napi
5
+ * `positionalParams` array (1-based `?` placeholders). Returns `undefined`
6
+ * when none were supplied, so the caller can keep the minimal no-options
7
+ * call shape.
8
+ */
9
+ export declare function buildKernelPositionalParams(ordinalParameters?: Array<DBSQLParameter | DBSQLParameterValue>): Array<KernelNativeTypedValueInput> | undefined;
10
+ /**
11
+ * Convert the public `namedParameters` option (`Record<name, value>`) into
12
+ * the napi `namedParams` array (`:name` placeholders). Each value reuses the
13
+ * same `toTypedValueInput` mapping (DECIMAL → DECIMAL(p,s), NULL → VOID, …),
14
+ * then carries its name. Returns `undefined` when none were supplied.
15
+ */
16
+ export declare function buildKernelNamedParams(namedParameters?: Record<string, DBSQLParameter | DBSQLParameterValue>): Array<KernelNativeNamedTypedValueInput> | undefined;
@@ -0,0 +1,120 @@
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
+ exports.buildKernelNamedParams = exports.buildKernelPositionalParams = void 0;
20
+ const DBSQLParameter_1 = require("../DBSQLParameter");
21
+ const ParameterError_1 = __importDefault(require("../errors/ParameterError"));
22
+ const KernelInputValidation_1 = __importDefault(require("./KernelInputValidation"));
23
+ /**
24
+ * Derive `(precision,scale)` from a decimal value string for the kernel
25
+ * `DECIMAL(p,s)` type name — the kernel param codec requires the parenthesised
26
+ * form (plain `"DECIMAL"` is rejected) so it preserves the caller's fractional
27
+ * digits. `"99.99"` ⇒ `"4,2"`; `"-123"` ⇒ `"3,0"`; `"0.00001"` ⇒ `"5,5"`.
28
+ *
29
+ * Precision is significant integer digits (insignificant leading zeros
30
+ * stripped, matching Spark's decimal-literal rule) plus the fractional scale.
31
+ * The value is NOT clamped: a non-numeric value, or one that needs precision >
32
+ * the Databricks maximum of 38, throws `ParameterError` at bind time rather
33
+ * than emitting an inconsistent `DECIMAL(38,…)` type alongside an
34
+ * unrepresentable value (which the kernel would reject or silently truncate).
35
+ */
36
+ function decimalPrecisionScale(v) {
37
+ var _a, _b;
38
+ // Accept an optional sign + plain decimal numeral only. Exponential form
39
+ // ("1e+21"), empty, and non-numeric ("abc") are rejected with a clear error
40
+ // instead of mis-deriving (p,s) and surfacing an opaque kernel failure.
41
+ const m = /^[+-]?(\d*)(?:\.(\d+))?$/.exec(v.trim());
42
+ const intPart = (_a = m === null || m === void 0 ? void 0 : m[1]) !== null && _a !== void 0 ? _a : '';
43
+ const fracPart = (_b = m === null || m === void 0 ? void 0 : m[2]) !== null && _b !== void 0 ? _b : '';
44
+ if (!m || (intPart === '' && fracPart === '')) {
45
+ throw new ParameterError_1.default(`DECIMAL parameter value "${v}" is not a plain decimal numeral (expected [+-]?digits[.digits]).`);
46
+ }
47
+ const scale = fracPart.length;
48
+ // Significant integer digits: drop insignificant leading zeros ("007" → 1,
49
+ // "0" / "" → 0) so e.g. 0.00001 is DECIMAL(5,5), not DECIMAL(6,5).
50
+ const significantIntDigits = intPart.replace(/^0+/, '').length;
51
+ const precision = Math.max(significantIntDigits + scale, 1);
52
+ if (precision > 38) {
53
+ throw new ParameterError_1.default(`DECIMAL parameter value "${v}" needs precision ${precision}, exceeding the Databricks maximum of 38. ` +
54
+ 'Round/scale the value or bind it as a STRING.');
55
+ }
56
+ return `${precision},${scale}`;
57
+ }
58
+ /**
59
+ * Reduce a `DBSQLParameter | DBSQLParameterValue` to the napi
60
+ * `TypedValueInput` (`{ sqlType, value? }`) the kernel's positional-param
61
+ * codec (`parse_typed_value`) accepts. Reuses `DBSQLParameter.toSparkParameter`
62
+ * — the same type-inference + value-stringification the Thrift backend uses —
63
+ * then adapts the type name to the codec's expectations:
64
+ * - DECIMAL → `DECIMAL(p,s)` (parenthesised form required)
65
+ * - INTERVAL * → `INTERVAL` (the codec's single interval type name)
66
+ * - a missing value ⇒ SQL NULL (`parse_typed_value` maps `value: None` to NULL).
67
+ */
68
+ function toTypedValueInput(value) {
69
+ var _a, _b, _c;
70
+ const param = value instanceof DBSQLParameter_1.DBSQLParameter ? value : new DBSQLParameter_1.DBSQLParameter({ value });
71
+ const spark = param.toSparkParameter();
72
+ const stringValue = (_b = (_a = spark.value) === null || _a === void 0 ? void 0 : _a.stringValue) !== null && _b !== void 0 ? _b : undefined;
73
+ // NULL: no value (and `VOID` ignores any type), matching toSparkParameter's
74
+ // type/value-less shape for null/undefined.
75
+ if (stringValue === undefined || stringValue === null) {
76
+ return { sqlType: 'VOID' };
77
+ }
78
+ let sqlType = (_c = spark.type) !== null && _c !== void 0 ? _c : 'STRING';
79
+ const upper = sqlType.toUpperCase();
80
+ if (upper === 'DECIMAL') {
81
+ sqlType = `DECIMAL(${decimalPrecisionScale(stringValue)})`;
82
+ }
83
+ else if (upper.startsWith('INTERVAL')) {
84
+ sqlType = 'INTERVAL';
85
+ }
86
+ return { sqlType, value: stringValue };
87
+ }
88
+ /**
89
+ * Convert the public `ordinalParameters` option into the napi
90
+ * `positionalParams` array (1-based `?` placeholders). Returns `undefined`
91
+ * when none were supplied, so the caller can keep the minimal no-options
92
+ * call shape.
93
+ */
94
+ function buildKernelPositionalParams(ordinalParameters) {
95
+ if (ordinalParameters === undefined || ordinalParameters.length === 0) {
96
+ return undefined;
97
+ }
98
+ return ordinalParameters.map((value, i) => {
99
+ (0, KernelInputValidation_1.default)(value, `ordinalParameters[${i}]`);
100
+ return toTypedValueInput(value);
101
+ });
102
+ }
103
+ exports.buildKernelPositionalParams = buildKernelPositionalParams;
104
+ /**
105
+ * Convert the public `namedParameters` option (`Record<name, value>`) into
106
+ * the napi `namedParams` array (`:name` placeholders). Each value reuses the
107
+ * same `toTypedValueInput` mapping (DECIMAL → DECIMAL(p,s), NULL → VOID, …),
108
+ * then carries its name. Returns `undefined` when none were supplied.
109
+ */
110
+ function buildKernelNamedParams(namedParameters) {
111
+ if (namedParameters === undefined || Object.keys(namedParameters).length === 0) {
112
+ return undefined;
113
+ }
114
+ return Object.keys(namedParameters).map((name) => {
115
+ (0, KernelInputValidation_1.default)(namedParameters[name], `namedParameters[${name}]`);
116
+ return { name, ...toTypedValueInput(namedParameters[name]) };
117
+ });
118
+ }
119
+ exports.buildKernelNamedParams = buildKernelNamedParams;
120
+ //# sourceMappingURL=KernelPositionalParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KernelPositionalParams.js","sourceRoot":"","sources":["../../lib/kernel/KernelPositionalParams.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,sDAAwE;AACxE,8EAAsD;AAEtD,oFAA0D;AAE1D;;;;;;;;;;;;GAYG;AACH,SAAS,qBAAqB,CAAC,CAAS;;IACtC,yEAAyE;IACzE,4EAA4E;IAC5E,wEAAwE;IACxE,MAAM,CAAC,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACpD,MAAM,OAAO,G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GAAG,iBAAiB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC;AAVD,wDAUC"}
@@ -0,0 +1,44 @@
1
+ /// <reference types="node" />
2
+ import IResultsProvider, { ResultsProviderFetchNextOptions } from '../result/IResultsProvider';
3
+ import { ArrowBatch } from '../result/utils';
4
+ /**
5
+ * The minimal slice of the napi-binding `Statement` class that we
6
+ * consume from JS. Defined locally (not imported from the binding's
7
+ * d.ts) so the loader layer's loose `unknown` typing doesn't force
8
+ * unsafe casts at every call site, and so unit tests can pass a stub.
9
+ */
10
+ export interface KernelFetchHandle {
11
+ fetchNextBatch(): Promise<{
12
+ ipcBytes: Buffer;
13
+ } | null>;
14
+ }
15
+ /**
16
+ * `IResultsProvider<ArrowBatch>` that pulls Arrow IPC batches from the
17
+ * kernel via the napi `Statement` handle and adapts them onto the
18
+ * shape `ArrowResultConverter` already speaks
19
+ * (`lib/result/utils.ts:22-25`).
20
+ *
21
+ * Each kernel `fetchNextBatch()` call returns a complete Arrow IPC
22
+ * stream (schema header + 1 record-batch message) per the design
23
+ * documented at `kernel-workflow/findings/arch/napi-binding/round2-methods-2026-05-15.md:46-60`.
24
+ * We pass that buffer through as a single-element `batches: [ipcBytes]`
25
+ * array — `RecordBatchReader.from(arrowBatch.batches)` inside the
26
+ * converter (`lib/result/ArrowResultConverter.ts:119`) reads the
27
+ * schema from the prefix and then the record-batch messages from the
28
+ * remainder of the same buffer.
29
+ *
30
+ * We pre-parse the IPC bytes once here to extract `rowCount` (the
31
+ * sum of `RecordBatch.numRows` across messages in the stream) because
32
+ * the converter consumes that as an explicit field rather than
33
+ * deriving it from the batch contents. See the comment in
34
+ * `KernelArrowIpc.ts:decodeIpcBatch` for the cost rationale.
35
+ */
36
+ export default class KernelResultsProvider implements IResultsProvider<ArrowBatch> {
37
+ private readonly statement;
38
+ private prefetched?;
39
+ private exhausted;
40
+ constructor(statement: KernelFetchHandle);
41
+ hasMore(): Promise<boolean>;
42
+ fetchNext(_options: ResultsProviderFetchNextOptions): Promise<ArrowBatch>;
43
+ private prime;
44
+ }