@databricks/sdk-statementexecution 0.0.0-dev → 0.1.0-dev.2
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/LICENSE +203 -0
- package/dist/v1/client.d.ts +93 -0
- package/dist/v1/client.d.ts.map +1 -0
- package/dist/v1/client.js +212 -0
- package/dist/v1/client.js.map +1 -0
- package/dist/v1/index.d.ts +4 -0
- package/dist/v1/index.d.ts.map +1 -0
- package/dist/v1/index.js +4 -0
- package/dist/v1/index.js.map +1 -0
- package/dist/v1/model.d.ts +500 -0
- package/dist/v1/model.d.ts.map +1 -0
- package/dist/v1/model.js +323 -0
- package/dist/v1/model.js.map +1 -0
- package/dist/v1/transport.d.ts +5 -0
- package/dist/v1/transport.d.ts.map +1 -0
- package/dist/v1/transport.js +57 -0
- package/dist/v1/transport.js.map +1 -0
- package/dist/v1/utils.d.ts +22 -0
- package/dist/v1/utils.d.ts.map +1 -0
- package/dist/v1/utils.js +113 -0
- package/dist/v1/utils.js.map +1 -0
- package/package.json +38 -4
- package/src/v1/client.ts +257 -0
- package/src/v1/index.ts +32 -0
- package/src/v1/model.ts +773 -0
- package/src/v1/transport.ts +73 -0
- package/src/v1/utils.ts +156 -0
- package/README.md +0 -1
- package/index.js +0 -1
package/src/v1/model.ts
ADDED
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
import type {JsonValue} from '@databricks/sdk-core/wkt';
|
|
4
|
+
import {z} from 'zod';
|
|
5
|
+
|
|
6
|
+
const jsonValueSchema: z.ZodType<JsonValue> = z.lazy(() =>
|
|
7
|
+
z.union([
|
|
8
|
+
z.null(),
|
|
9
|
+
z.number(),
|
|
10
|
+
z.string(),
|
|
11
|
+
z.boolean(),
|
|
12
|
+
z.record(z.string(), jsonValueSchema),
|
|
13
|
+
z.array(jsonValueSchema),
|
|
14
|
+
])
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
/** The name of the base data type. This doesn't include details for complex types such as STRUCT, MAP or ARRAY. */
|
|
18
|
+
export enum ColumnTypeName {
|
|
19
|
+
BOOLEAN = 'BOOLEAN',
|
|
20
|
+
BYTE = 'BYTE',
|
|
21
|
+
SHORT = 'SHORT',
|
|
22
|
+
INT = 'INT',
|
|
23
|
+
LONG = 'LONG',
|
|
24
|
+
FLOAT = 'FLOAT',
|
|
25
|
+
DOUBLE = 'DOUBLE',
|
|
26
|
+
DATE = 'DATE',
|
|
27
|
+
TIMESTAMP = 'TIMESTAMP',
|
|
28
|
+
STRING = 'STRING',
|
|
29
|
+
BINARY = 'BINARY',
|
|
30
|
+
DECIMAL = 'DECIMAL',
|
|
31
|
+
INTERVAL = 'INTERVAL',
|
|
32
|
+
ARRAY = 'ARRAY',
|
|
33
|
+
STRUCT = 'STRUCT',
|
|
34
|
+
MAP = 'MAP',
|
|
35
|
+
CHAR = 'CHAR',
|
|
36
|
+
NULL = 'NULL',
|
|
37
|
+
USER_DEFINED_TYPE = 'USER_DEFINED_TYPE',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export enum Disposition {
|
|
41
|
+
FETCH_DISPOSITION_UNSPECIFIED = 'FETCH_DISPOSITION_UNSPECIFIED',
|
|
42
|
+
INLINE = 'INLINE',
|
|
43
|
+
EXTERNAL_LINKS = 'EXTERNAL_LINKS',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export enum Format {
|
|
47
|
+
FORMAT_UNSPECIFIED = 'FORMAT_UNSPECIFIED',
|
|
48
|
+
JSON_ARRAY = 'JSON_ARRAY',
|
|
49
|
+
ARROW_STREAM = 'ARROW_STREAM',
|
|
50
|
+
CSV = 'CSV',
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export enum ServiceErrorCode {
|
|
54
|
+
UNKNOWN = 'UNKNOWN',
|
|
55
|
+
INTERNAL_ERROR = 'INTERNAL_ERROR',
|
|
56
|
+
TEMPORARILY_UNAVAILABLE = 'TEMPORARILY_UNAVAILABLE',
|
|
57
|
+
IO_ERROR = 'IO_ERROR',
|
|
58
|
+
BAD_REQUEST = 'BAD_REQUEST',
|
|
59
|
+
SERVICE_UNDER_MAINTENANCE = 'SERVICE_UNDER_MAINTENANCE',
|
|
60
|
+
WORKSPACE_TEMPORARILY_UNAVAILABLE = 'WORKSPACE_TEMPORARILY_UNAVAILABLE',
|
|
61
|
+
DEADLINE_EXCEEDED = 'DEADLINE_EXCEEDED',
|
|
62
|
+
CANCELLED = 'CANCELLED',
|
|
63
|
+
RESOURCE_EXHAUSTED = 'RESOURCE_EXHAUSTED',
|
|
64
|
+
ABORTED = 'ABORTED',
|
|
65
|
+
NOT_FOUND = 'NOT_FOUND',
|
|
66
|
+
ALREADY_EXISTS = 'ALREADY_EXISTS',
|
|
67
|
+
UNAUTHENTICATED = 'UNAUTHENTICATED',
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* When `wait_timeout > 0s`, the call will block up to the specified time. If the statement execution doesn't
|
|
72
|
+
* finish within this time, `on_wait_timeout` determines whether the execution should continue or be canceled.
|
|
73
|
+
* When set to `CONTINUE`, the statement execution continues asynchronously and the call returns a statement ID
|
|
74
|
+
* which can be used for polling with :method:statementexecution/getStatement. When set to `CANCEL`,
|
|
75
|
+
* the statement execution is canceled and the call returns with a `CANCELED` state.
|
|
76
|
+
*/
|
|
77
|
+
export enum TimeoutAction {
|
|
78
|
+
TIMEOUT_ACTION_UNSPECIFIED = 'TIMEOUT_ACTION_UNSPECIFIED',
|
|
79
|
+
CONTINUE = 'CONTINUE',
|
|
80
|
+
CANCEL = 'CANCEL',
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested enum name.
|
|
84
|
+
export enum StatementStatus_State {
|
|
85
|
+
STATE_UNSPECIFIED = 'STATE_UNSPECIFIED',
|
|
86
|
+
PENDING = 'PENDING',
|
|
87
|
+
RUNNING = 'RUNNING',
|
|
88
|
+
SUCCEEDED = 'SUCCEEDED',
|
|
89
|
+
FAILED = 'FAILED',
|
|
90
|
+
CANCELED = 'CANCELED',
|
|
91
|
+
CLOSED = 'CLOSED',
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface CancelStatementRequest {
|
|
95
|
+
/**
|
|
96
|
+
* The statement ID is returned upon successfully submitting a SQL statement, and is a required
|
|
97
|
+
* reference for all subsequent calls.
|
|
98
|
+
*/
|
|
99
|
+
statementId?: string | undefined;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
103
|
+
export interface CancelStatementResponse {}
|
|
104
|
+
|
|
105
|
+
export interface ChunkInfo {
|
|
106
|
+
/** The position within the sequence of result set chunks. */
|
|
107
|
+
chunkIndex?: number | undefined;
|
|
108
|
+
/** The starting row offset within the result set. */
|
|
109
|
+
rowOffset?: bigint | undefined;
|
|
110
|
+
/** The number of rows within the result chunk. */
|
|
111
|
+
rowCount?: bigint | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* The number of bytes in the result chunk. This field is not available when using `INLINE`
|
|
114
|
+
* disposition.
|
|
115
|
+
*/
|
|
116
|
+
byteCount?: bigint | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* When fetching, provides the `chunk_index` for the _next_ chunk. If absent, indicates there are no
|
|
119
|
+
* more chunks. The next chunk can be fetched with a
|
|
120
|
+
* :method:statementexecution/getstatementresultchunkn request.
|
|
121
|
+
*/
|
|
122
|
+
nextChunkIndex?: number | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* When fetching, provides a link to fetch the _next_ chunk. If absent, indicates there are no more
|
|
125
|
+
* chunks. This link is an absolute `path` to be joined with your `$DATABRICKS_HOST`, and should be
|
|
126
|
+
* treated as an opaque link. This is an alternative to using `next_chunk_index`.
|
|
127
|
+
*/
|
|
128
|
+
nextChunkInternalLink?: string | undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface ColumnInfo {
|
|
132
|
+
/** The name of the column. */
|
|
133
|
+
name?: string | undefined;
|
|
134
|
+
/** The full SQL type specification. */
|
|
135
|
+
typeText?: string | undefined;
|
|
136
|
+
/** The name of the base data type. This doesn't include details for complex types such as STRUCT, MAP or ARRAY. */
|
|
137
|
+
typeName?: ColumnTypeName | undefined;
|
|
138
|
+
/** The ordinal position of the column (starting at position 0). */
|
|
139
|
+
position?: number | undefined;
|
|
140
|
+
/** Specifies the number of digits in a number. This applies to the DECIMAL type. */
|
|
141
|
+
typePrecision?: number | undefined;
|
|
142
|
+
/** Specifies the number of digits to the right of the decimal point in a number. This applies to the DECIMAL type. */
|
|
143
|
+
typeScale?: number | undefined;
|
|
144
|
+
/** The format of the interval type. */
|
|
145
|
+
typeIntervalType?: string | undefined;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface ExecuteStatementRequest {
|
|
149
|
+
/**
|
|
150
|
+
* The SQL statement to execute. The statement can optionally be parameterized, see `parameters`.
|
|
151
|
+
* The maximum query text size is 16 MiB.
|
|
152
|
+
*/
|
|
153
|
+
statement?: string | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Warehouse upon which to execute a statement. See also
|
|
156
|
+
* [What are SQL warehouses?](https://docs.databricks.com/sql/admin/warehouse-type.html)
|
|
157
|
+
*/
|
|
158
|
+
warehouseId?: string | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* Sets default catalog for statement execution, similar to
|
|
161
|
+
* [`USE CATALOG`](https://docs.databricks.com/sql/language-manual/sql-ref-syntax-ddl-use-catalog.html)
|
|
162
|
+
* in SQL.
|
|
163
|
+
*/
|
|
164
|
+
catalog?: string | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* Sets default schema for statement execution, similar to
|
|
167
|
+
* [`USE SCHEMA`](https://docs.databricks.com/sql/language-manual/sql-ref-syntax-ddl-use-schema.html)
|
|
168
|
+
* in SQL.
|
|
169
|
+
*/
|
|
170
|
+
schema?: string | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Applies the given row limit to the statement's result set, but unlike the `LIMIT` clause in SQL,
|
|
173
|
+
* it also sets the `truncated` field in the response to indicate whether the result was trimmed due to the limit or
|
|
174
|
+
* not.
|
|
175
|
+
*/
|
|
176
|
+
rowLimit?: bigint | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* Applies the given byte limit to the statement's result size. Byte counts are based on internal data
|
|
179
|
+
* representations and might not match the final size in the requested `format`. If the result was truncated due to
|
|
180
|
+
* the byte limit, then `truncated` in the response is set to `true`.
|
|
181
|
+
* When using `EXTERNAL_LINKS` disposition, a default `byte_limit` of 100 GiB is applied if `byte_limit` is not
|
|
182
|
+
* explicitly set.
|
|
183
|
+
*/
|
|
184
|
+
byteLimit?: bigint | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Statement execution supports three result formats: `JSON_ARRAY` (default), `ARROW_STREAM`, and `CSV`.
|
|
187
|
+
*
|
|
188
|
+
* Important: The formats `ARROW_STREAM` and `CSV` are supported only with `EXTERNAL_LINKS` disposition.
|
|
189
|
+
* `JSON_ARRAY` is supported in `INLINE` and `EXTERNAL_LINKS` disposition.
|
|
190
|
+
*
|
|
191
|
+
* When specifying `format=JSON_ARRAY`, result data will be formatted as an array of arrays of values, where each
|
|
192
|
+
* value is either the *string representation* of a value, or `null`.
|
|
193
|
+
* For example, the output of `SELECT concat('id-', id) AS strCol, id AS intCol, null AS nullCol FROM range(3)` would
|
|
194
|
+
* look like this:
|
|
195
|
+
*
|
|
196
|
+
* ```
|
|
197
|
+
* [
|
|
198
|
+
* [ "id-1", "1", null ],
|
|
199
|
+
* [ "id-2", "2", null ],
|
|
200
|
+
* [ "id-3", "3", null ],
|
|
201
|
+
* ]
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* When specifying `format=JSON_ARRAY` and `disposition=EXTERNAL_LINKS`, each chunk in the result contains compact
|
|
205
|
+
* JSON with no indentation or extra whitespace.
|
|
206
|
+
*
|
|
207
|
+
* When specifying `format=ARROW_STREAM` and `disposition=EXTERNAL_LINKS`, each chunk in the result will be formatted
|
|
208
|
+
* as Apache Arrow Stream. See the
|
|
209
|
+
* [Apache Arrow streaming format](https://arrow.apache.org/docs/format/Columnar.html#ipc-streaming-format).
|
|
210
|
+
*
|
|
211
|
+
* When specifying `format=CSV` and `disposition=EXTERNAL_LINKS`, each chunk in the result will be a CSV according to
|
|
212
|
+
* [RFC 4180](https://www.rfc-editor.org/rfc/rfc4180) standard.
|
|
213
|
+
* All the columns values will have *string representation* similar to the `JSON_ARRAY` format, and `null` values will
|
|
214
|
+
* be encoded as “null”.
|
|
215
|
+
* Only the first chunk in the result would contain a header row with column names.
|
|
216
|
+
* For example, the output of `SELECT concat('id-', id) AS strCol, id AS intCol, null as nullCol FROM range(3)` would
|
|
217
|
+
* look like this:
|
|
218
|
+
*
|
|
219
|
+
* ```
|
|
220
|
+
* strCol,intCol,nullCol
|
|
221
|
+
* id-1,1,null
|
|
222
|
+
* id-2,2,null
|
|
223
|
+
* id-3,3,null
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
format?: Format | undefined;
|
|
227
|
+
/**
|
|
228
|
+
* The fetch disposition provides two modes of fetching results: `INLINE` and `EXTERNAL_LINKS`.
|
|
229
|
+
*
|
|
230
|
+
* Statements executed with `INLINE` disposition will return result data inline, in `JSON_ARRAY` format, in a series
|
|
231
|
+
* of chunks. If a given statement produces a result set with a size larger than 25 MiB,
|
|
232
|
+
* that statement execution is aborted, and no result set will be available.
|
|
233
|
+
*
|
|
234
|
+
* **NOTE**
|
|
235
|
+
* Byte limits are computed based upon internal representations of the result set data, and might not match the sizes
|
|
236
|
+
* visible in JSON responses.
|
|
237
|
+
*
|
|
238
|
+
* Statements executed with `EXTERNAL_LINKS` disposition will return result data as external links: URLs that point
|
|
239
|
+
* to cloud storage internal to the workspace. Using `EXTERNAL_LINKS` disposition allows statements to generate
|
|
240
|
+
* arbitrarily sized result sets for fetching up to 100 GiB. The resulting links have two important properties:
|
|
241
|
+
*
|
|
242
|
+
* 1. They point to resources _external_ to the <Databricks> compute; therefore any associated authentication
|
|
243
|
+
* information (typically a personal access token, OAuth token, or similar) _must be removed_ when fetching from
|
|
244
|
+
* these links.
|
|
245
|
+
*
|
|
246
|
+
* 2. These are URLs
|
|
247
|
+
* with a specific expiration, indicated in the response. The behavior when attempting to use an expired link is
|
|
248
|
+
* cloud specific.
|
|
249
|
+
*/
|
|
250
|
+
disposition?: Disposition | undefined;
|
|
251
|
+
/**
|
|
252
|
+
* The time in seconds the call will wait for the statement's result set as `Ns`, where `N` can be set to 0 or to a
|
|
253
|
+
* value between 5 and 50.
|
|
254
|
+
*
|
|
255
|
+
* When set to `0s`, the statement will execute in asynchronous mode and the call will not wait for the execution to
|
|
256
|
+
* finish. In this case, the call returns directly with `PENDING` state and a statement ID which can be used for
|
|
257
|
+
* polling with :method:statementexecution/getStatement.
|
|
258
|
+
*
|
|
259
|
+
* When set between 5 and 50 seconds, the call will behave synchronously up to this timeout and wait for the statement
|
|
260
|
+
* execution to finish. If the execution finishes within this time, the call returns immediately with a manifest and
|
|
261
|
+
* result data (or a `FAILED` state in case of an execution error). If the statement takes longer to execute,
|
|
262
|
+
* `on_wait_timeout` determines what should happen after the timeout is reached.
|
|
263
|
+
*/
|
|
264
|
+
waitTimeout?: string | undefined;
|
|
265
|
+
/**
|
|
266
|
+
* When `wait_timeout > 0s`, the call will block up to the specified time. If the statement execution doesn't
|
|
267
|
+
* finish within this time, `on_wait_timeout` determines whether the execution should continue or be canceled.
|
|
268
|
+
* When set to `CONTINUE`, the statement execution continues asynchronously and the call returns a statement ID
|
|
269
|
+
* which can be used for polling with :method:statementexecution/getStatement. When set to `CANCEL`,
|
|
270
|
+
* the statement execution is canceled and the call returns with a `CANCELED` state.
|
|
271
|
+
*/
|
|
272
|
+
onWaitTimeout?: TimeoutAction | undefined;
|
|
273
|
+
/**
|
|
274
|
+
* A list of parameters to pass into a SQL statement containing parameter markers. A
|
|
275
|
+
* parameter consists of a name, a value, and optionally a type. To represent a NULL
|
|
276
|
+
* value, the `value` field may be omitted or set to `null` explicitly. If the `type` field
|
|
277
|
+
* is omitted, the value is interpreted as a string.
|
|
278
|
+
*
|
|
279
|
+
* If the type is given, parameters will be checked for type correctness according
|
|
280
|
+
* to the given type. A value is correct if the provided string can be converted to
|
|
281
|
+
* the requested type using the `cast` function. The exact semantics are described in
|
|
282
|
+
* the section [`cast` function](https://docs.databricks.com/sql/language-manual/functions/cast.html) of the SQL language reference.
|
|
283
|
+
*
|
|
284
|
+
* For example, the following statement contains two parameters, `my_name` and `my_date`:
|
|
285
|
+
*
|
|
286
|
+
* ```
|
|
287
|
+
* SELECT * FROM my_table WHERE name = :my_name AND date = :my_date
|
|
288
|
+
* ```
|
|
289
|
+
*
|
|
290
|
+
* The parameters can be passed in the request body as follows:
|
|
291
|
+
*
|
|
292
|
+
* `
|
|
293
|
+
* {
|
|
294
|
+
* ...,
|
|
295
|
+
* "statement": "SELECT * FROM my_table WHERE name = :my_name AND date = :my_date",
|
|
296
|
+
* "parameters": [
|
|
297
|
+
* { "name": "my_name", "value": "the name" },
|
|
298
|
+
* { "name": "my_date", "value": "2020-01-01", "type": "DATE" }
|
|
299
|
+
* ]
|
|
300
|
+
* }
|
|
301
|
+
* `
|
|
302
|
+
*
|
|
303
|
+
* Currently, positional parameters denoted by a `?` marker are not supported by the
|
|
304
|
+
* Databricks SQL Statement Execution API.
|
|
305
|
+
*
|
|
306
|
+
* Also see the section [Parameter markers](https://docs.databricks.com/sql/language-manual/sql-ref-parameter-marker.html) of the SQL language reference.
|
|
307
|
+
*/
|
|
308
|
+
parameters?: StatementParameter[] | undefined;
|
|
309
|
+
/**
|
|
310
|
+
* An array of query tags to annotate a SQL statement. A query tag
|
|
311
|
+
* consists of a non-empty key and, optionally, a value. To represent a NULL
|
|
312
|
+
* value, either omit the `value` field or manually set it to `null` or white space.
|
|
313
|
+
* Refer to the SQL language reference for the format specification of query tags.
|
|
314
|
+
* There's no significance to the order of tags. Only one value per key will be recorded.
|
|
315
|
+
* A sequence in excess of 20 query tags will be coerced to 20.
|
|
316
|
+
* Example:
|
|
317
|
+
*
|
|
318
|
+
* {
|
|
319
|
+
* ...,
|
|
320
|
+
* "query_tags": [
|
|
321
|
+
* { "key": "team", "value": "eng" },
|
|
322
|
+
* { "key": "some key only tag" }
|
|
323
|
+
* ]
|
|
324
|
+
* }
|
|
325
|
+
*/
|
|
326
|
+
queryTags?: QueryTag[] | undefined;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export interface ExternalLink {
|
|
330
|
+
/**
|
|
331
|
+
* A URL pointing to a
|
|
332
|
+
* chunk of result data, hosted by an external service, with a short expiration time
|
|
333
|
+
* (<= 15 minutes). As this URL contains a temporary credential, it should be considered sensitive
|
|
334
|
+
* and the client should not expose this URL in a log.
|
|
335
|
+
*/
|
|
336
|
+
externalLink?: string | undefined;
|
|
337
|
+
/**
|
|
338
|
+
* Indicates the date-time that the given external link will expire and
|
|
339
|
+
* becomes invalid, after which point a new `external_link` must be requested.
|
|
340
|
+
*/
|
|
341
|
+
expiration?: string | undefined;
|
|
342
|
+
/**
|
|
343
|
+
* HTTP headers that must be included with a GET request to the `external_link`.
|
|
344
|
+
* Each header is provided as a key-value pair.
|
|
345
|
+
* Headers are typically used to pass a decryption key to the external service.
|
|
346
|
+
* The values of these headers should be considered sensitive and the client should not expose
|
|
347
|
+
* these values in a log.
|
|
348
|
+
*/
|
|
349
|
+
httpHeaders?: Record<string, string> | undefined;
|
|
350
|
+
/** The position within the sequence of result set chunks. */
|
|
351
|
+
chunkIndex?: number | undefined;
|
|
352
|
+
/** The starting row offset within the result set. */
|
|
353
|
+
rowOffset?: bigint | undefined;
|
|
354
|
+
/** The number of rows within the result chunk. */
|
|
355
|
+
rowCount?: bigint | undefined;
|
|
356
|
+
/**
|
|
357
|
+
* The number of bytes in the result chunk. This field is not available when using `INLINE`
|
|
358
|
+
* disposition.
|
|
359
|
+
*/
|
|
360
|
+
byteCount?: bigint | undefined;
|
|
361
|
+
/**
|
|
362
|
+
* When fetching, provides the `chunk_index` for the _next_ chunk. If absent, indicates there are no
|
|
363
|
+
* more chunks. The next chunk can be fetched with a
|
|
364
|
+
* :method:statementexecution/getstatementresultchunkn request.
|
|
365
|
+
*/
|
|
366
|
+
nextChunkIndex?: number | undefined;
|
|
367
|
+
/**
|
|
368
|
+
* When fetching, provides a link to fetch the _next_ chunk. If absent, indicates there are no more
|
|
369
|
+
* chunks. This link is an absolute `path` to be joined with your `$DATABRICKS_HOST`, and should be
|
|
370
|
+
* treated as an opaque link. This is an alternative to using `next_chunk_index`.
|
|
371
|
+
*/
|
|
372
|
+
nextChunkInternalLink?: string | undefined;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
|
|
376
|
+
export interface ExternalLink_HttpHeadersEntry {
|
|
377
|
+
key?: string | undefined;
|
|
378
|
+
value?: string | undefined;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export interface GetResultDataRequest {
|
|
382
|
+
/**
|
|
383
|
+
* The statement ID is returned upon successfully submitting a SQL statement, and is a required
|
|
384
|
+
* reference for all subsequent calls.
|
|
385
|
+
*/
|
|
386
|
+
statementId?: string | undefined;
|
|
387
|
+
chunkIndex?: number | undefined;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export interface GetStatementResultRequest {
|
|
391
|
+
/**
|
|
392
|
+
* The statement ID is returned upon successfully submitting a SQL statement, and is a required
|
|
393
|
+
* reference for all subsequent calls.
|
|
394
|
+
*/
|
|
395
|
+
statementId?: string | undefined;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* * A query execution can be annotated with an optional key-value pair to
|
|
400
|
+
* allow users to attribute the executions by key and optional value to filter by.
|
|
401
|
+
* QueryTag is the user-facing representation.
|
|
402
|
+
*/
|
|
403
|
+
export interface QueryTag {
|
|
404
|
+
key?: string | undefined;
|
|
405
|
+
value?: string | undefined;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Contains the result data of a single chunk when using `INLINE` disposition. When using
|
|
410
|
+
* `EXTERNAL_LINKS` disposition, the array `external_links` is used instead to provide
|
|
411
|
+
* URLs to the result data
|
|
412
|
+
* in cloud storage. Exactly one of these alternatives is used. (While the `external_links`
|
|
413
|
+
* array prepares the API to return multiple links in a single response. Currently only a single
|
|
414
|
+
* link is returned.)
|
|
415
|
+
*/
|
|
416
|
+
export interface ResultData {
|
|
417
|
+
externalLinks?: ExternalLink[] | undefined;
|
|
418
|
+
/**
|
|
419
|
+
* The `JSON_ARRAY` format is an array of arrays of values, where each non-null value is
|
|
420
|
+
* formatted as a string. Null values are encoded as JSON `null`.
|
|
421
|
+
*/
|
|
422
|
+
dataArray?: JsonValue[][] | undefined;
|
|
423
|
+
/** The position within the sequence of result set chunks. */
|
|
424
|
+
chunkIndex?: number | undefined;
|
|
425
|
+
/** The starting row offset within the result set. */
|
|
426
|
+
rowOffset?: bigint | undefined;
|
|
427
|
+
/** The number of rows within the result chunk. */
|
|
428
|
+
rowCount?: bigint | undefined;
|
|
429
|
+
/**
|
|
430
|
+
* The number of bytes in the result chunk. This field is not available when using `INLINE`
|
|
431
|
+
* disposition.
|
|
432
|
+
*/
|
|
433
|
+
byteCount?: bigint | undefined;
|
|
434
|
+
/**
|
|
435
|
+
* When fetching, provides the `chunk_index` for the _next_ chunk. If absent, indicates there are no
|
|
436
|
+
* more chunks. The next chunk can be fetched with a
|
|
437
|
+
* :method:statementexecution/getstatementresultchunkn request.
|
|
438
|
+
*/
|
|
439
|
+
nextChunkIndex?: number | undefined;
|
|
440
|
+
/**
|
|
441
|
+
* When fetching, provides a link to fetch the _next_ chunk. If absent, indicates there are no more
|
|
442
|
+
* chunks. This link is an absolute `path` to be joined with your `$DATABRICKS_HOST`, and should be
|
|
443
|
+
* treated as an opaque link. This is an alternative to using `next_chunk_index`.
|
|
444
|
+
*/
|
|
445
|
+
nextChunkInternalLink?: string | undefined;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** The result manifest provides schema and metadata for the result set. */
|
|
449
|
+
export interface ResultManifest {
|
|
450
|
+
format?: Format | undefined;
|
|
451
|
+
schema?: Schema | undefined;
|
|
452
|
+
/** The total number of chunks that the result set has been divided into. */
|
|
453
|
+
totalChunkCount?: number | undefined;
|
|
454
|
+
/** Array of result set chunk metadata. */
|
|
455
|
+
chunks?: ChunkInfo[] | undefined;
|
|
456
|
+
/** The total number of rows in the result set. */
|
|
457
|
+
totalRowCount?: bigint | undefined;
|
|
458
|
+
/**
|
|
459
|
+
* The total number of bytes in the result set. This field is not available when using `INLINE`
|
|
460
|
+
* disposition.
|
|
461
|
+
*/
|
|
462
|
+
totalByteCount?: bigint | undefined;
|
|
463
|
+
/** Indicates whether the result is truncated due to `row_limit` or `byte_limit`. */
|
|
464
|
+
truncated?: boolean | undefined;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/** The schema is an ordered list of column descriptions. */
|
|
468
|
+
export interface Schema {
|
|
469
|
+
columnCount?: number | undefined;
|
|
470
|
+
columns?: ColumnInfo[] | undefined;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface ServiceError {
|
|
474
|
+
errorCode?: ServiceErrorCode | undefined;
|
|
475
|
+
/** A brief summary of the error condition. */
|
|
476
|
+
message?: string | undefined;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export interface StatementParameter {
|
|
480
|
+
/** The name of a parameter marker to be substituted in the statement. */
|
|
481
|
+
name?: string | undefined;
|
|
482
|
+
/** The value to substitute, represented as a string. If omitted, the value is interpreted as NULL. */
|
|
483
|
+
value?: string | undefined;
|
|
484
|
+
/**
|
|
485
|
+
* The data type, given as a string. For example: `INT`, `STRING`, `DECIMAL(10,2)`.
|
|
486
|
+
* If no type is given the type is assumed to be `STRING`. Complex types, such as
|
|
487
|
+
* `ARRAY`, `MAP`, and `STRUCT` are not supported. For valid types, refer to the
|
|
488
|
+
* section [Data types](https://docs.databricks.com/sql/language-manual/functions/cast.html) of the SQL language reference.
|
|
489
|
+
*/
|
|
490
|
+
type?: string | undefined;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export interface StatementResponse {
|
|
494
|
+
/**
|
|
495
|
+
* The statement ID is returned upon successfully submitting a SQL statement, and is a required
|
|
496
|
+
* reference for all subsequent calls.
|
|
497
|
+
*/
|
|
498
|
+
statementId?: string | undefined;
|
|
499
|
+
status?: StatementStatus | undefined;
|
|
500
|
+
manifest?: ResultManifest | undefined;
|
|
501
|
+
result?: ResultData | undefined;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/** The status response includes execution state and if relevant, error information. */
|
|
505
|
+
export interface StatementStatus {
|
|
506
|
+
/**
|
|
507
|
+
* Statement execution state:
|
|
508
|
+
* - `PENDING`: waiting for warehouse
|
|
509
|
+
* - `RUNNING`: running
|
|
510
|
+
* - `SUCCEEDED`: execution was successful, result data available for fetch
|
|
511
|
+
* - `FAILED`: execution failed; reason for failure described in accompanying error message
|
|
512
|
+
* - `CANCELED`: user canceled; can come from explicit cancel call, or timeout with
|
|
513
|
+
* `on_wait_timeout=CANCEL`
|
|
514
|
+
* - `CLOSED`: execution successful, and statement closed; result no longer available for fetch
|
|
515
|
+
*/
|
|
516
|
+
state?: StatementStatus_State | undefined;
|
|
517
|
+
error?: ServiceError | undefined;
|
|
518
|
+
/**
|
|
519
|
+
* SQLSTATE error code returned when the statement execution fails.
|
|
520
|
+
* Only populated when the statement status is `FAILED`.
|
|
521
|
+
*/
|
|
522
|
+
sqlState?: string | undefined;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
export const unmarshalCancelStatementResponseSchema: z.ZodType<CancelStatementResponse> =
|
|
526
|
+
z.object({});
|
|
527
|
+
|
|
528
|
+
export const unmarshalChunkInfoSchema: z.ZodType<ChunkInfo> = z
|
|
529
|
+
.object({
|
|
530
|
+
chunk_index: z.number().optional(),
|
|
531
|
+
row_offset: z
|
|
532
|
+
.union([z.number(), z.bigint()])
|
|
533
|
+
.transform(v => BigInt(v))
|
|
534
|
+
.optional(),
|
|
535
|
+
row_count: z
|
|
536
|
+
.union([z.number(), z.bigint()])
|
|
537
|
+
.transform(v => BigInt(v))
|
|
538
|
+
.optional(),
|
|
539
|
+
byte_count: z
|
|
540
|
+
.union([z.number(), z.bigint()])
|
|
541
|
+
.transform(v => BigInt(v))
|
|
542
|
+
.optional(),
|
|
543
|
+
next_chunk_index: z.number().optional(),
|
|
544
|
+
next_chunk_internal_link: z.string().optional(),
|
|
545
|
+
})
|
|
546
|
+
.transform(d => ({
|
|
547
|
+
chunkIndex: d.chunk_index,
|
|
548
|
+
rowOffset: d.row_offset,
|
|
549
|
+
rowCount: d.row_count,
|
|
550
|
+
byteCount: d.byte_count,
|
|
551
|
+
nextChunkIndex: d.next_chunk_index,
|
|
552
|
+
nextChunkInternalLink: d.next_chunk_internal_link,
|
|
553
|
+
}));
|
|
554
|
+
|
|
555
|
+
export const unmarshalColumnInfoSchema: z.ZodType<ColumnInfo> = z
|
|
556
|
+
.object({
|
|
557
|
+
name: z.string().optional(),
|
|
558
|
+
type_text: z.string().optional(),
|
|
559
|
+
type_name: z.enum(ColumnTypeName).optional(),
|
|
560
|
+
position: z.number().optional(),
|
|
561
|
+
type_precision: z.number().optional(),
|
|
562
|
+
type_scale: z.number().optional(),
|
|
563
|
+
type_interval_type: z.string().optional(),
|
|
564
|
+
})
|
|
565
|
+
.transform(d => ({
|
|
566
|
+
name: d.name,
|
|
567
|
+
typeText: d.type_text,
|
|
568
|
+
typeName: d.type_name,
|
|
569
|
+
position: d.position,
|
|
570
|
+
typePrecision: d.type_precision,
|
|
571
|
+
typeScale: d.type_scale,
|
|
572
|
+
typeIntervalType: d.type_interval_type,
|
|
573
|
+
}));
|
|
574
|
+
|
|
575
|
+
export const unmarshalExternalLinkSchema: z.ZodType<ExternalLink> = z
|
|
576
|
+
.object({
|
|
577
|
+
external_link: z.string().optional(),
|
|
578
|
+
expiration: z.string().optional(),
|
|
579
|
+
http_headers: z.record(z.string(), z.string()).optional(),
|
|
580
|
+
chunk_index: z.number().optional(),
|
|
581
|
+
row_offset: z
|
|
582
|
+
.union([z.number(), z.bigint()])
|
|
583
|
+
.transform(v => BigInt(v))
|
|
584
|
+
.optional(),
|
|
585
|
+
row_count: z
|
|
586
|
+
.union([z.number(), z.bigint()])
|
|
587
|
+
.transform(v => BigInt(v))
|
|
588
|
+
.optional(),
|
|
589
|
+
byte_count: z
|
|
590
|
+
.union([z.number(), z.bigint()])
|
|
591
|
+
.transform(v => BigInt(v))
|
|
592
|
+
.optional(),
|
|
593
|
+
next_chunk_index: z.number().optional(),
|
|
594
|
+
next_chunk_internal_link: z.string().optional(),
|
|
595
|
+
})
|
|
596
|
+
.transform(d => ({
|
|
597
|
+
externalLink: d.external_link,
|
|
598
|
+
expiration: d.expiration,
|
|
599
|
+
httpHeaders: d.http_headers,
|
|
600
|
+
chunkIndex: d.chunk_index,
|
|
601
|
+
rowOffset: d.row_offset,
|
|
602
|
+
rowCount: d.row_count,
|
|
603
|
+
byteCount: d.byte_count,
|
|
604
|
+
nextChunkIndex: d.next_chunk_index,
|
|
605
|
+
nextChunkInternalLink: d.next_chunk_internal_link,
|
|
606
|
+
}));
|
|
607
|
+
|
|
608
|
+
export const unmarshalResultDataSchema: z.ZodType<ResultData> = z
|
|
609
|
+
.object({
|
|
610
|
+
external_links: z
|
|
611
|
+
.array(z.lazy(() => unmarshalExternalLinkSchema))
|
|
612
|
+
.optional(),
|
|
613
|
+
data_array: z.array(z.array(jsonValueSchema)).optional(),
|
|
614
|
+
chunk_index: z.number().optional(),
|
|
615
|
+
row_offset: z
|
|
616
|
+
.union([z.number(), z.bigint()])
|
|
617
|
+
.transform(v => BigInt(v))
|
|
618
|
+
.optional(),
|
|
619
|
+
row_count: z
|
|
620
|
+
.union([z.number(), z.bigint()])
|
|
621
|
+
.transform(v => BigInt(v))
|
|
622
|
+
.optional(),
|
|
623
|
+
byte_count: z
|
|
624
|
+
.union([z.number(), z.bigint()])
|
|
625
|
+
.transform(v => BigInt(v))
|
|
626
|
+
.optional(),
|
|
627
|
+
next_chunk_index: z.number().optional(),
|
|
628
|
+
next_chunk_internal_link: z.string().optional(),
|
|
629
|
+
})
|
|
630
|
+
.transform(d => ({
|
|
631
|
+
externalLinks: d.external_links,
|
|
632
|
+
dataArray: d.data_array,
|
|
633
|
+
chunkIndex: d.chunk_index,
|
|
634
|
+
rowOffset: d.row_offset,
|
|
635
|
+
rowCount: d.row_count,
|
|
636
|
+
byteCount: d.byte_count,
|
|
637
|
+
nextChunkIndex: d.next_chunk_index,
|
|
638
|
+
nextChunkInternalLink: d.next_chunk_internal_link,
|
|
639
|
+
}));
|
|
640
|
+
|
|
641
|
+
export const unmarshalResultManifestSchema: z.ZodType<ResultManifest> = z
|
|
642
|
+
.object({
|
|
643
|
+
format: z.enum(Format).optional(),
|
|
644
|
+
schema: z.lazy(() => unmarshalSchemaSchema).optional(),
|
|
645
|
+
total_chunk_count: z.number().optional(),
|
|
646
|
+
chunks: z.array(z.lazy(() => unmarshalChunkInfoSchema)).optional(),
|
|
647
|
+
total_row_count: z
|
|
648
|
+
.union([z.number(), z.bigint()])
|
|
649
|
+
.transform(v => BigInt(v))
|
|
650
|
+
.optional(),
|
|
651
|
+
total_byte_count: z
|
|
652
|
+
.union([z.number(), z.bigint()])
|
|
653
|
+
.transform(v => BigInt(v))
|
|
654
|
+
.optional(),
|
|
655
|
+
truncated: z.boolean().optional(),
|
|
656
|
+
})
|
|
657
|
+
.transform(d => ({
|
|
658
|
+
format: d.format,
|
|
659
|
+
schema: d.schema,
|
|
660
|
+
totalChunkCount: d.total_chunk_count,
|
|
661
|
+
chunks: d.chunks,
|
|
662
|
+
totalRowCount: d.total_row_count,
|
|
663
|
+
totalByteCount: d.total_byte_count,
|
|
664
|
+
truncated: d.truncated,
|
|
665
|
+
}));
|
|
666
|
+
|
|
667
|
+
export const unmarshalSchemaSchema: z.ZodType<Schema> = z
|
|
668
|
+
.object({
|
|
669
|
+
column_count: z.number().optional(),
|
|
670
|
+
columns: z.array(z.lazy(() => unmarshalColumnInfoSchema)).optional(),
|
|
671
|
+
})
|
|
672
|
+
.transform(d => ({
|
|
673
|
+
columnCount: d.column_count,
|
|
674
|
+
columns: d.columns,
|
|
675
|
+
}));
|
|
676
|
+
|
|
677
|
+
export const unmarshalServiceErrorSchema: z.ZodType<ServiceError> = z
|
|
678
|
+
.object({
|
|
679
|
+
error_code: z.enum(ServiceErrorCode).optional(),
|
|
680
|
+
message: z.string().optional(),
|
|
681
|
+
})
|
|
682
|
+
.transform(d => ({
|
|
683
|
+
errorCode: d.error_code,
|
|
684
|
+
message: d.message,
|
|
685
|
+
}));
|
|
686
|
+
|
|
687
|
+
export const unmarshalStatementResponseSchema: z.ZodType<StatementResponse> = z
|
|
688
|
+
.object({
|
|
689
|
+
statement_id: z.string().optional(),
|
|
690
|
+
status: z.lazy(() => unmarshalStatementStatusSchema).optional(),
|
|
691
|
+
manifest: z.lazy(() => unmarshalResultManifestSchema).optional(),
|
|
692
|
+
result: z.lazy(() => unmarshalResultDataSchema).optional(),
|
|
693
|
+
})
|
|
694
|
+
.transform(d => ({
|
|
695
|
+
statementId: d.statement_id,
|
|
696
|
+
status: d.status,
|
|
697
|
+
manifest: d.manifest,
|
|
698
|
+
result: d.result,
|
|
699
|
+
}));
|
|
700
|
+
|
|
701
|
+
export const unmarshalStatementStatusSchema: z.ZodType<StatementStatus> = z
|
|
702
|
+
.object({
|
|
703
|
+
state: z.enum(StatementStatus_State).optional(),
|
|
704
|
+
error: z.lazy(() => unmarshalServiceErrorSchema).optional(),
|
|
705
|
+
sql_state: z.string().optional(),
|
|
706
|
+
})
|
|
707
|
+
.transform(d => ({
|
|
708
|
+
state: d.state,
|
|
709
|
+
error: d.error,
|
|
710
|
+
sqlState: d.sql_state,
|
|
711
|
+
}));
|
|
712
|
+
|
|
713
|
+
export const marshalCancelStatementRequestSchema: z.ZodType = z
|
|
714
|
+
.object({
|
|
715
|
+
statementId: z.string().optional(),
|
|
716
|
+
})
|
|
717
|
+
.transform(d => ({
|
|
718
|
+
statement_id: d.statementId,
|
|
719
|
+
}));
|
|
720
|
+
|
|
721
|
+
export const marshalExecuteStatementRequestSchema: z.ZodType = z
|
|
722
|
+
.object({
|
|
723
|
+
statement: z.string().optional(),
|
|
724
|
+
warehouseId: z.string().optional(),
|
|
725
|
+
catalog: z.string().optional(),
|
|
726
|
+
schema: z.string().optional(),
|
|
727
|
+
rowLimit: z.bigint().optional(),
|
|
728
|
+
byteLimit: z.bigint().optional(),
|
|
729
|
+
format: z.enum(Format).optional(),
|
|
730
|
+
disposition: z.enum(Disposition).optional(),
|
|
731
|
+
waitTimeout: z.string().optional(),
|
|
732
|
+
onWaitTimeout: z.enum(TimeoutAction).optional(),
|
|
733
|
+
parameters: z
|
|
734
|
+
.array(z.lazy(() => marshalStatementParameterSchema))
|
|
735
|
+
.optional(),
|
|
736
|
+
queryTags: z.array(z.lazy(() => marshalQueryTagSchema)).optional(),
|
|
737
|
+
})
|
|
738
|
+
.transform(d => ({
|
|
739
|
+
statement: d.statement,
|
|
740
|
+
warehouse_id: d.warehouseId,
|
|
741
|
+
catalog: d.catalog,
|
|
742
|
+
schema: d.schema,
|
|
743
|
+
row_limit: d.rowLimit,
|
|
744
|
+
byte_limit: d.byteLimit,
|
|
745
|
+
format: d.format,
|
|
746
|
+
disposition: d.disposition,
|
|
747
|
+
wait_timeout: d.waitTimeout,
|
|
748
|
+
on_wait_timeout: d.onWaitTimeout,
|
|
749
|
+
parameters: d.parameters,
|
|
750
|
+
query_tags: d.queryTags,
|
|
751
|
+
}));
|
|
752
|
+
|
|
753
|
+
export const marshalQueryTagSchema: z.ZodType = z
|
|
754
|
+
.object({
|
|
755
|
+
key: z.string().optional(),
|
|
756
|
+
value: z.string().optional(),
|
|
757
|
+
})
|
|
758
|
+
.transform(d => ({
|
|
759
|
+
key: d.key,
|
|
760
|
+
value: d.value,
|
|
761
|
+
}));
|
|
762
|
+
|
|
763
|
+
export const marshalStatementParameterSchema: z.ZodType = z
|
|
764
|
+
.object({
|
|
765
|
+
name: z.string().optional(),
|
|
766
|
+
value: z.string().optional(),
|
|
767
|
+
type: z.string().optional(),
|
|
768
|
+
})
|
|
769
|
+
.transform(d => ({
|
|
770
|
+
name: d.name,
|
|
771
|
+
value: d.value,
|
|
772
|
+
type: d.type,
|
|
773
|
+
}));
|