@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,102 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ const KernelArrowIpc_1 = require("./KernelArrowIpc");
17
+ /**
18
+ * `IResultsProvider<ArrowBatch>` that pulls Arrow IPC batches from the
19
+ * kernel via the napi `Statement` handle and adapts them onto the
20
+ * shape `ArrowResultConverter` already speaks
21
+ * (`lib/result/utils.ts:22-25`).
22
+ *
23
+ * Each kernel `fetchNextBatch()` call returns a complete Arrow IPC
24
+ * stream (schema header + 1 record-batch message) per the design
25
+ * documented at `kernel-workflow/findings/arch/napi-binding/round2-methods-2026-05-15.md:46-60`.
26
+ * We pass that buffer through as a single-element `batches: [ipcBytes]`
27
+ * array — `RecordBatchReader.from(arrowBatch.batches)` inside the
28
+ * converter (`lib/result/ArrowResultConverter.ts:119`) reads the
29
+ * schema from the prefix and then the record-batch messages from the
30
+ * remainder of the same buffer.
31
+ *
32
+ * We pre-parse the IPC bytes once here to extract `rowCount` (the
33
+ * sum of `RecordBatch.numRows` across messages in the stream) because
34
+ * the converter consumes that as an explicit field rather than
35
+ * deriving it from the batch contents. See the comment in
36
+ * `KernelArrowIpc.ts:decodeIpcBatch` for the cost rationale.
37
+ */
38
+ class KernelResultsProvider {
39
+ constructor(statement) {
40
+ // Set once the kernel returns `null` from `fetchNextBatch()`.
41
+ this.exhausted = false;
42
+ this.statement = statement;
43
+ }
44
+ async hasMore() {
45
+ if (this.exhausted) {
46
+ return false;
47
+ }
48
+ if (this.prefetched !== undefined) {
49
+ return true;
50
+ }
51
+ await this.prime();
52
+ return this.prefetched !== undefined;
53
+ }
54
+ async fetchNext(_options) {
55
+ if (this.prefetched === undefined && !this.exhausted) {
56
+ await this.prime();
57
+ }
58
+ if (this.prefetched === undefined) {
59
+ return { batches: [], rowCount: 0 };
60
+ }
61
+ const out = this.prefetched;
62
+ this.prefetched = undefined;
63
+ return out;
64
+ }
65
+ // Pull the next batch from the kernel and stash it in `prefetched`,
66
+ // or mark the stream exhausted. Used by both `hasMore` and `fetchNext`
67
+ // to keep one batch buffered ahead so `hasMore` is accurate without
68
+ // re-asking the kernel.
69
+ async prime() {
70
+ // Loop rather than self-recurse: a long run of empty batches drains
71
+ // iteratively toward the null sentinel without building a deep promise
72
+ // chain.
73
+ while (!this.exhausted && this.prefetched === undefined) {
74
+ // eslint-disable-next-line no-await-in-loop
75
+ const next = await this.statement.fetchNextBatch();
76
+ if (next === null) {
77
+ this.exhausted = true;
78
+ return;
79
+ }
80
+ // Patch the raw bytes once: rewrite any Arrow `Duration` field to
81
+ // `Int64` with a `databricks.arrow.duration_unit` marker, so that
82
+ // apache-arrow@13 (which predates Duration support) can decode the
83
+ // stream. The downstream `RecordBatchReader.from` inside
84
+ // `ArrowResultConverter` sees the same patched buffer. See
85
+ // `KernelArrowIpcDurationFix.ts`.
86
+ const ipcBytes = (0, KernelArrowIpc_1.patchIpcBytes)(next.ipcBytes);
87
+ // Row count only — `countRowsInIpc` reads the RecordBatch metadata
88
+ // headers without materializing vectors (the converter re-decodes
89
+ // the bytes for the actual values). Avoids a full second Arrow
90
+ // decode on the fetch hot path.
91
+ const rowCount = (0, KernelArrowIpc_1.countRowsInIpc)(ipcBytes);
92
+ // Skip empty batches — the converter handles them but pre-filtering here
93
+ // avoids a round-trip through the converter's prefetch loop. Continue to
94
+ // find a non-empty batch or hit exhaustion.
95
+ if (rowCount > 0) {
96
+ this.prefetched = { batches: [ipcBytes], rowCount };
97
+ }
98
+ }
99
+ }
100
+ }
101
+ exports.default = KernelResultsProvider;
102
+ //# sourceMappingURL=KernelResultsProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KernelResultsProvider.js","sourceRoot":"","sources":["../../lib/kernel/KernelResultsProvider.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;;AAIjC,qDAAiE;AAYjE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAqB,qBAAqB;IAUxC,YAAY,SAA4B;QAHxC,8DAA8D;QACtD,cAAS,GAAG,KAAK,CAAC;QAGxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,OAAO,KAAK,CAAC;SACd;QACD,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE;YACjC,OAAO,IAAI,CAAC;SACb;QACD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,QAAyC;QAC9D,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACpD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;SACpB;QACD,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE;YACjC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;SACrC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,oEAAoE;IACpE,uEAAuE;IACvE,oEAAoE;IACpE,wBAAwB;IAChB,KAAK,CAAC,KAAK;QACjB,oEAAoE;QACpE,uEAAuE;QACvE,SAAS;QACT,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE;YACvD,4CAA4C;YAC5C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;YACnD,IAAI,IAAI,KAAK,IAAI,EAAE;gBACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,OAAO;aACR;YACD,kEAAkE;YAClE,kEAAkE;YAClE,mEAAmE;YACnE,yDAAyD;YACzD,2DAA2D;YAC3D,kCAAkC;YAClC,MAAM,QAAQ,GAAG,IAAA,8BAAa,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9C,mEAAmE;YACnE,kEAAkE;YAClE,+DAA+D;YAC/D,gCAAgC;YAChC,MAAM,QAAQ,GAAG,IAAA,+BAAc,EAAC,QAAQ,CAAC,CAAC;YAC1C,yEAAyE;YACzE,yEAAyE;YACzE,4CAA4C;YAC5C,IAAI,QAAQ,GAAG,CAAC,EAAE;gBAChB,IAAI,CAAC,UAAU,GAAG,EAAE,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;aACrD;SACF;IACH,CAAC;CACF;AAxED,wCAwEC"}
@@ -0,0 +1,44 @@
1
+ import { TGetInfoValue } from '../../thrift/TCLIService_types';
2
+ /**
3
+ * `getInfo` (JDBC `DatabaseMetaData` / ODBC `SQLGetInfo`) is a Thrift-protocol
4
+ * concept: the Thrift backend forwards `TGetInfoReq` to the server's `getInfo`
5
+ * RPC. The SEA REST protocol and the Rust kernel have **no** equivalent
6
+ * endpoint, so — exactly as JDBC does for `DatabaseMetaData` — we synthesize
7
+ * the values client-side.
8
+ *
9
+ * The Databricks Thrift server itself answers only three `TGetInfoType`s and
10
+ * rejects every other value; we mirror that surface so the kernel path is a
11
+ * drop-in equivalent:
12
+ *
13
+ * | TGetInfoType | Thrift server | kernel (here) |
14
+ * |---------------------|---------------|-------------------|
15
+ * | CLI_SERVER_NAME (13)| "Spark SQL" | "Spark SQL" |
16
+ * | CLI_DBMS_NAME (17)| "Spark SQL" | "Spark SQL" |
17
+ * | CLI_DBMS_VER (18)| "3.1.1" | "3.1.1" |
18
+ * | (any other) | error | undefined → error |
19
+ *
20
+ * Empirically re-verified against a live warehouse over the Thrift path: the
21
+ * three values above are byte-identical to the server's, and the server
22
+ * returns an error for every other `TGetInfoType` (probed CLI_MAX_DRIVER_-
23
+ * CONNECTIONS, CLI_DATA_SOURCE_NAME, CLI_FETCH_DIRECTION, … — all errored). So
24
+ * the kernel "undefined → throw" path matches Thrift's effective behaviour rather
25
+ * than narrowing it.
26
+ */
27
+ /** Canonical DBMS product name — identical to the Thrift server's value. */
28
+ export declare const KERNEL_DBMS_NAME = "Spark SQL";
29
+ /** Server-name answer — identical to the Thrift server's value. */
30
+ export declare const KERNEL_SERVER_NAME = "Spark SQL";
31
+ /**
32
+ * DBMS version string. Mirrors the constant the Databricks Thrift server
33
+ * reports for `CLI_DBMS_VER` (the HiveServer2-compat Spark SQL version, not
34
+ * the DBR release). Kept in lock-step with Thrift for parity; if the server
35
+ * ever changes it the comparator's GET_INFO suite flags the drift.
36
+ */
37
+ export declare const KERNEL_DBMS_VERSION = "3.1.1";
38
+ /**
39
+ * Synthesize the `TGetInfoValue` for a `getInfo` request on the kernel path.
40
+ * Returns `undefined` for any `TGetInfoType` the (Thrift) server does not
41
+ * answer — the caller surfaces that as an error, matching Thrift's
42
+ * reject-unsupported-info-type behaviour.
43
+ */
44
+ export declare function kernelServerInfoValue(infoType: number): TGetInfoValue | undefined;
@@ -0,0 +1,73 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.kernelServerInfoValue = exports.KERNEL_DBMS_VERSION = exports.KERNEL_SERVER_NAME = exports.KERNEL_DBMS_NAME = void 0;
17
+ const TCLIService_types_1 = require("../../thrift/TCLIService_types");
18
+ /**
19
+ * `getInfo` (JDBC `DatabaseMetaData` / ODBC `SQLGetInfo`) is a Thrift-protocol
20
+ * concept: the Thrift backend forwards `TGetInfoReq` to the server's `getInfo`
21
+ * RPC. The SEA REST protocol and the Rust kernel have **no** equivalent
22
+ * endpoint, so — exactly as JDBC does for `DatabaseMetaData` — we synthesize
23
+ * the values client-side.
24
+ *
25
+ * The Databricks Thrift server itself answers only three `TGetInfoType`s and
26
+ * rejects every other value; we mirror that surface so the kernel path is a
27
+ * drop-in equivalent:
28
+ *
29
+ * | TGetInfoType | Thrift server | kernel (here) |
30
+ * |---------------------|---------------|-------------------|
31
+ * | CLI_SERVER_NAME (13)| "Spark SQL" | "Spark SQL" |
32
+ * | CLI_DBMS_NAME (17)| "Spark SQL" | "Spark SQL" |
33
+ * | CLI_DBMS_VER (18)| "3.1.1" | "3.1.1" |
34
+ * | (any other) | error | undefined → error |
35
+ *
36
+ * Empirically re-verified against a live warehouse over the Thrift path: the
37
+ * three values above are byte-identical to the server's, and the server
38
+ * returns an error for every other `TGetInfoType` (probed CLI_MAX_DRIVER_-
39
+ * CONNECTIONS, CLI_DATA_SOURCE_NAME, CLI_FETCH_DIRECTION, … — all errored). So
40
+ * the kernel "undefined → throw" path matches Thrift's effective behaviour rather
41
+ * than narrowing it.
42
+ */
43
+ /** Canonical DBMS product name — identical to the Thrift server's value. */
44
+ exports.KERNEL_DBMS_NAME = 'Spark SQL';
45
+ /** Server-name answer — identical to the Thrift server's value. */
46
+ exports.KERNEL_SERVER_NAME = 'Spark SQL';
47
+ /**
48
+ * DBMS version string. Mirrors the constant the Databricks Thrift server
49
+ * reports for `CLI_DBMS_VER` (the HiveServer2-compat Spark SQL version, not
50
+ * the DBR release). Kept in lock-step with Thrift for parity; if the server
51
+ * ever changes it the comparator's GET_INFO suite flags the drift.
52
+ */
53
+ exports.KERNEL_DBMS_VERSION = '3.1.1';
54
+ /**
55
+ * Synthesize the `TGetInfoValue` for a `getInfo` request on the kernel path.
56
+ * Returns `undefined` for any `TGetInfoType` the (Thrift) server does not
57
+ * answer — the caller surfaces that as an error, matching Thrift's
58
+ * reject-unsupported-info-type behaviour.
59
+ */
60
+ function kernelServerInfoValue(infoType) {
61
+ switch (infoType) {
62
+ case TCLIService_types_1.TGetInfoType.CLI_SERVER_NAME:
63
+ return new TCLIService_types_1.TGetInfoValue({ stringValue: exports.KERNEL_SERVER_NAME });
64
+ case TCLIService_types_1.TGetInfoType.CLI_DBMS_NAME:
65
+ return new TCLIService_types_1.TGetInfoValue({ stringValue: exports.KERNEL_DBMS_NAME });
66
+ case TCLIService_types_1.TGetInfoType.CLI_DBMS_VER:
67
+ return new TCLIService_types_1.TGetInfoValue({ stringValue: exports.KERNEL_DBMS_VERSION });
68
+ default:
69
+ return undefined;
70
+ }
71
+ }
72
+ exports.kernelServerInfoValue = kernelServerInfoValue;
73
+ //# sourceMappingURL=KernelServerInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KernelServerInfo.js","sourceRoot":"","sources":["../../lib/kernel/KernelServerInfo.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,sEAA6E;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,4EAA4E;AAC/D,QAAA,gBAAgB,GAAG,WAAW,CAAC;AAE5C,mEAAmE;AACtD,QAAA,kBAAkB,GAAG,WAAW,CAAC;AAE9C;;;;;GAKG;AACU,QAAA,mBAAmB,GAAG,OAAO,CAAC;AAE3C;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,QAAgB;IACpD,QAAQ,QAAQ,EAAE;QAChB,KAAK,gCAAY,CAAC,eAAe;YAC/B,OAAO,IAAI,iCAAa,CAAC,EAAE,WAAW,EAAE,0BAAkB,EAAE,CAAC,CAAC;QAChE,KAAK,gCAAY,CAAC,aAAa;YAC7B,OAAO,IAAI,iCAAa,CAAC,EAAE,WAAW,EAAE,wBAAgB,EAAE,CAAC,CAAC;QAC9D,KAAK,gCAAY,CAAC,YAAY;YAC5B,OAAO,IAAI,iCAAa,CAAC,EAAE,WAAW,EAAE,2BAAmB,EAAE,CAAC,CAAC;QACjE;YACE,OAAO,SAAS,CAAC;KACpB;AACH,CAAC;AAXD,sDAWC"}
@@ -0,0 +1,100 @@
1
+ import ISessionBackend from '../contracts/ISessionBackend';
2
+ import IOperationBackend from '../contracts/IOperationBackend';
3
+ import IClientContext from '../contracts/IClientContext';
4
+ import { ExecuteStatementOptions, TypeInfoRequest, CatalogsRequest, SchemasRequest, TablesRequest, TableTypesRequest, ColumnsRequest, FunctionsRequest, PrimaryKeysRequest, CrossReferenceRequest } from '../contracts/IDBSQLSession';
5
+ import Status from '../dto/Status';
6
+ import InfoValue from '../dto/InfoValue';
7
+ import { KernelConnection } from './KernelNativeLoader';
8
+ export interface KernelSessionBackendOptions {
9
+ /** The opaque napi `Connection` handle returned by `openSession`. */
10
+ connection: KernelConnection;
11
+ context: IClientContext;
12
+ /** Optional override for `id`. Defaults to a fresh UUIDv4. */
13
+ id?: string;
14
+ }
15
+ export default class KernelSessionBackend implements ISessionBackend {
16
+ private readonly connection;
17
+ private readonly context;
18
+ private readonly _id;
19
+ private closed;
20
+ constructor({ connection, context, id }: KernelSessionBackendOptions);
21
+ get id(): string;
22
+ /**
23
+ * `getInfo` (JDBC `DatabaseMetaData` / ODBC `SQLGetInfo`) has no kernel
24
+ * endpoint, so — exactly as JDBC does for `DatabaseMetaData` — we synthesize
25
+ * the answer client-side for the three `TGetInfoType`s the Databricks server
26
+ * answers (server name / DBMS name / DBMS version) and reject the rest.
27
+ *
28
+ * This is NOT a kernel-only contract narrowing: probing the live warehouse over
29
+ * the Thrift path confirms the server itself returns an error for every
30
+ * other `TGetInfoType` (CLI_MAX_DRIVER_CONNECTIONS, CLI_DATA_SOURCE_NAME, …),
31
+ * and the three values it does answer are byte-identical to the constants we
32
+ * synthesize (`"Spark SQL"` / `"Spark SQL"` / `"3.1.1"`, re-verified live).
33
+ * So rejecting an unsupported type matches Thrift's effective behaviour — we
34
+ * just surface a clearer, typed error than the server's opaque one. See
35
+ * {@link kernelServerInfoValue}.
36
+ */
37
+ getInfo(infoType: number): Promise<InfoValue>;
38
+ /**
39
+ * Execute a SQL statement through the napi binding.
40
+ *
41
+ * Catalog / schema / sessionConf are session-level (applied at open).
42
+ * Per-statement options forwarded to the kernel `ExecuteOptions`:
43
+ * - `ordinalParameters` / `namedParameters` → bound params (mutually
44
+ * exclusive — the kernel binds one placeholder style per statement);
45
+ * - `queryTimeout` → NO-OP on kernel (SQL Warehouses use `STATEMENT_TIMEOUT`);
46
+ * never forwarded to the kernel and never applied as a client-side
47
+ * deadline — see the note in `executeStatement`;
48
+ * - `rowLimit` → `rowLimit` (kernel-only server-side row cap);
49
+ * - `queryTags` → serialised into the conf overlay's reserved
50
+ * `query_tags` key (the same wire shape Thrift's `serializeQueryTags`
51
+ * produces), merged with any explicit `statementConf`.
52
+ *
53
+ * Still rejected (genuinely unsupported on kernel, rather than silently
54
+ * dropped): `useCloudFetch` (governed by the kernel `ResultConfig`, not a
55
+ * per-statement knob), `useLZ4Compression` (kernel owns result compression),
56
+ * and `stagingAllowedLocalPath` (volume operations). `maxRows` is applied by
57
+ * the facade at fetch time, so it is intentionally not handled here.
58
+ */
59
+ executeStatement(statement: string, options: ExecuteStatementOptions): Promise<IOperationBackend>;
60
+ /**
61
+ * Translate the public `ExecuteStatementOptions` into the kernel napi
62
+ * `ExecuteOptions`, returning `undefined` when nothing is set so the
63
+ * no-options call shape (`executeStatement(sql)`) is preserved.
64
+ */
65
+ private buildExecuteOptions;
66
+ /** Wrap a napi metadata `Statement` (already terminal) as an operation backend. */
67
+ private wrapStatement;
68
+ /**
69
+ * Metadata calls forward to the kernel's metadata surface (`listCatalogs`,
70
+ * `listTables`, …), each of which returns a napi `Statement` whose result
71
+ * carries the JDBC-shaped columns. We wrap that handle exactly like an
72
+ * executed statement. The kernel owns the SQL synthesis, the column
73
+ * projection, and (for `listTables`) the client-side `TABLE_TYPE` filter —
74
+ * the driver only maps the request fields to positional arguments.
75
+ *
76
+ * The `runAsync` / `maxRows` request fields are not threaded here: `runAsync`
77
+ * is deprecated, and `maxRows` is applied by the facade at fetch time (same
78
+ * as the Thrift path), so the napi call takes only the filter arguments.
79
+ */
80
+ getTypeInfo(_request: TypeInfoRequest): Promise<IOperationBackend>;
81
+ getCatalogs(_request: CatalogsRequest): Promise<IOperationBackend>;
82
+ getSchemas(request: SchemasRequest): Promise<IOperationBackend>;
83
+ getTables(request: TablesRequest): Promise<IOperationBackend>;
84
+ getTableTypes(_request: TableTypesRequest): Promise<IOperationBackend>;
85
+ getColumns(request: ColumnsRequest): Promise<IOperationBackend>;
86
+ getFunctions(request: FunctionsRequest): Promise<IOperationBackend>;
87
+ getPrimaryKeys(request: PrimaryKeysRequest): Promise<IOperationBackend>;
88
+ getCrossReference(request: CrossReferenceRequest): Promise<IOperationBackend>;
89
+ /** Run a napi metadata call, mapping kernel errors and wrapping the result handle. */
90
+ private runMetadata;
91
+ /**
92
+ * Map a napi/kernel error to a typed driver error and emit a debug breadcrumb
93
+ * first, matching the rest of the kernel backend's logging convention
94
+ * (`KernelOperationLifecycle` / `KernelOperationBackend`). Metadata and bound-param
95
+ * execute failures otherwise threw with no on-call signal.
96
+ */
97
+ private logAndMapError;
98
+ close(): Promise<Status>;
99
+ private failIfClosed;
100
+ }