@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.
- package/README.md +12 -0
- package/dist/DBSQLClient.d.ts +102 -0
- package/dist/DBSQLClient.js +541 -55
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLLogger.d.ts +3 -0
- package/dist/DBSQLLogger.js +25 -0
- package/dist/DBSQLLogger.js.map +1 -1
- package/dist/DBSQLOperation.d.ts +67 -17
- package/dist/DBSQLOperation.js +245 -217
- package/dist/DBSQLOperation.js.map +1 -1
- package/dist/DBSQLParameter.d.ts +2 -0
- package/dist/DBSQLParameter.js +63 -7
- package/dist/DBSQLParameter.js.map +1 -1
- package/dist/DBSQLSession.d.ts +24 -16
- package/dist/DBSQLSession.js +77 -268
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js +10 -6
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js.map +1 -1
- package/dist/connection/connections/HttpRetryPolicy.d.ts +3 -0
- package/dist/connection/connections/HttpRetryPolicy.js +116 -21
- package/dist/connection/connections/HttpRetryPolicy.js.map +1 -1
- package/dist/connection/connections/ThriftHttpConnection.js +18 -3
- package/dist/connection/connections/ThriftHttpConnection.js.map +1 -1
- package/dist/contracts/IBackend.d.ts +31 -0
- package/dist/contracts/IBackend.js +3 -0
- package/dist/contracts/IBackend.js.map +1 -0
- package/dist/contracts/IClientContext.d.ts +30 -0
- package/dist/contracts/IDBSQLClient.d.ts +115 -0
- package/dist/contracts/IDBSQLLogger.d.ts +17 -0
- package/dist/contracts/IDBSQLLogger.js.map +1 -1
- package/dist/contracts/IDBSQLSession.d.ts +24 -1
- package/dist/contracts/IOperation.d.ts +10 -1
- package/dist/contracts/IOperationBackend.d.ts +98 -0
- package/dist/contracts/IOperationBackend.js +3 -0
- package/dist/contracts/IOperationBackend.js.map +1 -0
- package/dist/contracts/ISessionBackend.d.ts +36 -0
- package/dist/contracts/ISessionBackend.js +3 -0
- package/dist/contracts/ISessionBackend.js.map +1 -0
- package/dist/contracts/InternalConnectionOptions.d.ts +72 -0
- package/dist/contracts/InternalConnectionOptions.js +3 -0
- package/dist/contracts/InternalConnectionOptions.js.map +1 -0
- package/dist/contracts/OperationStatus.d.ts +76 -0
- package/dist/contracts/OperationStatus.js +28 -0
- package/dist/contracts/OperationStatus.js.map +1 -0
- package/dist/contracts/ResultMetadata.d.ts +34 -0
- package/dist/contracts/ResultMetadata.js +16 -0
- package/dist/contracts/ResultMetadata.js.map +1 -0
- package/dist/errors/AuthenticationError.d.ts +1 -0
- package/dist/errors/AuthenticationError.js +4 -0
- package/dist/errors/AuthenticationError.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/kernel/KernelArrowIpc.d.ts +54 -0
- package/dist/kernel/KernelArrowIpc.js +292 -0
- package/dist/kernel/KernelArrowIpc.js.map +1 -0
- package/dist/kernel/KernelArrowIpcDurationFix.d.ts +29 -0
- package/dist/kernel/KernelArrowIpcDurationFix.js +605 -0
- package/dist/kernel/KernelArrowIpcDurationFix.js.map +1 -0
- package/dist/kernel/KernelAuth.d.ts +300 -0
- package/dist/kernel/KernelAuth.js +463 -0
- package/dist/kernel/KernelAuth.js.map +1 -0
- package/dist/kernel/KernelBackend.d.ts +53 -0
- package/dist/kernel/KernelBackend.js +164 -0
- package/dist/kernel/KernelBackend.js.map +1 -0
- package/dist/kernel/KernelErrorMapping.d.ts +109 -0
- package/dist/kernel/KernelErrorMapping.js +249 -0
- package/dist/kernel/KernelErrorMapping.js.map +1 -0
- package/dist/kernel/KernelInputValidation.d.ts +16 -0
- package/dist/kernel/KernelInputValidation.js +49 -0
- package/dist/kernel/KernelInputValidation.js.map +1 -0
- package/dist/kernel/KernelLogging.d.ts +63 -0
- package/dist/kernel/KernelLogging.js +128 -0
- package/dist/kernel/KernelLogging.js.map +1 -0
- package/dist/kernel/KernelNativeLoader.d.ts +77 -0
- package/dist/kernel/KernelNativeLoader.js +178 -0
- package/dist/kernel/KernelNativeLoader.js.map +1 -0
- package/dist/kernel/KernelOperationBackend.d.ts +154 -0
- package/dist/kernel/KernelOperationBackend.js +640 -0
- package/dist/kernel/KernelOperationBackend.js.map +1 -0
- package/dist/kernel/KernelOperationLifecycle.d.ts +130 -0
- package/dist/kernel/KernelOperationLifecycle.js +245 -0
- package/dist/kernel/KernelOperationLifecycle.js.map +1 -0
- package/dist/kernel/KernelPositionalParams.d.ts +16 -0
- package/dist/kernel/KernelPositionalParams.js +120 -0
- package/dist/kernel/KernelPositionalParams.js.map +1 -0
- package/dist/kernel/KernelResultsProvider.d.ts +44 -0
- package/dist/kernel/KernelResultsProvider.js +102 -0
- package/dist/kernel/KernelResultsProvider.js.map +1 -0
- package/dist/kernel/KernelServerInfo.d.ts +44 -0
- package/dist/kernel/KernelServerInfo.js +73 -0
- package/dist/kernel/KernelServerInfo.js.map +1 -0
- package/dist/kernel/KernelSessionBackend.d.ts +100 -0
- package/dist/kernel/KernelSessionBackend.js +384 -0
- package/dist/kernel/KernelSessionBackend.js.map +1 -0
- package/dist/result/ArrowResultConverter.d.ts +31 -2
- package/dist/result/ArrowResultConverter.js +226 -14
- package/dist/result/ArrowResultConverter.js.map +1 -1
- package/dist/result/CloudFetchResultHandler.d.ts +8 -1
- package/dist/result/CloudFetchResultHandler.js +64 -10
- package/dist/result/CloudFetchResultHandler.js.map +1 -1
- package/dist/result/RowSetProvider.d.ts +8 -1
- package/dist/result/RowSetProvider.js +110 -1
- package/dist/result/RowSetProvider.js.map +1 -1
- package/dist/telemetry/DatabricksTelemetryExporter.js +101 -34
- package/dist/telemetry/DatabricksTelemetryExporter.js.map +1 -1
- package/dist/telemetry/FeatureFlagCache.js +10 -4
- package/dist/telemetry/FeatureFlagCache.js.map +1 -1
- package/dist/telemetry/MetricsAggregator.d.ts +38 -0
- package/dist/telemetry/MetricsAggregator.js +249 -14
- package/dist/telemetry/MetricsAggregator.js.map +1 -1
- package/dist/telemetry/TelemetryClient.d.ts +94 -14
- package/dist/telemetry/TelemetryClient.js +252 -20
- package/dist/telemetry/TelemetryClient.js.map +1 -1
- package/dist/telemetry/TelemetryClientProvider.d.ts +28 -33
- package/dist/telemetry/TelemetryClientProvider.js +58 -52
- package/dist/telemetry/TelemetryClientProvider.js.map +1 -1
- package/dist/telemetry/TelemetryEventEmitter.d.ts +52 -26
- package/dist/telemetry/TelemetryEventEmitter.js +88 -109
- package/dist/telemetry/TelemetryEventEmitter.js.map +1 -1
- package/dist/telemetry/{urlUtils.d.ts → telemetryTypeMappers.d.ts} +8 -5
- package/dist/telemetry/telemetryTypeMappers.js +72 -0
- package/dist/telemetry/telemetryTypeMappers.js.map +1 -0
- package/dist/telemetry/telemetryUtils.d.ts +14 -0
- package/dist/telemetry/telemetryUtils.js +52 -1
- package/dist/telemetry/telemetryUtils.js.map +1 -1
- package/dist/telemetry/types.d.ts +48 -1
- package/dist/telemetry/types.js +5 -2
- package/dist/telemetry/types.js.map +1 -1
- package/dist/thrift-backend/ThriftBackend.d.ts +17 -0
- package/dist/thrift-backend/ThriftBackend.js +80 -0
- package/dist/thrift-backend/ThriftBackend.js.map +1 -0
- package/dist/thrift-backend/ThriftOperationBackend.d.ts +70 -0
- package/dist/thrift-backend/ThriftOperationBackend.js +330 -0
- package/dist/thrift-backend/ThriftOperationBackend.js.map +1 -0
- package/dist/thrift-backend/ThriftSessionBackend.d.ts +36 -0
- package/dist/thrift-backend/ThriftSessionBackend.js +266 -0
- package/dist/thrift-backend/ThriftSessionBackend.js.map +1 -0
- package/dist/thrift-backend/wireSynthesis.d.ts +30 -0
- package/dist/thrift-backend/wireSynthesis.js +128 -0
- package/dist/thrift-backend/wireSynthesis.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/native/kernel/README.md +97 -0
- package/native/kernel/index.d.ts +1069 -0
- package/native/kernel/index.js +325 -0
- package/package.json +14 -3
- package/dist/telemetry/urlUtils.js +0 -35
- package/dist/telemetry/urlUtils.js.map +0 -1
|
@@ -29,6 +29,26 @@ function delay(milliseconds) {
|
|
|
29
29
|
setTimeout(() => resolve(), milliseconds);
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
+
// Transient network error codes worth retrying. Aligned with the OS-level errno set
|
|
33
|
+
// surfaced by Node's `http`/`https` (and `node-fetch` via `system` FetchError type)
|
|
34
|
+
// when an in-flight request fails before/while delivering a response. Matches the
|
|
35
|
+
// classes of errors that the Python (urllib3) and JDBC (Apache HttpClient) drivers
|
|
36
|
+
// retry by default at the connection layer.
|
|
37
|
+
const RETRYABLE_NETWORK_ERROR_CODES = new Set([
|
|
38
|
+
'ECONNRESET',
|
|
39
|
+
'ECONNREFUSED',
|
|
40
|
+
'ETIMEDOUT',
|
|
41
|
+
'EHOSTUNREACH',
|
|
42
|
+
'ENETUNREACH',
|
|
43
|
+
'EPIPE',
|
|
44
|
+
'ENOTFOUND',
|
|
45
|
+
'EAI_AGAIN',
|
|
46
|
+
]);
|
|
47
|
+
// Fallback message patterns for errors that don't carry an errno. node-fetch surfaces
|
|
48
|
+
// "socket hang up" as a generic FetchError, and "Premature close" when the response
|
|
49
|
+
// body stream closes before all data is received — both occur regularly when a
|
|
50
|
+
// keep-alive TCP connection is silently dropped by an intermediate load balancer.
|
|
51
|
+
const RETRYABLE_NETWORK_ERROR_MESSAGE_RE = /socket hang up|premature close|aborted/i;
|
|
32
52
|
class HttpRetryPolicy {
|
|
33
53
|
constructor(context) {
|
|
34
54
|
this.context = context;
|
|
@@ -37,34 +57,109 @@ class HttpRetryPolicy {
|
|
|
37
57
|
}
|
|
38
58
|
async shouldRetry(details) {
|
|
39
59
|
if (this.isRetryable(details)) {
|
|
40
|
-
|
|
41
|
-
// Don't retry if overall retry timeout exceeded
|
|
42
|
-
const timeoutExceeded = Date.now() - this.startTime >= clientConfig.retriesTimeout;
|
|
43
|
-
if (timeoutExceeded) {
|
|
44
|
-
throw new RetryError_1.default(RetryError_1.RetryErrorCode.TimeoutExceeded, details);
|
|
45
|
-
}
|
|
46
|
-
this.attempt += 1;
|
|
47
|
-
// Don't retry if max attempts count reached
|
|
48
|
-
const attemptsExceeded = this.attempt >= clientConfig.retryMaxAttempts;
|
|
49
|
-
if (attemptsExceeded) {
|
|
50
|
-
throw new RetryError_1.default(RetryError_1.RetryErrorCode.AttemptsExceeded, details);
|
|
51
|
-
}
|
|
52
|
-
// If possible, use `Retry-After` header as a floor for a backoff algorithm
|
|
53
|
-
const retryAfterHeader = this.getRetryAfterHeader(details, clientConfig.retryDelayMin);
|
|
54
|
-
const retryAfter = this.getBackoffDelay(this.attempt, retryAfterHeader !== null && retryAfterHeader !== void 0 ? retryAfterHeader : clientConfig.retryDelayMin, clientConfig.retryDelayMax);
|
|
55
|
-
return { shouldRetry: true, retryAfter };
|
|
60
|
+
return this.computeRetry(details);
|
|
56
61
|
}
|
|
57
62
|
return { shouldRetry: false };
|
|
58
63
|
}
|
|
59
64
|
async invokeWithRetry(operation) {
|
|
60
65
|
for (;;) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
// Capture either the resolved response or the thrown error so the
|
|
67
|
+
// retry-decision logic below can flow without an early `continue` and
|
|
68
|
+
// share one backoff site between both paths.
|
|
69
|
+
let outcome;
|
|
70
|
+
try {
|
|
71
|
+
// eslint-disable-next-line no-await-in-loop
|
|
72
|
+
const details = await operation();
|
|
73
|
+
outcome = { ok: true, details };
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
outcome = { ok: false, error };
|
|
77
|
+
}
|
|
78
|
+
if (outcome.ok) {
|
|
79
|
+
// eslint-disable-next-line no-await-in-loop
|
|
80
|
+
const status = await this.shouldRetry(outcome.details);
|
|
81
|
+
if (!status.shouldRetry) {
|
|
82
|
+
return outcome.details;
|
|
83
|
+
}
|
|
84
|
+
// eslint-disable-next-line no-await-in-loop
|
|
85
|
+
await delay(status.retryAfter);
|
|
65
86
|
}
|
|
66
|
-
|
|
87
|
+
else {
|
|
88
|
+
// The operation threw before producing a response. This is typically a
|
|
89
|
+
// transient network failure (stale keep-alive socket reset by a load
|
|
90
|
+
// balancer, DNS hiccup, truncated response body, etc.). The status-code-
|
|
91
|
+
// driven `shouldRetry` path can't see these because there's no `Response`
|
|
92
|
+
// to inspect, so we have a separate decision point here. Non-network
|
|
93
|
+
// errors (programmer errors, config errors, RetryError raised by our
|
|
94
|
+
// own attempts/timeout budget) are re-thrown unchanged.
|
|
95
|
+
if (!this.isRetryableNetworkError(outcome.error)) {
|
|
96
|
+
throw outcome.error;
|
|
97
|
+
}
|
|
98
|
+
// eslint-disable-next-line no-await-in-loop
|
|
99
|
+
const status = await this.computeNetworkErrorRetry(outcome.error);
|
|
100
|
+
if (!status.shouldRetry) {
|
|
101
|
+
throw outcome.error;
|
|
102
|
+
}
|
|
103
|
+
// eslint-disable-next-line no-await-in-loop
|
|
104
|
+
await delay(status.retryAfter);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Shared budgeting logic — bumps the attempt counter, enforces overall retries
|
|
109
|
+
// timeout/max attempts, and computes the next backoff. Used by both the HTTP
|
|
110
|
+
// status-code path (`shouldRetry`) and the network-error path
|
|
111
|
+
// (`computeNetworkErrorRetry`) so they share a single attempt budget.
|
|
112
|
+
computeRetry(details) {
|
|
113
|
+
const clientConfig = this.context.getConfig();
|
|
114
|
+
// Don't retry if overall retry timeout exceeded
|
|
115
|
+
const timeoutExceeded = Date.now() - this.startTime >= clientConfig.retriesTimeout;
|
|
116
|
+
if (timeoutExceeded) {
|
|
117
|
+
throw new RetryError_1.default(RetryError_1.RetryErrorCode.TimeoutExceeded, details);
|
|
118
|
+
}
|
|
119
|
+
this.attempt += 1;
|
|
120
|
+
// Don't retry if max attempts count reached
|
|
121
|
+
const attemptsExceeded = this.attempt >= clientConfig.retryMaxAttempts;
|
|
122
|
+
if (attemptsExceeded) {
|
|
123
|
+
throw new RetryError_1.default(RetryError_1.RetryErrorCode.AttemptsExceeded, details);
|
|
124
|
+
}
|
|
125
|
+
// If possible, use `Retry-After` header as a floor for a backoff algorithm
|
|
126
|
+
const retryAfterHeader = this.getRetryAfterHeader(details, clientConfig.retryDelayMin);
|
|
127
|
+
const retryAfter = this.getBackoffDelay(this.attempt, retryAfterHeader !== null && retryAfterHeader !== void 0 ? retryAfterHeader : clientConfig.retryDelayMin, clientConfig.retryDelayMax);
|
|
128
|
+
return { shouldRetry: true, retryAfter };
|
|
129
|
+
}
|
|
130
|
+
async computeNetworkErrorRetry(error) {
|
|
131
|
+
const clientConfig = this.context.getConfig();
|
|
132
|
+
const timeoutExceeded = Date.now() - this.startTime >= clientConfig.retriesTimeout;
|
|
133
|
+
if (timeoutExceeded) {
|
|
134
|
+
throw new RetryError_1.default(RetryError_1.RetryErrorCode.TimeoutExceeded, error);
|
|
135
|
+
}
|
|
136
|
+
this.attempt += 1;
|
|
137
|
+
const attemptsExceeded = this.attempt >= clientConfig.retryMaxAttempts;
|
|
138
|
+
if (attemptsExceeded) {
|
|
139
|
+
throw new RetryError_1.default(RetryError_1.RetryErrorCode.AttemptsExceeded, error);
|
|
140
|
+
}
|
|
141
|
+
const retryAfter = this.getBackoffDelay(this.attempt, clientConfig.retryDelayMin, clientConfig.retryDelayMax);
|
|
142
|
+
return { shouldRetry: true, retryAfter };
|
|
143
|
+
}
|
|
144
|
+
isRetryableNetworkError(error) {
|
|
145
|
+
if (!error || typeof error !== 'object') {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
const candidate = error;
|
|
149
|
+
// node-fetch FetchError surfaces low-level network failures with `type: 'system'`
|
|
150
|
+
// and a body-stream timeout with `type: 'body-timeout'`. Both should be retried;
|
|
151
|
+
// `request-timeout` is converted to a Thrift TApplicationException upstream so
|
|
152
|
+
// we don't need to retry it here.
|
|
153
|
+
if (candidate.type === 'system' || candidate.type === 'body-timeout') {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
if (typeof candidate.code === 'string' && RETRYABLE_NETWORK_ERROR_CODES.has(candidate.code)) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
if (typeof candidate.message === 'string' && RETRYABLE_NETWORK_ERROR_MESSAGE_RE.test(candidate.message)) {
|
|
160
|
+
return true;
|
|
67
161
|
}
|
|
162
|
+
return false;
|
|
68
163
|
}
|
|
69
164
|
isRetryable({ response }) {
|
|
70
165
|
const statusCode = response.status;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpRetryPolicy.js","sourceRoot":"","sources":["../../../lib/connection/connections/HttpRetryPolicy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAGA,sEAAqE;AAErE,SAAS,KAAK,CAAC,YAAoB;IACjC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QACnC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAqB,eAAe;IAOlC,YAAY,OAAuB;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,OAA+B;QACtD,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;YAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"HttpRetryPolicy.js","sourceRoot":"","sources":["../../../lib/connection/connections/HttpRetryPolicy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAGA,sEAAqE;AAErE,SAAS,KAAK,CAAC,YAAoB;IACjC,OA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AAa,CAAC,IAAI,EAAE,CAAC;QACzD,IAAI,MAAM,KAAK,EAAE,EAAE;YACjB,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;YAC7B,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE;gBACvC,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;aAClC;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAES,eAAe,CAAC,OAAe,EAAE,QAAgB,EAAE,QAAgB;QAC3E,MAAM,KAAK,GAAG,CAAC,IAAI,OAAO,GAAG,QAAQ,CAAC;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF;AAhLD,kCAgLC"}
|
|
@@ -99,12 +99,24 @@ class ThriftHttpConnection extends events_1.EventEmitter {
|
|
|
99
99
|
},
|
|
100
100
|
body: data,
|
|
101
101
|
};
|
|
102
|
+
// Consume the response body inside the retried block. node-fetch surfaces
|
|
103
|
+
// late-stage failures (TCP RST after headers, "Premature close") as rejections
|
|
104
|
+
// from `response.buffer()`, not from `fetch()`. Reading the body here means
|
|
105
|
+
// the retry policy sees those failures and can retry them like any other
|
|
106
|
+
// transient network error — the body Buffer is captured via closure so the
|
|
107
|
+
// post-retry caller still gets it.
|
|
108
|
+
let responseBuffer;
|
|
102
109
|
this.getThriftMethodName(data)
|
|
103
110
|
.then((thriftMethod) => this.getRetryPolicy(thriftMethod))
|
|
104
111
|
.then((retryPolicy) => {
|
|
105
|
-
const makeRequest = () => {
|
|
112
|
+
const makeRequest = async () => {
|
|
113
|
+
responseBuffer = undefined;
|
|
106
114
|
const request = new node_fetch_1.Request(this.url, requestConfig);
|
|
107
|
-
|
|
115
|
+
const response = await (0, node_fetch_1.default)(request);
|
|
116
|
+
if (response.status === 200) {
|
|
117
|
+
responseBuffer = await response.buffer();
|
|
118
|
+
}
|
|
119
|
+
return { request, response };
|
|
108
120
|
};
|
|
109
121
|
return retryPolicy.invokeWithRetry(makeRequest);
|
|
110
122
|
})
|
|
@@ -112,7 +124,10 @@ class ThriftHttpConnection extends events_1.EventEmitter {
|
|
|
112
124
|
if (response.status !== 200) {
|
|
113
125
|
throw new THTTPException(response);
|
|
114
126
|
}
|
|
115
|
-
|
|
127
|
+
// `responseBuffer` is always set when status is 200, since `makeRequest`
|
|
128
|
+
// assigns it before resolving in that branch and the retry loop only
|
|
129
|
+
// returns a fulfilled response (failures are thrown).
|
|
130
|
+
return responseBuffer;
|
|
116
131
|
})
|
|
117
132
|
.then((buffer) => {
|
|
118
133
|
this.transport.receiver((transportWithData) => this.handleThriftResponse(transportWithData), seqId)(buffer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThriftHttpConnection.js","sourceRoot":"","sources":["../../../lib/connection/connections/ThriftHttpConnection.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,mCAAsC;AACtC,mCAAkH;AAClH,yDAA4F;AAC5F,wEAAwE;AACxE,2HAAgG;AAGhG,wEAAgD;AAEhD,MAAa,cAAe,SAAQ,eAAM,CAAC,qBAAqB;IAK9D,YAAY,QAAkB;QAC5B,KAAK,CACH,eAAM,CAAC,yBAAyB,CAAC,cAAc,EAC/C,oDAAoD,QAAQ,CAAC,MAAM,EAAE,CACtE,CAAC;QACF,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAbD,wCAaC;AAuBD,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,oBAAoB;IACpB,iBAAiB;IACjB,gBAAgB;IAChB,sBAAsB;IACtB,cAAc;IACd,SAAS;IACT,aAAa;IACb,aAAa;IACb,YAAY;IACZ,WAAW;IACX,eAAe;IACf,YAAY;IACZ,cA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,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;aACzD,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;YACpB,MAAM,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"ThriftHttpConnection.js","sourceRoot":"","sources":["../../../lib/connection/connections/ThriftHttpConnection.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,mCAAsC;AACtC,mCAAkH;AAClH,yDAA4F;AAC5F,wEAAwE;AACxE,2HAAgG;AAGhG,wEAAgD;AAEhD,MAAa,cAAe,SAAQ,eAAM,CAAC,qBAAqB;IAK9D,YAAY,QAAkB;QAC5B,KAAK,CACH,eAAM,CAAC,yBAAyB,CAAC,cAAc,EAC/C,oDAAoD,QAAQ,CAAC,MAAM,EAAE,CACtE,CAAC;QACF,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAbD,wCAaC;AAuBD,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,oBAAoB;IACpB,iBAAiB;IACjB,gBAAgB;IAChB,sBAAsB;IACtB,cAAc;IACd,SAAS;IACT,aAAa;IACb,aAAa;IACb,YAAY;IACZ,WAAW;IACX,eAAe;IACf,YAAY;IACZ,cAAc;IACd,gBAAgB;IAChB,mBAAmB;CACpB,CAAC,CAAC;AAEH,MAAqB,oBAAqB,SAAQ,qBAAY;IAgB5D,YAAY,OAAoC,EAAE,SAAsB,EAAE;;QACxE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,2BAAkB,CAAC;QACzD,IAAI,CAA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
|
|
2
|
+
import ISessionBackend from './ISessionBackend';
|
|
3
|
+
/**
|
|
4
|
+
* Top-level backend dispatch handle. One instance per `DBSQLClient`,
|
|
5
|
+
* chosen at `connect()` time based on the `useKernel` flag and never
|
|
6
|
+
* re-selected per-call.
|
|
7
|
+
*/
|
|
8
|
+
export default interface IBackend {
|
|
9
|
+
/**
|
|
10
|
+
* Establish backend-level state before any session is opened. Implementations
|
|
11
|
+
* consume `options` to build backend-specific connection parameters (e.g. the
|
|
12
|
+
* kernel backend derives napi-binding `KernelNativeConnectionOptions` from the auth
|
|
13
|
+
* + host fields here). Transport-layer connection providers are owned by
|
|
14
|
+
* `DBSQLClient` (via `IClientContext`) and exposed to backends through
|
|
15
|
+
* constructor injection.
|
|
16
|
+
*/
|
|
17
|
+
connect(options: ConnectionOptions): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Open a session. Returned `ISessionBackend` is owned by the caller
|
|
20
|
+
* and torn down via its own `close()`.
|
|
21
|
+
*/
|
|
22
|
+
openSession(request: OpenSessionRequest): Promise<ISessionBackend>;
|
|
23
|
+
/**
|
|
24
|
+
* Backend-level teardown. Transport-layer cleanup (connection provider,
|
|
25
|
+
* thrift client, auth provider) is owned by `DBSQLClient` and runs
|
|
26
|
+
* after this returns. Implementations release backend-internal resources
|
|
27
|
+
* here, and MUST be safe to call on a partially-initialized backend
|
|
28
|
+
* (i.e. after a failed `connect()`).
|
|
29
|
+
*/
|
|
30
|
+
close(): Promise<void>;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IBackend.js","sourceRoot":"","sources":["../../lib/contracts/IBackend.ts"],"names":[],"mappings":""}
|
|
@@ -2,6 +2,9 @@ import IDBSQLLogger from './IDBSQLLogger';
|
|
|
2
2
|
import IDriver from './IDriver';
|
|
3
3
|
import IConnectionProvider from '../connection/contracts/IConnectionProvider';
|
|
4
4
|
import IThriftClient from './IThriftClient';
|
|
5
|
+
import IAuthentication from '../connection/contracts/IAuthentication';
|
|
6
|
+
import type TelemetryEventEmitter from '../telemetry/TelemetryEventEmitter';
|
|
7
|
+
import type MetricsAggregator from '../telemetry/MetricsAggregator';
|
|
5
8
|
export interface ClientConfig {
|
|
6
9
|
directResultsDefaultMaxRows: number;
|
|
7
10
|
fetchChunkDefaultMaxRows: number;
|
|
@@ -17,6 +20,7 @@ export interface ClientConfig {
|
|
|
17
20
|
cloudFetchSpeedThresholdMBps: number;
|
|
18
21
|
useLZ4Compression: boolean;
|
|
19
22
|
enableMetricViewMetadata?: boolean;
|
|
23
|
+
preserveBigNumericPrecision?: boolean;
|
|
20
24
|
telemetryEnabled?: boolean;
|
|
21
25
|
telemetryBatchSize?: number;
|
|
22
26
|
telemetryFlushIntervalMs?: number;
|
|
@@ -30,7 +34,28 @@ export interface ClientConfig {
|
|
|
30
34
|
telemetryMaxPendingMetrics?: number;
|
|
31
35
|
telemetryMaxErrorsPerStatement?: number;
|
|
32
36
|
telemetryStatementTtlMs?: number;
|
|
37
|
+
telemetryCloseTimeoutMs?: number;
|
|
38
|
+
telemetryMaxStatementMetrics?: number;
|
|
39
|
+
/**
|
|
40
|
+
* If `true`, MetricsAggregator installs a `process.on('beforeExit')` hook
|
|
41
|
+
* that triggers a synchronous-as-possible flush before Node.js shuts down.
|
|
42
|
+
* Mitigates data loss when application code calls `process.exit(0)` without
|
|
43
|
+
* awaiting `client.close()`. Default `false` because adding a `beforeExit`
|
|
44
|
+
* listener changes process-exit semantics for hosts that monkey-patch
|
|
45
|
+
* `process.exit` (e.g. some test runners).
|
|
46
|
+
*/
|
|
47
|
+
telemetryFlushOnExit?: boolean;
|
|
33
48
|
userAgentEntry?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Extra HTTP headers attached to driver-owned out-of-band requests
|
|
51
|
+
* (telemetry, feature flags). Populated by `DBSQLClient.connect()` from
|
|
52
|
+
* `ConnectionOptions.customHeaders` plus an `x-databricks-org-id` header
|
|
53
|
+
* derived from the `?o=` query parameter on `httpPath` when present, to
|
|
54
|
+
* support SPOG (Single Panel of Glass) account-level routing on endpoints
|
|
55
|
+
* that don't carry `?o=` in their URL path. NOT applied to Thrift or
|
|
56
|
+
* OAuth/OIDC requests.
|
|
57
|
+
*/
|
|
58
|
+
customHeaders?: Record<string, string>;
|
|
34
59
|
}
|
|
35
60
|
export default interface IClientContext {
|
|
36
61
|
getConfig(): ClientConfig;
|
|
@@ -38,4 +63,9 @@ export default interface IClientContext {
|
|
|
38
63
|
getConnectionProvider(): Promise<IConnectionProvider>;
|
|
39
64
|
getClient(): Promise<IThriftClient>;
|
|
40
65
|
getDriver(): Promise<IDriver>;
|
|
66
|
+
getAuthProvider?(): IAuthentication | undefined;
|
|
67
|
+
/** @internal Telemetry event emitter, undefined when telemetry is disabled. */
|
|
68
|
+
getTelemetryEmitter?(): TelemetryEventEmitter | undefined;
|
|
69
|
+
/** @internal Telemetry aggregator, undefined when telemetry is disabled. */
|
|
70
|
+
getTelemetryAggregator?(): MetricsAggregator | undefined;
|
|
41
71
|
}
|
|
@@ -18,6 +18,7 @@ type AuthOptions = {
|
|
|
18
18
|
oauthClientId?: string;
|
|
19
19
|
oauthClientSecret?: string;
|
|
20
20
|
useDatabricksOAuthInAzure?: boolean;
|
|
21
|
+
oauthScopes?: Array<string>;
|
|
21
22
|
} | {
|
|
22
23
|
authType: 'custom';
|
|
23
24
|
provider: IAuthentication;
|
|
@@ -45,6 +46,120 @@ export type ConnectionOptions = {
|
|
|
45
46
|
socketTimeout?: number;
|
|
46
47
|
proxy?: ProxyOptions;
|
|
47
48
|
enableMetricViewMetadata?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Retry-policy knobs governing how the driver retries retryable requests.
|
|
51
|
+
* They apply to **both** backends: the Thrift `HttpRetryPolicy` reads them
|
|
52
|
+
* directly, and on the kernel (SEA) path they are forwarded to the kernel
|
|
53
|
+
* (which owns the retry loop) via `buildKernelRetryOptions`. An unset field
|
|
54
|
+
* keeps the driver default shown below.
|
|
55
|
+
*
|
|
56
|
+
* • `retryMaxAttempts` — maximum TOTAL number of attempts (the initial
|
|
57
|
+
* request plus any retries). Default 5. `0` or `1` both mean a single
|
|
58
|
+
* attempt with no retry. Both backends honour the same total-attempt
|
|
59
|
+
* semantics (the kernel converts it to its after-initial retry count).
|
|
60
|
+
* • `retriesTimeout` — maximum total wallclock spent retrying, in
|
|
61
|
+
* milliseconds. Default 900000 (15 minutes).
|
|
62
|
+
* • `retryDelayMin` — minimum backoff between attempts, in milliseconds.
|
|
63
|
+
* Default 1000.
|
|
64
|
+
* • `retryDelayMax` — maximum backoff between attempts, in milliseconds.
|
|
65
|
+
* Default 60000.
|
|
66
|
+
*/
|
|
67
|
+
retryMaxAttempts?: number;
|
|
68
|
+
retriesTimeout?: number;
|
|
69
|
+
retryDelayMin?: number;
|
|
70
|
+
retryDelayMax?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Preserve full numeric precision in results. When `true`, DECIMAL columns
|
|
73
|
+
* are returned as exact strings and 64-bit integers (BIGINT) as JS `bigint`,
|
|
74
|
+
* instead of the default lossy coercion to a JS `number` (which silently
|
|
75
|
+
* rounds DECIMALs and integers beyond 2^53). Applies to both the Thrift and
|
|
76
|
+
* kernel backends. Defaults to `false` to preserve the existing representation.
|
|
77
|
+
*/
|
|
78
|
+
preserveBigNumericPrecision?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Extra HTTP headers attached to driver-owned out-of-band requests
|
|
81
|
+
* (telemetry POSTs and feature-flag GETs). Not applied to the primary
|
|
82
|
+
* Thrift transport or to OAuth/OIDC token requests.
|
|
83
|
+
*
|
|
84
|
+
* When `path` contains `?o=<workspaceId>` (SPOG account-level routing),
|
|
85
|
+
* the driver automatically injects an `x-databricks-org-id` header unless
|
|
86
|
+
* one is already present in this map.
|
|
87
|
+
*/
|
|
88
|
+
customHeaders?: Record<string, string>;
|
|
89
|
+
/**
|
|
90
|
+
* Whether the driver emits telemetry events (connection / statement /
|
|
91
|
+
* cloud-fetch / error). Defaults to `true`.
|
|
92
|
+
*
|
|
93
|
+
* Activation is gated by **two** conditions:
|
|
94
|
+
* 1. This flag is `true` **and**
|
|
95
|
+
* 2. The remote feature flag for the workspace allows telemetry.
|
|
96
|
+
*
|
|
97
|
+
* Setting this to `false` is a hard, unconditional opt-out. Setting to
|
|
98
|
+
* `true` only requests telemetry; the workspace must also allow it.
|
|
99
|
+
*
|
|
100
|
+
* The environment variable `DATABRICKS_TELEMETRY_DISABLED` set to one of
|
|
101
|
+
* `1`, `true`, `yes`, or `on` (case-insensitive) overrides this flag and
|
|
102
|
+
* disables telemetry entirely.
|
|
103
|
+
*/
|
|
104
|
+
telemetryEnabled?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Maximum number of metrics to batch before flushing to the telemetry
|
|
107
|
+
* endpoint. Default 100.
|
|
108
|
+
*/
|
|
109
|
+
telemetryBatchSize?: number;
|
|
110
|
+
/**
|
|
111
|
+
* How often to flush buffered telemetry metrics, in milliseconds.
|
|
112
|
+
* The flush timer is `unref()`'d so it cannot keep the Node.js process
|
|
113
|
+
* alive on its own. Default 5000ms.
|
|
114
|
+
*/
|
|
115
|
+
telemetryFlushIntervalMs?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Maximum retry attempts for a telemetry export *after* the initial call.
|
|
118
|
+
* Default 3.
|
|
119
|
+
*/
|
|
120
|
+
telemetryMaxRetries?: number;
|
|
121
|
+
/**
|
|
122
|
+
* When `true`, telemetry is sent to the authenticated `/telemetry-ext`
|
|
123
|
+
* endpoint with workspace + session + statement IDs and a system
|
|
124
|
+
* configuration block. When `false`, only error names are emitted via the
|
|
125
|
+
* unauthenticated endpoint. Default `true`.
|
|
126
|
+
*
|
|
127
|
+
* Privacy-relevant: setting `false` minimizes the data surface at the
|
|
128
|
+
* cost of losing most observability.
|
|
129
|
+
*/
|
|
130
|
+
telemetryAuthenticatedExport?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Number of consecutive telemetry export failures before the per-host
|
|
133
|
+
* circuit breaker trips and pauses exports. Default 5.
|
|
134
|
+
*/
|
|
135
|
+
telemetryCircuitBreakerThreshold?: number;
|
|
136
|
+
/**
|
|
137
|
+
* How long the circuit breaker stays open before re-probing the
|
|
138
|
+
* telemetry endpoint, in milliseconds. Default 60000ms (1 minute).
|
|
139
|
+
*/
|
|
140
|
+
telemetryCircuitBreakerTimeout?: number;
|
|
141
|
+
/**
|
|
142
|
+
* Maximum wall-clock time `client.close()` will wait for the final
|
|
143
|
+
* telemetry flush HTTP POST. Bounds shutdown latency so callers
|
|
144
|
+
* doing `await client.close(); process.exit(0)` are not held up by a
|
|
145
|
+
* misbehaving telemetry endpoint. Default 2000ms.
|
|
146
|
+
*/
|
|
147
|
+
telemetryCloseTimeoutMs?: number;
|
|
148
|
+
/**
|
|
149
|
+
* Hard cap on the per-statement aggregation map size. When the cap is
|
|
150
|
+
* reached, the oldest entry is evicted (its buffered errors are emitted
|
|
151
|
+
* as standalone metrics first so the first-failure signal survives).
|
|
152
|
+
* Default 5000.
|
|
153
|
+
*/
|
|
154
|
+
telemetryMaxStatementMetrics?: number;
|
|
155
|
+
/**
|
|
156
|
+
* Maximum number of telemetry metrics buffered in memory before the
|
|
157
|
+
* oldest non-error entry is dropped. Raise this when
|
|
158
|
+
* `getTelemetryStats().droppedMetrics` increases between observations,
|
|
159
|
+
* which indicates the buffer is filling faster than the flush interval
|
|
160
|
+
* can drain it. Default 500.
|
|
161
|
+
*/
|
|
162
|
+
telemetryMaxPendingMetrics?: number;
|
|
48
163
|
} & AuthOptions;
|
|
49
164
|
export interface OpenSessionRequest {
|
|
50
165
|
initialCatalog?: string;
|
|
@@ -4,6 +4,23 @@ export interface LoggerOptions {
|
|
|
4
4
|
}
|
|
5
5
|
export default interface IDBSQLLogger {
|
|
6
6
|
log(level: LogLevel, message: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Optional: the logger's current level. When implemented, the kernel
|
|
9
|
+
* backend uses it to set the verbosity of the kernel-side (Rust) log bridge,
|
|
10
|
+
* so kernel logs are filtered at the same level as the driver's own logs and
|
|
11
|
+
* land in the same sink. Loggers that don't implement it leave the kernel
|
|
12
|
+
* bridge at its `info` default.
|
|
13
|
+
*/
|
|
14
|
+
getLevel?(): LogLevel;
|
|
15
|
+
/**
|
|
16
|
+
* Optional: subscribe to runtime level changes. When implemented, the
|
|
17
|
+
* kernel backend subscribes so a runtime `setLevel(...)` retargets the
|
|
18
|
+
* kernel-side log bridge too (not just the driver's own transports) — keeping
|
|
19
|
+
* kernel verbosity in lock-step with the driver's. Returns an unsubscribe
|
|
20
|
+
* function. Loggers that don't implement it still get the connect-time level;
|
|
21
|
+
* only *runtime* retargeting of the kernel is unavailable.
|
|
22
|
+
*/
|
|
23
|
+
onLevelChange?(listener: (level: LogLevel) => void): () => void;
|
|
7
24
|
}
|
|
8
25
|
export declare enum LogLevel {
|
|
9
26
|
error = "error",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IDBSQLLogger.js","sourceRoot":"","sources":["../../lib/contracts/IDBSQLLogger.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"IDBSQLLogger.js","sourceRoot":"","sources":["../../lib/contracts/IDBSQLLogger.ts"],"names":[],"mappings":";;;AA4BA,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EALW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAKnB"}
|
|
@@ -11,7 +11,18 @@ export type ExecuteStatementOptions = {
|
|
|
11
11
|
*/
|
|
12
12
|
queryTimeout?: number | bigint | Int64;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Selects the execution lifecycle. The only observable effect is WHEN
|
|
15
|
+
* `executeStatement` resolves; the result data, schema, and error classes are
|
|
16
|
+
* identical regardless.
|
|
17
|
+
*
|
|
18
|
+
* - **Thrift backend:** no-op. The Thrift path always submits asynchronously
|
|
19
|
+
* (`runAsync: true` on the wire) and polls during fetch; this option is not
|
|
20
|
+
* read.
|
|
21
|
+
* - **Kernel backend (`useKernel`):** selects the kernel execution path —
|
|
22
|
+
* `false`/unset (default) runs the blocking direct-results path (faster,
|
|
23
|
+
* cancellable mid-compute); `true` submits and polls (returns a pending
|
|
24
|
+
* handle before completion). Default is sync, matching the python
|
|
25
|
+
* connector's `cursor.execute()`.
|
|
15
26
|
*/
|
|
16
27
|
runAsync?: boolean;
|
|
17
28
|
maxRows?: number | bigint | Int64 | null;
|
|
@@ -26,6 +37,18 @@ export type ExecuteStatementOptions = {
|
|
|
26
37
|
* These tags apply only to this statement and do not persist across queries.
|
|
27
38
|
*/
|
|
28
39
|
queryTags?: Record<string, string | null | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* kernel-only: server-side row cap for this statement (kernel `row_limit`). The
|
|
42
|
+
* Thrift backend has no execute-time server cap, so this is a no-op there;
|
|
43
|
+
* use `maxRows` for the cross-backend client-side fetch limit.
|
|
44
|
+
*/
|
|
45
|
+
rowLimit?: number;
|
|
46
|
+
/**
|
|
47
|
+
* kernel-only: per-statement Spark conf overlay (kernel `statement_conf`).
|
|
48
|
+
* Merged with the serialized `queryTags` (which land under the reserved
|
|
49
|
+
* `query_tags` key). Ignored by the Thrift backend.
|
|
50
|
+
*/
|
|
51
|
+
statementConf?: Record<string, string>;
|
|
29
52
|
};
|
|
30
53
|
export type TypeInfoRequest = {
|
|
31
54
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Readable, ReadableOptions } from 'node:stream';
|
|
3
3
|
import { TGetOperationStatusResp, TTableSchema } from '../../thrift/TCLIService_types';
|
|
4
4
|
import Status from '../dto/Status';
|
|
5
|
+
import { ResultMetadata } from './ResultMetadata';
|
|
5
6
|
export type OperationStatusCallback = (progress: TGetOperationStatusResp) => unknown;
|
|
6
7
|
export interface WaitUntilReadyOptions {
|
|
7
8
|
progress?: boolean;
|
|
@@ -43,7 +44,10 @@ export default interface IOperation {
|
|
|
43
44
|
*/
|
|
44
45
|
fetchAll(options?: FetchOptions): Promise<Array<object>>;
|
|
45
46
|
/**
|
|
46
|
-
* Request status of operation
|
|
47
|
+
* Request status of operation. Returns the Thrift wire response for
|
|
48
|
+
* back-compat. New code should prefer {@link IOperation.getResultMetadata}
|
|
49
|
+
* for metadata and may consume the neutral `IOperationBackend.status` via
|
|
50
|
+
* a typed downcast when implementing alternative backends.
|
|
47
51
|
*
|
|
48
52
|
* @param progress
|
|
49
53
|
*/
|
|
@@ -68,6 +72,11 @@ export default interface IOperation {
|
|
|
68
72
|
* Fetch schema
|
|
69
73
|
*/
|
|
70
74
|
getSchema(options?: GetSchemaOptions): Promise<TTableSchema | null>;
|
|
75
|
+
/**
|
|
76
|
+
* Fetch result-set metadata in the backend-neutral `ResultMetadata` shape.
|
|
77
|
+
* Prefer this over the Thrift-shaped surface for new code.
|
|
78
|
+
*/
|
|
79
|
+
getResultMetadata(): Promise<ResultMetadata>;
|
|
71
80
|
iterateChunks(options?: IteratorOptions): IOperationChunksIterator;
|
|
72
81
|
iterateRows(options?: IteratorOptions): IOperationRowsIterator;
|
|
73
82
|
toNodeStream(options?: NodeStreamOptions): Readable;
|