@databricks/sql 1.14.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 (150) hide show
  1. package/README.md +12 -0
  2. package/dist/DBSQLClient.d.ts +102 -0
  3. package/dist/DBSQLClient.js +541 -55
  4. package/dist/DBSQLClient.js.map +1 -1
  5. package/dist/DBSQLLogger.d.ts +3 -0
  6. package/dist/DBSQLLogger.js +25 -0
  7. package/dist/DBSQLLogger.js.map +1 -1
  8. package/dist/DBSQLOperation.d.ts +67 -17
  9. package/dist/DBSQLOperation.js +245 -217
  10. package/dist/DBSQLOperation.js.map +1 -1
  11. package/dist/DBSQLParameter.d.ts +2 -0
  12. package/dist/DBSQLParameter.js +63 -7
  13. package/dist/DBSQLParameter.js.map +1 -1
  14. package/dist/DBSQLSession.d.ts +24 -16
  15. package/dist/DBSQLSession.js +77 -268
  16. package/dist/DBSQLSession.js.map +1 -1
  17. package/dist/connection/auth/DatabricksOAuth/OAuthManager.js +10 -6
  18. package/dist/connection/auth/DatabricksOAuth/OAuthManager.js.map +1 -1
  19. package/dist/connection/connections/HttpRetryPolicy.d.ts +3 -0
  20. package/dist/connection/connections/HttpRetryPolicy.js +116 -21
  21. package/dist/connection/connections/HttpRetryPolicy.js.map +1 -1
  22. package/dist/connection/connections/ThriftHttpConnection.js +18 -3
  23. package/dist/connection/connections/ThriftHttpConnection.js.map +1 -1
  24. package/dist/contracts/IBackend.d.ts +31 -0
  25. package/dist/contracts/IBackend.js +3 -0
  26. package/dist/contracts/IBackend.js.map +1 -0
  27. package/dist/contracts/IClientContext.d.ts +30 -0
  28. package/dist/contracts/IDBSQLClient.d.ts +115 -0
  29. package/dist/contracts/IDBSQLLogger.d.ts +17 -0
  30. package/dist/contracts/IDBSQLLogger.js.map +1 -1
  31. package/dist/contracts/IDBSQLSession.d.ts +24 -1
  32. package/dist/contracts/IOperation.d.ts +10 -1
  33. package/dist/contracts/IOperationBackend.d.ts +98 -0
  34. package/dist/contracts/IOperationBackend.js +3 -0
  35. package/dist/contracts/IOperationBackend.js.map +1 -0
  36. package/dist/contracts/ISessionBackend.d.ts +36 -0
  37. package/dist/contracts/ISessionBackend.js +3 -0
  38. package/dist/contracts/ISessionBackend.js.map +1 -0
  39. package/dist/contracts/InternalConnectionOptions.d.ts +72 -0
  40. package/dist/contracts/InternalConnectionOptions.js +3 -0
  41. package/dist/contracts/InternalConnectionOptions.js.map +1 -0
  42. package/dist/contracts/OperationStatus.d.ts +76 -0
  43. package/dist/contracts/OperationStatus.js +28 -0
  44. package/dist/contracts/OperationStatus.js.map +1 -0
  45. package/dist/contracts/ResultMetadata.d.ts +34 -0
  46. package/dist/contracts/ResultMetadata.js +16 -0
  47. package/dist/contracts/ResultMetadata.js.map +1 -0
  48. package/dist/errors/AuthenticationError.d.ts +1 -0
  49. package/dist/errors/AuthenticationError.js +4 -0
  50. package/dist/errors/AuthenticationError.js.map +1 -1
  51. package/dist/index.d.ts +2 -0
  52. package/dist/index.js +7 -3
  53. package/dist/index.js.map +1 -1
  54. package/dist/kernel/KernelArrowIpc.d.ts +54 -0
  55. package/dist/kernel/KernelArrowIpc.js +292 -0
  56. package/dist/kernel/KernelArrowIpc.js.map +1 -0
  57. package/dist/kernel/KernelArrowIpcDurationFix.d.ts +29 -0
  58. package/dist/kernel/KernelArrowIpcDurationFix.js +605 -0
  59. package/dist/kernel/KernelArrowIpcDurationFix.js.map +1 -0
  60. package/dist/kernel/KernelAuth.d.ts +300 -0
  61. package/dist/kernel/KernelAuth.js +463 -0
  62. package/dist/kernel/KernelAuth.js.map +1 -0
  63. package/dist/kernel/KernelBackend.d.ts +53 -0
  64. package/dist/kernel/KernelBackend.js +164 -0
  65. package/dist/kernel/KernelBackend.js.map +1 -0
  66. package/dist/kernel/KernelErrorMapping.d.ts +109 -0
  67. package/dist/kernel/KernelErrorMapping.js +249 -0
  68. package/dist/kernel/KernelErrorMapping.js.map +1 -0
  69. package/dist/kernel/KernelInputValidation.d.ts +16 -0
  70. package/dist/kernel/KernelInputValidation.js +49 -0
  71. package/dist/kernel/KernelInputValidation.js.map +1 -0
  72. package/dist/kernel/KernelLogging.d.ts +63 -0
  73. package/dist/kernel/KernelLogging.js +128 -0
  74. package/dist/kernel/KernelLogging.js.map +1 -0
  75. package/dist/kernel/KernelNativeLoader.d.ts +77 -0
  76. package/dist/kernel/KernelNativeLoader.js +178 -0
  77. package/dist/kernel/KernelNativeLoader.js.map +1 -0
  78. package/dist/kernel/KernelOperationBackend.d.ts +154 -0
  79. package/dist/kernel/KernelOperationBackend.js +640 -0
  80. package/dist/kernel/KernelOperationBackend.js.map +1 -0
  81. package/dist/kernel/KernelOperationLifecycle.d.ts +130 -0
  82. package/dist/kernel/KernelOperationLifecycle.js +245 -0
  83. package/dist/kernel/KernelOperationLifecycle.js.map +1 -0
  84. package/dist/kernel/KernelPositionalParams.d.ts +16 -0
  85. package/dist/kernel/KernelPositionalParams.js +120 -0
  86. package/dist/kernel/KernelPositionalParams.js.map +1 -0
  87. package/dist/kernel/KernelResultsProvider.d.ts +44 -0
  88. package/dist/kernel/KernelResultsProvider.js +102 -0
  89. package/dist/kernel/KernelResultsProvider.js.map +1 -0
  90. package/dist/kernel/KernelServerInfo.d.ts +44 -0
  91. package/dist/kernel/KernelServerInfo.js +73 -0
  92. package/dist/kernel/KernelServerInfo.js.map +1 -0
  93. package/dist/kernel/KernelSessionBackend.d.ts +100 -0
  94. package/dist/kernel/KernelSessionBackend.js +384 -0
  95. package/dist/kernel/KernelSessionBackend.js.map +1 -0
  96. package/dist/result/ArrowResultConverter.d.ts +31 -2
  97. package/dist/result/ArrowResultConverter.js +226 -14
  98. package/dist/result/ArrowResultConverter.js.map +1 -1
  99. package/dist/result/CloudFetchResultHandler.d.ts +8 -1
  100. package/dist/result/CloudFetchResultHandler.js +64 -10
  101. package/dist/result/CloudFetchResultHandler.js.map +1 -1
  102. package/dist/result/RowSetProvider.d.ts +8 -1
  103. package/dist/result/RowSetProvider.js +110 -1
  104. package/dist/result/RowSetProvider.js.map +1 -1
  105. package/dist/telemetry/DatabricksTelemetryExporter.js +101 -34
  106. package/dist/telemetry/DatabricksTelemetryExporter.js.map +1 -1
  107. package/dist/telemetry/FeatureFlagCache.js +10 -4
  108. package/dist/telemetry/FeatureFlagCache.js.map +1 -1
  109. package/dist/telemetry/MetricsAggregator.d.ts +38 -0
  110. package/dist/telemetry/MetricsAggregator.js +249 -14
  111. package/dist/telemetry/MetricsAggregator.js.map +1 -1
  112. package/dist/telemetry/TelemetryClient.d.ts +94 -14
  113. package/dist/telemetry/TelemetryClient.js +252 -20
  114. package/dist/telemetry/TelemetryClient.js.map +1 -1
  115. package/dist/telemetry/TelemetryClientProvider.d.ts +28 -33
  116. package/dist/telemetry/TelemetryClientProvider.js +58 -52
  117. package/dist/telemetry/TelemetryClientProvider.js.map +1 -1
  118. package/dist/telemetry/TelemetryEventEmitter.d.ts +52 -26
  119. package/dist/telemetry/TelemetryEventEmitter.js +88 -109
  120. package/dist/telemetry/TelemetryEventEmitter.js.map +1 -1
  121. package/dist/telemetry/{urlUtils.d.ts → telemetryTypeMappers.d.ts} +8 -5
  122. package/dist/telemetry/telemetryTypeMappers.js +72 -0
  123. package/dist/telemetry/telemetryTypeMappers.js.map +1 -0
  124. package/dist/telemetry/telemetryUtils.d.ts +14 -0
  125. package/dist/telemetry/telemetryUtils.js +52 -1
  126. package/dist/telemetry/telemetryUtils.js.map +1 -1
  127. package/dist/telemetry/types.d.ts +48 -1
  128. package/dist/telemetry/types.js +5 -2
  129. package/dist/telemetry/types.js.map +1 -1
  130. package/dist/thrift-backend/ThriftBackend.d.ts +17 -0
  131. package/dist/thrift-backend/ThriftBackend.js +80 -0
  132. package/dist/thrift-backend/ThriftBackend.js.map +1 -0
  133. package/dist/thrift-backend/ThriftOperationBackend.d.ts +70 -0
  134. package/dist/thrift-backend/ThriftOperationBackend.js +330 -0
  135. package/dist/thrift-backend/ThriftOperationBackend.js.map +1 -0
  136. package/dist/thrift-backend/ThriftSessionBackend.d.ts +36 -0
  137. package/dist/thrift-backend/ThriftSessionBackend.js +266 -0
  138. package/dist/thrift-backend/ThriftSessionBackend.js.map +1 -0
  139. package/dist/thrift-backend/wireSynthesis.d.ts +30 -0
  140. package/dist/thrift-backend/wireSynthesis.js +128 -0
  141. package/dist/thrift-backend/wireSynthesis.js.map +1 -0
  142. package/dist/version.d.ts +1 -1
  143. package/dist/version.js +1 -1
  144. package/dist/version.js.map +1 -1
  145. package/native/kernel/README.md +97 -0
  146. package/native/kernel/index.d.ts +1069 -0
  147. package/native/kernel/index.js +325 -0
  148. package/package.json +14 -3
  149. package/dist/telemetry/urlUtils.js +0 -35
  150. package/dist/telemetry/urlUtils.js.map +0 -1
@@ -0,0 +1,98 @@
1
+ import Status from '../dto/Status';
2
+ import { TOperationType } from '../../thrift/TCLIService_types';
3
+ import { OperationStatus } from './OperationStatus';
4
+ import { ResultMetadata } from './ResultMetadata';
5
+ /**
6
+ * Backend-facing wait-loop options. Neutral by design — the `callback`
7
+ * receives an {@link OperationStatus}, not a Thrift wire struct, so a
8
+ * non-Thrift backend doesn't have to depend on Thrift IDL or synthesize a
9
+ * fake wire response just to invoke it. The facade `DBSQLOperation` adapts
10
+ * the user's public Thrift-shaped `OperationStatusCallback` into a neutral
11
+ * callback at the facade boundary.
12
+ */
13
+ export interface IOperationBackendWaitOptions {
14
+ /** Request progress payload from the backend on each poll. */
15
+ progress?: boolean;
16
+ /** Neutral progress callback invoked once per poll. */
17
+ callback?: (status: OperationStatus) => unknown;
18
+ }
19
+ /**
20
+ * What a `DBSQLOperation` needs from its backend. Returned by
21
+ * `ISessionBackend.executeStatement` and the metadata methods.
22
+ *
23
+ * Facade downcast policy: `DBSQLOperation.status()` and `getMetadata()`
24
+ * use `instanceof ThriftOperationBackend` to return the verbatim Thrift wire
25
+ * response on the Thrift path (zero-loss back-compat for legacy user code).
26
+ * These two are grandfathered. Do NOT add further `instanceof <BackendClass>`
27
+ * downcasts in the facade — extend this interface (or add an optional
28
+ * method) instead, so the abstraction stays neutral as more backends land.
29
+ */
30
+ export default interface IOperationBackend {
31
+ /** Operation identifier. */
32
+ readonly id: string;
33
+ /** Optional Thrift operation type used for statement telemetry classification. */
34
+ readonly operationType?: TOperationType;
35
+ /**
36
+ * Optional raw data provider exposed only for legacy tests that inspect
37
+ * result-handler internals. Not part of the public operation contract.
38
+ */
39
+ readonly dataProvider?: unknown;
40
+ /**
41
+ * Whether this operation has a result set.
42
+ *
43
+ * Method-form (rather than property) because the value is state-dependent:
44
+ * the initial value may be derived from the create-operation response, but
45
+ * implementations MUST refresh it from terminal status responses (the
46
+ * Thrift impl updates `operationHandle.hasResultSet` inside
47
+ * `processOperationStatusResponse`). The method form signals to
48
+ * implementers that this is a live read, not a constructor-time const.
49
+ */
50
+ hasResultSet(): boolean;
51
+ /**
52
+ * Fetch the next chunk of result rows.
53
+ *
54
+ * `isClosed`, when supplied, lets the facade probe its `closed`/`cancelled`
55
+ * flags from inside the backend at a safe yield point between metadata
56
+ * preparation and the data RPC. Implementations SHOULD invoke it after any
57
+ * macrotask yield they introduce and short-circuit (return `[]`) when it
58
+ * returns `true`, so a concurrent `cancel()`/`close()` does not run the data
59
+ * RPC to completion needlessly. The facade re-checks `failIfClosed()` after
60
+ * `fetchChunk` returns and throws the appropriate `OperationStateError`, so
61
+ * returning `[]` is the correct way to bail — the user-visible error is
62
+ * still raised by the facade.
63
+ */
64
+ fetchChunk(options: {
65
+ limit: number;
66
+ disableBuffering?: boolean;
67
+ isClosed?: () => boolean;
68
+ }): Promise<Array<object>>;
69
+ /** Whether more rows are available beyond what has been fetched. */
70
+ hasMore(): Promise<boolean>;
71
+ /**
72
+ * Poll the backend until the operation reaches a terminal state.
73
+ *
74
+ * Receives neutral {@link IOperationBackendWaitOptions} — implementations
75
+ * MUST invoke `options.callback` (when present) with a neutral
76
+ * {@link OperationStatus}, not a Thrift wire struct. The public Thrift-
77
+ * shaped `OperationStatusCallback` is adapted at the facade boundary in
78
+ * `DBSQLOperation`.
79
+ *
80
+ * MUST throw `OperationStateError` (with one of `OperationStateErrorCode.{Canceled,
81
+ * Closed, Error, Timeout, Unknown}`) on terminal non-success states. The
82
+ * `DBSQLOperation` facade depends on `Canceled` and `Closed` codes to mirror
83
+ * the operation into its closed/cancelled flags; future implementations must
84
+ * use the same error type for the facade to stay in sync.
85
+ */
86
+ waitUntilReady(options?: IOperationBackendWaitOptions): Promise<void>;
87
+ /**
88
+ * Fetch operation status as a neutral `OperationStatus`. Pass `progress: true`
89
+ * to request that the backend include a progress payload.
90
+ */
91
+ status(progress: boolean): Promise<OperationStatus>;
92
+ /** Fetch result-set metadata (schema, format, lz4 flag, arrow schema, staging flag). */
93
+ getResultMetadata(): Promise<ResultMetadata>;
94
+ /** Cancel the operation. */
95
+ cancel(): Promise<Status>;
96
+ /** Close the operation. Idempotent. */
97
+ close(): Promise<Status>;
98
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IOperationBackend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IOperationBackend.js","sourceRoot":"","sources":["../../lib/contracts/IOperationBackend.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ import IOperationBackend from './IOperationBackend';
2
+ import { ExecuteStatementOptions, TypeInfoRequest, CatalogsRequest, SchemasRequest, TablesRequest, TableTypesRequest, ColumnsRequest, FunctionsRequest, PrimaryKeysRequest, CrossReferenceRequest } from './IDBSQLSession';
3
+ import Status from '../dto/Status';
4
+ import InfoValue from '../dto/InfoValue';
5
+ /**
6
+ * What a `DBSQLSession` needs from its backend. Returned by
7
+ * `IBackend.openSession()`. Lifecycle tied to a single `DBSQLSession`.
8
+ */
9
+ export default interface ISessionBackend {
10
+ /** Session identifier. */
11
+ readonly id: string;
12
+ /** Returns general information about the data source. */
13
+ getInfo(infoType: number): Promise<InfoValue>;
14
+ /** Executes DDL/DML statements. */
15
+ executeStatement(statement: string, options: ExecuteStatementOptions): Promise<IOperationBackend>;
16
+ /** Information about supported data types. */
17
+ getTypeInfo(request: TypeInfoRequest): Promise<IOperationBackend>;
18
+ /** List of catalogs. */
19
+ getCatalogs(request: CatalogsRequest): Promise<IOperationBackend>;
20
+ /** List of schemas. */
21
+ getSchemas(request: SchemasRequest): Promise<IOperationBackend>;
22
+ /** List of tables. */
23
+ getTables(request: TablesRequest): Promise<IOperationBackend>;
24
+ /** List of supported table types. */
25
+ getTableTypes(request: TableTypesRequest): Promise<IOperationBackend>;
26
+ /** Full column information for a table. */
27
+ getColumns(request: ColumnsRequest): Promise<IOperationBackend>;
28
+ /** Information about a function. */
29
+ getFunctions(request: FunctionsRequest): Promise<IOperationBackend>;
30
+ /** Primary keys of a table. */
31
+ getPrimaryKeys(request: PrimaryKeysRequest): Promise<IOperationBackend>;
32
+ /** Foreign-key relationships between two tables. */
33
+ getCrossReference(request: CrossReferenceRequest): Promise<IOperationBackend>;
34
+ /** Close the session. Idempotent. */
35
+ close(): Promise<Status>;
36
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ISessionBackend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ISessionBackend.js","sourceRoot":"","sources":["../../lib/contracts/ISessionBackend.ts"],"names":[],"mappings":""}
@@ -0,0 +1,72 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Internal, non-exported extension of `ConnectionOptions`. Carries M0-only
4
+ * flags that should not appear in the published `.d.ts`.
5
+ *
6
+ * Matches the Python connector pattern: there, `use_kernel` is consumed via
7
+ * `kwargs.get("use_kernel", False)` and is intentionally absent from the typed
8
+ * signature (see `databricks-sql-python/src/databricks/sql/session.py`).
9
+ *
10
+ * Callers cast `ConnectionOptions` to this type *only* at the read site
11
+ * inside the driver; user code that wants to set `useKernel` may still do so
12
+ * via an untyped object literal — the option is not part of the public
13
+ * contract and may be removed without notice.
14
+ */
15
+ export interface InternalConnectionOptions {
16
+ /**
17
+ * Opt-in flag to dispatch through the Statement Execution API (SEA)
18
+ * backend instead of the default Thrift backend. Defaults to `false`.
19
+ * @internal Not stable; M0 stub only.
20
+ */
21
+ useKernel?: boolean;
22
+ /**
23
+ * kernel-only: kernel connection-pool size (`ConnectionOptions.max_connections`).
24
+ * Validated as a positive integer within the napi `u32` range.
25
+ * @internal kernel path only.
26
+ */
27
+ maxConnections?: number;
28
+ /**
29
+ * kernel-only: verify the server's TLS certificate. Secure-by-default — omit
30
+ * to keep full chain + hostname verification; set `false` only to opt into
31
+ * the insecure accept-anything mode. This is the master verify toggle:
32
+ * `false` also subsumes the hostname check (see
33
+ * `checkServerCertificateHostname`). Mirrors the Python connector's
34
+ * `_tls_no_verify` (inverted).
35
+ * @internal kernel path only.
36
+ */
37
+ checkServerCertificate?: boolean;
38
+ /**
39
+ * kernel-only: verify that the server certificate matches the host
40
+ * (hostname-vs-SNI check), independently of full chain validation. Omit
41
+ * to keep the secure default (on); set `false` to skip only the hostname
42
+ * check while still validating the chain — e.g. connecting via an IP
43
+ * literal or a host the cert wasn't issued for. No-op when
44
+ * `checkServerCertificate` is `false` (that disables everything). Mirrors
45
+ * the Python connector's `_tls_verify_hostname`.
46
+ * @internal kernel path only.
47
+ */
48
+ checkServerCertificateHostname?: boolean;
49
+ /**
50
+ * kernel-only: PEM-encoded CA certificate (string or `Buffer`) added to the
51
+ * trust store on top of the system roots — for TLS-inspecting proxies or
52
+ * on-prem internal CAs. Honoured regardless of `checkServerCertificate`.
53
+ * @internal kernel path only.
54
+ */
55
+ customCaCert?: Buffer | string;
56
+ /**
57
+ * kernel-only: PEM-encoded client certificate (string or `Buffer`) for
58
+ * mutual TLS (mTLS). Must be supplied together with `clientKeyPem`; a
59
+ * leaf cert optionally followed by its intermediate chain is accepted.
60
+ * Mirrors the Python connector's `_tls_client_cert_file`.
61
+ * @internal kernel path only.
62
+ */
63
+ clientCertPem?: Buffer | string;
64
+ /**
65
+ * kernel-only: PEM-encoded private key (string or `Buffer`) for the mTLS
66
+ * client certificate. Must be supplied together with `clientCertPem`.
67
+ * For portability supply a PKCS#8 key (`BEGIN PRIVATE KEY`). Mirrors the
68
+ * Python connector's `_tls_client_cert_key_file`.
69
+ * @internal kernel path only.
70
+ */
71
+ clientKeyPem?: Buffer | string;
72
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=InternalConnectionOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InternalConnectionOptions.js","sourceRoot":"","sources":["../../lib/contracts/InternalConnectionOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Backend-neutral operation state. Mirrors the kernel/pyo3 `StatementStatus`
3
+ * and the Python connector's `CommandState`, so a kernel `IOperationBackend`
4
+ * implementer can return these without depending on the Thrift wire enum.
5
+ *
6
+ * Thrift mapping (in `ThriftOperationBackend.adaptOperationStatus`):
7
+ * - INITIALIZED_STATE, PENDING_STATE → Pending
8
+ * - RUNNING_STATE → Running
9
+ * - FINISHED_STATE → Succeeded
10
+ * - CANCELED_STATE → Cancelled
11
+ * - CLOSED_STATE → Closed
12
+ * - ERROR_STATE, TIMEDOUT_STATE → Failed
13
+ * - UKNOWN_STATE / anything else → Unknown
14
+ */
15
+ export declare enum OperationState {
16
+ Pending = "Pending",
17
+ Running = "Running",
18
+ Succeeded = "Succeeded",
19
+ Failed = "Failed",
20
+ Cancelled = "Cancelled",
21
+ Closed = "Closed",
22
+ Unknown = "Unknown"
23
+ }
24
+ /**
25
+ * Neutral status snapshot returned by `IOperationBackend.status()`. Backends
26
+ * adapt their wire format at the boundary; callers in `DBSQLOperation` and
27
+ * `IOperationBackend.waitUntilReady` switch on `state` alone.
28
+ *
29
+ * Fields beyond `state` are best-effort and may be undefined depending on
30
+ * what the backend exposes.
31
+ */
32
+ export interface OperationStatus {
33
+ /** Current operation state. */
34
+ state: OperationState;
35
+ /**
36
+ * Whether this operation has produced (or is producing) a result set.
37
+ * Some backends only know this after the operation reaches a terminal
38
+ * state — undefined means "no signal from this backend".
39
+ */
40
+ hasResultSet?: boolean;
41
+ /** Human-readable error/display message, if the backend supplied one. */
42
+ errorMessage?: string;
43
+ /** SQL state code (e.g. "42000"), if available. */
44
+ sqlState?: string;
45
+ /**
46
+ * Opaque progress payload as returned by the backend when callers pass
47
+ * `progress: true`. Treated as untyped by the facade — passed through
48
+ * to `WaitUntilReadyOptions.callback` for the consumer to interpret.
49
+ */
50
+ progressUpdateResponse?: unknown;
51
+ /**
52
+ * Number of rows modified by a DML statement (UPDATE / INSERT / DELETE /
53
+ * MERGE). `undefined`/`null` for SELECT and on backends/warehouses that do
54
+ * not surface the counter. Mirrors Thrift's
55
+ * `TGetOperationStatusResp.numModifiedRows`.
56
+ */
57
+ numModifiedRows?: number | null;
58
+ /**
59
+ * Server-supplied user-facing message, when the backend exposes one. Mirrors
60
+ * Thrift's `TGetOperationStatusResp.displayMessage`. May contain SQL
61
+ * fragments or parameter values — treat as potentially sensitive.
62
+ */
63
+ displayMessage?: string | null;
64
+ /**
65
+ * Server-supplied diagnostic detail (multi-line operator / stack context),
66
+ * when available. Mirrors Thrift's `TGetOperationStatusResp.diagnosticInfo`.
67
+ * For support surfaces, not user-facing.
68
+ */
69
+ diagnosticInfo?: string | null;
70
+ /**
71
+ * Server-supplied JSON blob with extended error details, when available.
72
+ * Mirrors Thrift's `TGetOperationStatusResp.errorDetailsJson`. Pass-through
73
+ * string — callers parse with `JSON.parse` if they need structured access.
74
+ */
75
+ errorDetailsJson?: string | null;
76
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OperationState = void 0;
4
+ /**
5
+ * Backend-neutral operation state. Mirrors the kernel/pyo3 `StatementStatus`
6
+ * and the Python connector's `CommandState`, so a kernel `IOperationBackend`
7
+ * implementer can return these without depending on the Thrift wire enum.
8
+ *
9
+ * Thrift mapping (in `ThriftOperationBackend.adaptOperationStatus`):
10
+ * - INITIALIZED_STATE, PENDING_STATE → Pending
11
+ * - RUNNING_STATE → Running
12
+ * - FINISHED_STATE → Succeeded
13
+ * - CANCELED_STATE → Cancelled
14
+ * - CLOSED_STATE → Closed
15
+ * - ERROR_STATE, TIMEDOUT_STATE → Failed
16
+ * - UKNOWN_STATE / anything else → Unknown
17
+ */
18
+ var OperationState;
19
+ (function (OperationState) {
20
+ OperationState["Pending"] = "Pending";
21
+ OperationState["Running"] = "Running";
22
+ OperationState["Succeeded"] = "Succeeded";
23
+ OperationState["Failed"] = "Failed";
24
+ OperationState["Cancelled"] = "Cancelled";
25
+ OperationState["Closed"] = "Closed";
26
+ OperationState["Unknown"] = "Unknown";
27
+ })(OperationState = exports.OperationState || (exports.OperationState = {}));
28
+ //# sourceMappingURL=OperationStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OperationStatus.js","sourceRoot":"","sources":["../../lib/contracts/OperationStatus.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,IAAY,cAQX;AARD,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,qCAAmB,CAAA;IACnB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;IACjB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;IACjB,qCAAmB,CAAA;AACrB,CAAC,EARW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAQzB"}
@@ -0,0 +1,34 @@
1
+ /// <reference types="node" />
2
+ import { TTableSchema } from '../../thrift/TCLIService_types';
3
+ /**
4
+ * Backend-neutral result-format taxonomy. Mirrors the three on-wire shapes
5
+ * `ThriftOperationBackend` actually dispatches on (`COLUMN_BASED_SET`,
6
+ * `ARROW_BASED_SET`, `URL_BASED_SET`); a kernel implementer surfaces the same
7
+ * three so result-handling stays format-agnostic.
8
+ */
9
+ export declare enum ResultFormat {
10
+ ColumnBased = "COLUMN_BASED",
11
+ ArrowBased = "ARROW_BASED",
12
+ UrlBased = "URL_BASED"
13
+ }
14
+ /**
15
+ * Neutral result-set metadata returned by `IOperationBackend.getResultMetadata()`.
16
+ *
17
+ * `schema` keeps the Thrift `TTableSchema` shape for now because the public
18
+ * `DBSQLOperation.getSchema()` and `getMetadata()` already expose it on
19
+ * `IOperation`; carrying it across the boundary preserves back-compat. The
20
+ * kernel backend will adapt its column descriptors into the same shape until
21
+ * the public IOperation surface is migrated in a later PR.
22
+ */
23
+ export interface ResultMetadata {
24
+ /** Column schema; null if the operation has no result set. */
25
+ schema?: TTableSchema;
26
+ /** Wire format the result handler should dispatch on. */
27
+ resultFormat: ResultFormat;
28
+ /** Whether the result payload is LZ4-compressed. */
29
+ lz4Compressed?: boolean;
30
+ /** Optional Arrow IPC schema bytes (for ARROW_BASED / URL_BASED formats). */
31
+ arrowSchema?: Buffer;
32
+ /** True iff the operation is a staging (PUT/GET/REMOVE) operation. */
33
+ isStagingOperation: boolean;
34
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResultFormat = void 0;
4
+ /**
5
+ * Backend-neutral result-format taxonomy. Mirrors the three on-wire shapes
6
+ * `ThriftOperationBackend` actually dispatches on (`COLUMN_BASED_SET`,
7
+ * `ARROW_BASED_SET`, `URL_BASED_SET`); a kernel implementer surfaces the same
8
+ * three so result-handling stays format-agnostic.
9
+ */
10
+ var ResultFormat;
11
+ (function (ResultFormat) {
12
+ ResultFormat["ColumnBased"] = "COLUMN_BASED";
13
+ ResultFormat["ArrowBased"] = "ARROW_BASED";
14
+ ResultFormat["UrlBased"] = "URL_BASED";
15
+ })(ResultFormat = exports.ResultFormat || (exports.ResultFormat = {}));
16
+ //# sourceMappingURL=ResultMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResultMetadata.js","sourceRoot":"","sources":["../../lib/contracts/ResultMetadata.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,4CAA4B,CAAA;IAC5B,0CAA0B,CAAA;IAC1B,sCAAsB,CAAA;AACxB,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB"}
@@ -1,3 +1,4 @@
1
1
  import HiveDriverError from './HiveDriverError';
2
2
  export default class AuthenticationError extends HiveDriverError {
3
+ constructor(message?: string);
3
4
  }
@@ -5,6 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const HiveDriverError_1 = __importDefault(require("./HiveDriverError"));
7
7
  class AuthenticationError extends HiveDriverError_1.default {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = 'AuthenticationError';
11
+ }
8
12
  }
9
13
  exports.default = AuthenticationError;
10
14
  //# sourceMappingURL=AuthenticationError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuthenticationError.js","sourceRoot":"","sources":["../../lib/errors/AuthenticationError.ts"],"names":[],"mappings":";;;;;AAAA,wEAAgD;AAEhD,MAAqB,mBAAoB,SAAQ,yBAAe;CAAG;AAAnE,sCAAmE"}
1
+ {"version":3,"file":"AuthenticationError.js","sourceRoot":"","sources":["../../lib/errors/AuthenticationError.ts"],"names":[],"mappings":";;;;;AAAA,wEAAgD;AAEhD,MAAqB,mBAAoB,SAAQ,yBAAe;IAC9D,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,sCAKC"}
package/dist/index.d.ts CHANGED
@@ -14,6 +14,8 @@ import { LogLevel } from './contracts/IDBSQLLogger';
14
14
  export type { default as ITokenProvider } from './connection/auth/tokenProvider/ITokenProvider';
15
15
  export { CircuitBreakerOpenError, CIRCUIT_BREAKER_OPEN_CODE } from './telemetry/CircuitBreaker';
16
16
  export { TelemetryTerminalError } from './telemetry/DatabricksTelemetryExporter';
17
+ export { TelemetryEventType, DEFAULT_TELEMETRY_CONFIG } from './telemetry/types';
18
+ export type { TelemetryEvent, TelemetryMetric, TelemetryConfiguration, StatementMetrics, DriverConfiguration, } from './telemetry/types';
17
19
  export declare const auth: {
18
20
  PlainHttpAuthentication: typeof PlainHttpAuthentication;
19
21
  Token: typeof Token;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.LogLevel = exports.DBSQLLogger = exports.DBSQLParameterType = exports.DBSQLParameter = exports.DBSQLSession = exports.DBSQLClient = exports.utils = exports.thrift = exports.connections = exports.TProtocolExceptionType = exports.TProtocolException = exports.TApplicationExceptionType = exports.TApplicationException = exports.TException = exports.auth = exports.TelemetryTerminalError = exports.CIRCUIT_BREAKER_OPEN_CODE = exports.CircuitBreakerOpenError = void 0;
6
+ exports.LogLevel = exports.DBSQLLogger = exports.DBSQLParameterType = exports.DBSQLParameter = exports.DBSQLSession = exports.DBSQLClient = exports.utils = exports.thrift = exports.connections = exports.TProtocolExceptionType = exports.TProtocolException = exports.TApplicationExceptionType = exports.TApplicationException = exports.TException = exports.auth = exports.DEFAULT_TELEMETRY_CONFIG = exports.TelemetryEventType = exports.TelemetryTerminalError = exports.CIRCUIT_BREAKER_OPEN_CODE = exports.CircuitBreakerOpenError = void 0;
7
7
  // Don't move this import - it should be placed before any other
8
8
  require("./polyfills");
9
9
  const thrift_1 = require("thrift");
@@ -24,13 +24,17 @@ const HttpConnection_1 = __importDefault(require("./connection/connections/HttpC
24
24
  const utils_1 = require("./utils");
25
25
  const IDBSQLLogger_1 = require("./contracts/IDBSQLLogger");
26
26
  Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return IDBSQLLogger_1.LogLevel; } });
27
- // Re-export telemetry error classes so consumers can instanceof-check rather
28
- // than string-matching error messages.
29
27
  var CircuitBreaker_1 = require("./telemetry/CircuitBreaker");
30
28
  Object.defineProperty(exports, "CircuitBreakerOpenError", { enumerable: true, get: function () { return CircuitBreaker_1.CircuitBreakerOpenError; } });
31
29
  Object.defineProperty(exports, "CIRCUIT_BREAKER_OPEN_CODE", { enumerable: true, get: function () { return CircuitBreaker_1.CIRCUIT_BREAKER_OPEN_CODE; } });
32
30
  var DatabricksTelemetryExporter_1 = require("./telemetry/DatabricksTelemetryExporter");
33
31
  Object.defineProperty(exports, "TelemetryTerminalError", { enumerable: true, get: function () { return DatabricksTelemetryExporter_1.TelemetryTerminalError; } });
32
+ // Telemetry event/metric/config shapes for consumers that want to inspect
33
+ // telemetry payloads or pre-validate config. The emitter, aggregator, and
34
+ // per-host client are deliberately not re-exported — they are internal.
35
+ var types_1 = require("./telemetry/types");
36
+ Object.defineProperty(exports, "TelemetryEventType", { enumerable: true, get: function () { return types_1.TelemetryEventType; } });
37
+ Object.defineProperty(exports, "DEFAULT_TELEMETRY_CONFIG", { enumerable: true, get: function () { return types_1.DEFAULT_TELEMETRY_CONFIG; } });
34
38
  exports.auth = {
35
39
  PlainHttpAuthentication: PlainHttpAuthentication_1.default,
36
40
  // Token provider classes for custom authentication
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAgE;AAChE,uBAAqB;AAErB,mCAAgC;AAChC,wEAAgD;AAChD,oFAA4D;AAC5D,gEAAwC;AAoD/B,sBApDF,qBAAW,CAoDE;AAnDpB,kEAA0C;AAmDpB,uBAnDf,sBAAY,CAmDe;AAlDlC,qDAAsE;AAkDlC,+FAlD3B,+BAAc,OAkD2B;AAAE,mGAlD3B,mCAAkB,OAkD2B;AAjDtE,gEAAwC;AAiDgC,sBAjDjE,qBAAW,CAiDiE;AAhDnF,wGAAgF;AAChF,mEAMyC;AACzC,6FAAqE;AACrE,mCAAyC;AACzC,2DAAoD;AAsCiC,yFAtC5E,uBAAQ,OAsC4E;AAjC7F,6EAA6E;AAC7E,uCAAuC;AACvC,6DAAgG;AAAvF,yHAAA,uBAAuB,OAAA;AAAE,2HAAA,yBAAyB,OAAA;AAC3D,uFAAiF;AAAxE,qIAAA,sBAAsB,OAAA;AAElB,QAAA,IAAI,GAAG;IAClB,uBAAuB,EAAvB,iCAAuB;IACvB,mDAAmD;IACnD,KAAK,EAAL,qBAAK;IACL,mBAAmB,EAAnB,mCAAmB;IACnB,qBAAqB,EAArB,qCAAqB;IACrB,mBAAmB,EAAnB,mCAAmB;IACnB,kBAAkB,EAAlB,kCAAkB;CACnB,CAAC;AAEF,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,GAChH,eAAM,CAAC;AAEA,gCAAU;AAAE,sDAAqB;AAAE,8DAAyB;AAAE,gDAAkB;AAAE,wDAAsB;AAEpG,QAAA,WAAW,GAAG;IACzB,cAAc,EAAd,wBAAc;CACf,CAAC;AAEW,QAAA,MAAM,GAAG;IACpB,WAAW,EAAX,qBAAW;IACX,iBAAiB,EAAjB,2BAAiB;CAClB,CAAC;AAEW,QAAA,KAAK,GAAG;IACnB,cAAc,EAAd,sBAAc;CACf,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAgE;AAChE,uBAAqB;AAErB,mCAAgC;AAChC,wEAAgD;AAChD,oFAA4D;AAC5D,gEAAwC;AA8D/B,sBA9DF,qBAAW,CA8DE;AA7DpB,kEAA0C;AA6DpB,uBA7Df,sBAAY,CA6De;AA5DlC,qDAAsE;AA4DlC,+FA5D3B,+BAAc,OA4D2B;AAAE,mGA5D3B,mCAAkB,OA4D2B;AA3DtE,gEAAwC;AA2DgC,sBA3DjE,qBAAW,CA2DiE;AA1DnF,wGAAgF;AAChF,mEAMyC;AACzC,6FAAqE;AACrE,mCAAyC;AACzC,2DAAoD;AAgDiC,yFAhD5E,uBAAQ,OAgD4E;AA3C7F,6DAAgG;AAAvF,yHAAA,uBAAuB,OAAA;AAAE,2HAAA,yBAAyB,OAAA;AAC3D,uFAAiF;AAAxE,qIAAA,sBAAsB,OAAA;AAE/B,0EAA0E;AAC1E,0EAA0E;AAC1E,wEAAwE;AACxE,2CAAiF;AAAxE,2GAAA,kBAAkB,OAAA;AAAE,iHAAA,wBAAwB,OAAA;AASxC,QAAA,IAAI,GAAG;IAClB,uBAAuB,EAAvB,iCAAuB;IACvB,mDAAmD;IACnD,KAAK,EAAL,qBAAK;IACL,mBAAmB,EAAnB,mCAAmB;IACnB,qBAAqB,EAArB,qCAAqB;IACrB,mBAAmB,EAAnB,mCAAmB;IACnB,kBAAkB,EAAlB,kCAAkB;CACnB,CAAC;AAEF,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,GAChH,eAAM,CAAC;AAEA,gCAAU;AAAE,sDAAqB;AAAE,8DAAyB;AAAE,gDAAkB;AAAE,wDAAsB;AAEpG,QAAA,WAAW,GAAG;IACzB,cAAc,EAAd,wBAAc;CACf,CAAC;AAEW,QAAA,MAAM,GAAG;IACpB,WAAW,EAAX,qBAAW;IACX,iBAAiB,EAAjB,2BAAiB;CAClB,CAAC;AAEW,QAAA,KAAK,GAAG;IACnB,cAAc,EAAd,sBAAc;CACf,CAAC"}
@@ -0,0 +1,54 @@
1
+ /// <reference types="node" />
2
+ import { Schema, TypeMap } from 'apache-arrow';
3
+ import { TTableSchema } from '../../thrift/TCLIService_types';
4
+ /**
5
+ * Sum the row counts of every RecordBatch message in an Arrow IPC
6
+ * stream, WITHOUT materializing the Arrow vector tree.
7
+ *
8
+ * Why this exists: `ArrowResultConverter` consumes `ArrowBatch` objects
9
+ * that carry an explicit `rowCount`, but the kernel's IPC payload only
10
+ * carries per-RecordBatch `length` (no separate total). `KernelResultsProvider`
11
+ * needs that count to build the `ArrowBatch` it hands to the converter —
12
+ * which then re-decodes the same bytes for the actual values.
13
+ *
14
+ * The previous implementation used `RecordBatchReader` and iterated the
15
+ * batches, which calls `_loadVectors` and materializes the full vector
16
+ * tree for every batch just to read `numRows` and discard everything
17
+ * else — ~2x Arrow decode CPU + transient allocation on the fetch hot
18
+ * path. `MessageReader` instead reads only each message's FlatBuffer
19
+ * metadata header (where `RecordBatch.length` lives) and skips the body
20
+ * bytes, so no vectors are decoded here. The converter's later re-decode
21
+ * is the only real materialization.
22
+ *
23
+ * `ipcBytes` must already be Duration-patched (row count is unaffected
24
+ * by the Duration→Int64 rewrite, and the framing is unchanged). Returns
25
+ * 0 for an empty / schema-only stream.
26
+ */
27
+ export declare function countRowsInIpc(ipcBytes: Buffer): number;
28
+ /**
29
+ * Decode an Arrow IPC schema payload (no record batches) into the
30
+ * apache-arrow Schema object.
31
+ */
32
+ export declare function decodeIpcSchema(ipcBytes: Buffer): Schema<TypeMap>;
33
+ /**
34
+ * Pre-process raw IPC bytes from the kernel so they're consumable by
35
+ * `apache-arrow@13`. The current transformation is `Duration → Int64`
36
+ * with the original duration unit preserved in field metadata (see
37
+ * `KernelArrowIpcDurationFix.ts`). Returned bytes are byte-identical to
38
+ * the input when no transformation is needed.
39
+ *
40
+ * Exposed so callers can pre-patch the buffer **once** and pass the
41
+ * result through both `decodeIpcBatch` (for row-count extraction in
42
+ * `KernelResultsProvider`) and `ArrowResultConverter.fetchNext` (which
43
+ * re-decodes the same bytes via `RecordBatchReader.from`). Without
44
+ * this, the converter would re-throw on `Duration` because it never
45
+ * sees the patched bytes.
46
+ */
47
+ export declare function patchIpcBytes(ipcBytes: Buffer): Buffer;
48
+ /**
49
+ * Synthesize a Thrift `TTableSchema` from an Arrow schema decoded out
50
+ * of the kernel's IPC stream. Used by `KernelOperationBackend.getResultMetadata`
51
+ * to drive `ArrowResultConverter.convertThriftTypes` (Phase 2) without
52
+ * changing that code.
53
+ */
54
+ export declare function arrowSchemaToThriftSchema(arrowSchema: Schema<TypeMap>): TTableSchema;