@databricks/sdk-queryhistory 0.0.0-dev → 0.1.0-dev.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.
@@ -0,0 +1,720 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ import {z} from 'zod';
4
+
5
+ export enum ChannelName {
6
+ CHANNEL_NAME_UNSPECIFIED = 'CHANNEL_NAME_UNSPECIFIED',
7
+ CHANNEL_NAME_PREVIEW = 'CHANNEL_NAME_PREVIEW',
8
+ CHANNEL_NAME_CURRENT = 'CHANNEL_NAME_CURRENT',
9
+ CHANNEL_NAME_PREVIOUS = 'CHANNEL_NAME_PREVIOUS',
10
+ CHANNEL_NAME_CUSTOM = 'CHANNEL_NAME_CUSTOM',
11
+ }
12
+
13
+ /** Possible Reasons for which we have not saved plans in the database */
14
+ export enum PlansState {
15
+ /** Execution time of the query was smaller than the min required to save plans */
16
+ IGNORED_SMALL_DURATION = 'IGNORED_SMALL_DURATION',
17
+ /** Size of plans is larger than the limit defined in config */
18
+ IGNORED_LARGE_PLANS_SIZE = 'IGNORED_LARGE_PLANS_SIZE',
19
+ /** If plans exist and are stored in the DB */
20
+ EXISTS = 'EXISTS',
21
+ /** Catchall for unknown states in graphql, to prevent it from crashing when it recieved an unknown enum type that is defined here but not in the graphql schema of the object */
22
+ UNKNOWN = 'UNKNOWN',
23
+ /** When the query has no plans by default */
24
+ EMPTY = 'EMPTY',
25
+ /** When plans are filtered out in history backend because it is isIgnoredSparkPlanType, isIgnoredSparkPlanName or isDeltaLogScan */
26
+ IGNORED_SPARK_PLAN_TYPE = 'IGNORED_SPARK_PLAN_TYPE',
27
+ }
28
+
29
+ export enum QueryStatementType {
30
+ OTHER = 'OTHER',
31
+ ALTER = 'ALTER',
32
+ ANALYZE = 'ANALYZE',
33
+ COPY = 'COPY',
34
+ CREATE = 'CREATE',
35
+ DELETE = 'DELETE',
36
+ DESCRIBE = 'DESCRIBE',
37
+ DROP = 'DROP',
38
+ EXPLAIN = 'EXPLAIN',
39
+ GRANT = 'GRANT',
40
+ INSERT = 'INSERT',
41
+ MERGE = 'MERGE',
42
+ OPTIMIZE = 'OPTIMIZE',
43
+ REFRESH = 'REFRESH',
44
+ REPLACE = 'REPLACE',
45
+ REVOKE = 'REVOKE',
46
+ SELECT = 'SELECT',
47
+ SET = 'SET',
48
+ SHOW = 'SHOW',
49
+ TRUNCATE = 'TRUNCATE',
50
+ UPDATE = 'UPDATE',
51
+ USE = 'USE',
52
+ }
53
+
54
+ /**
55
+ * Statuses which are also used by OperationStatus in runtime.
56
+ * When adding a new QueryStatus, make sure to update com.databricks.sqlgateway.history.QueryStatusOrdering
57
+ */
58
+ export enum QueryStatus {
59
+ /** query has been received and queued */
60
+ QUEUED = 'QUEUED',
61
+ /**
62
+ * query has been received and started by the driver
63
+ * DEPRECATED: to be removed once runtime side change is picked up.
64
+ */
65
+ STARTED = 'STARTED',
66
+ /**
67
+ * query compilation has been started
68
+ * This isn't currently used. We will soon use this.
69
+ */
70
+ COMPILING = 'COMPILING',
71
+ /**
72
+ * query has been compiled
73
+ * DEPRECATED: to be removed once runtime side change is picked up.
74
+ */
75
+ COMPILED = 'COMPILED',
76
+ /**
77
+ * currently execution has been started (spark jobs for this query has been started running)
78
+ * detail ui is available from this state
79
+ */
80
+ RUNNING = 'RUNNING',
81
+ /** query has been cancelled by the user */
82
+ CANCELED = 'CANCELED',
83
+ /** query has failed */
84
+ FAILED = 'FAILED',
85
+ /** query execution has been completed */
86
+ FINISHED = 'FINISHED',
87
+ }
88
+
89
+ /** Details about a Channel. */
90
+ export interface ChannelInfo {
91
+ /** Name of the channel */
92
+ name?: ChannelName | undefined;
93
+ /** DB SQL Version the Channel is mapped to. */
94
+ dbsqlVersion?: string | undefined;
95
+ }
96
+
97
+ export interface ExternalQuerySource {
98
+ /** The canonical identifier for this Lakeview dashboard */
99
+ dashboardId?: string | undefined;
100
+ /** The canonical identifier for this legacy dashboard */
101
+ legacyDashboardId?: string | undefined;
102
+ /** The canonical identifier for this SQL alert */
103
+ alertId?: string | undefined;
104
+ /** The canonical identifier for this notebook */
105
+ notebookId?: string | undefined;
106
+ /** The canonical identifier for this SQL query */
107
+ sqlQueryId?: string | undefined;
108
+ jobInfo?: ExternalQuerySource_JobInfo | undefined;
109
+ /** The canonical identifier for this Genie space */
110
+ genieSpaceId?: string | undefined;
111
+ }
112
+
113
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
114
+ export interface ExternalQuerySource_JobInfo {
115
+ /** The canonical identifier for this job. */
116
+ jobId?: string | undefined;
117
+ /** The canonical identifier of the run. This ID is unique across all runs of all jobs. */
118
+ jobRunId?: string | undefined;
119
+ /** The canonical identifier of the task run. */
120
+ jobTaskRunId?: string | undefined;
121
+ }
122
+
123
+ /**
124
+ * Fetches a list of queries conforming to the provided set of query filters.
125
+ *
126
+ * If the the number of queries to return takes > 10 seconds, the request will timeout.
127
+ * In that case, please reduce the time range to ensure ListQueries conforms to the 10 second max query time limit.
128
+ */
129
+ export interface ListQueriesRequest {
130
+ /**
131
+ * An optional filter object to limit query history results. Accepts parameters such as user IDs, endpoint IDs, and statuses to narrow the returned data.
132
+ * In a URL, the parameters of this filter are specified with dot notation. For example: `filter_by.statement_ids`.
133
+ */
134
+ filterBy?: QueryFilter | undefined;
135
+ /** Limit the number of results returned in one page. Must be less than 1000 and the default is 100. */
136
+ maxResults?: number | undefined;
137
+ /**
138
+ * A token that can be used to get the next page of results. The token can contains characters that need to be encoded before using it in a URL.
139
+ * For example, the character '+' needs to be replaced by %2B. This field is optional.
140
+ */
141
+ pageToken?: string | undefined;
142
+ /**
143
+ * Whether to include the query metrics with each query.
144
+ * Only use this for a small subset of queries (max_results).
145
+ * Defaults to false.
146
+ */
147
+ includeMetrics?: boolean | undefined;
148
+ }
149
+
150
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
151
+ export interface ListQueriesRequest_Response {
152
+ /** A token that can be used to get the next page of results. */
153
+ nextPageToken?: string | undefined;
154
+ /** Whether there is another page of results. */
155
+ hasNextPage?: boolean | undefined;
156
+ res?: QueryInfo[] | undefined;
157
+ }
158
+
159
+ export interface QueryFilter {
160
+ /** A range filter for query submitted time. The time range must be less than or equal to 30 days. */
161
+ queryStartTimeRange?: TimeRange | undefined;
162
+ /** A list of user IDs who ran the queries. */
163
+ userIds?: bigint[] | undefined;
164
+ /**
165
+ * A list of statuses (QUEUED, RUNNING, CANCELED, FAILED, FINISHED) to match query results. Corresponds to
166
+ * the `status` field in the response.
167
+ * Filtering for multiple statuses is not recommended. Instead, opt to filter by a single status
168
+ * multiple times and then combine the results.
169
+ */
170
+ statuses?: QueryStatus[] | undefined;
171
+ /** A list of warehouse IDs. */
172
+ warehouseIds?: string[] | undefined;
173
+ /** A list of statement IDs. */
174
+ statementIds?: string[] | undefined;
175
+ }
176
+
177
+ export interface QueryInfo {
178
+ /** The query ID. */
179
+ queryId?: string | undefined;
180
+ /**
181
+ * Query status with one the following values:
182
+ *
183
+ * - `QUEUED`: Query has been received and queued.
184
+ * - `RUNNING`: Query has started.
185
+ * - `CANCELED`: Query has been cancelled by the user.
186
+ * - `FAILED`: Query has failed.
187
+ * - `FINISHED`: Query has completed.
188
+ */
189
+ status?: QueryStatus | undefined;
190
+ /** The text of the query. */
191
+ queryText?: string | undefined;
192
+ /** The time the query started. */
193
+ queryStartTimeMs?: bigint | undefined;
194
+ /** The time execution of the query ended. */
195
+ executionEndTimeMs?: bigint | undefined;
196
+ /** The time the query ended. */
197
+ queryEndTimeMs?: bigint | undefined;
198
+ /** The ID of the user who ran the query. */
199
+ userId?: bigint | undefined;
200
+ /** The email address or username of the user who ran the query. */
201
+ userName?: string | undefined;
202
+ /** URL to the Spark UI query plan. */
203
+ sparkUiUrl?: string | undefined;
204
+ /** Alias for `warehouse_id`. */
205
+ endpointId?: string | undefined;
206
+ /** The number of results returned by the query. */
207
+ rowsProduced?: bigint | undefined;
208
+ /** Message describing why the query could not complete. */
209
+ errorMessage?: string | undefined;
210
+ /** A key that can be used to look up query details. */
211
+ lookupKey?: string | undefined;
212
+ /** Metrics about query execution. */
213
+ metrics?: QueryMetrics | undefined;
214
+ /** The ID of the user whose credentials were used to run the query. */
215
+ executedAsUserId?: bigint | undefined;
216
+ /** The email address or username of the user whose credentials were used to run the query. */
217
+ executedAsUserName?: string | undefined;
218
+ /**
219
+ * The spark session UUID that query ran on.
220
+ * This is either the Spark Connect, DBSQL, or SDP session ID.
221
+ */
222
+ sessionId?: string | undefined;
223
+ /** Whether more updates for the query are expected. */
224
+ isFinal?: boolean | undefined;
225
+ /** SQL Warehouse channel information at the time of query execution */
226
+ channelUsed?: ChannelInfo | undefined;
227
+ /** Whether plans exist for the execution, or the reason why they are missing */
228
+ plansState?: PlansState | undefined;
229
+ /** Type of statement for this query */
230
+ statementType?: QueryStatementType | undefined;
231
+ /** Warehouse ID. */
232
+ warehouseId?: string | undefined;
233
+ /**
234
+ * Total time of the statement execution. This value does not include the time taken to retrieve the results, which
235
+ * can result in a discrepancy between this value and the start-to-finish wall-clock time.
236
+ */
237
+ duration?: bigint | undefined;
238
+ /**
239
+ * Client application that ran the statement. For example: Databricks SQL Editor, Tableau, and Power BI.
240
+ * This field is derived from information provided by client applications. While values are expected to
241
+ * remain static over time, this cannot be guaranteed.
242
+ */
243
+ clientApplication?: string | undefined;
244
+ /**
245
+ * A struct that contains key-value pairs representing <Databricks> entities that were involved in the execution
246
+ * of this statement, such as jobs, notebooks, or dashboards. This field only records <Databricks> entities.
247
+ */
248
+ querySource?: ExternalQuerySource | undefined;
249
+ /** The ID of the cached query if this result retrieved from cache */
250
+ cacheQueryId?: string | undefined;
251
+ /** A query execution can be optionally annotated with query tags */
252
+ queryTags?: QueryTag[] | undefined;
253
+ }
254
+
255
+ /**
256
+ * A query metric that encapsulates a set of measurements for a single query.
257
+ * Metrics come from the driver and are stored in the history service database.
258
+ */
259
+ export interface QueryMetrics {
260
+ /** Total execution time of the query from the client’s point of view, in milliseconds. */
261
+ totalTimeMs?: bigint | undefined;
262
+ /** Total size of data read by the query, in bytes. */
263
+ readBytes?: bigint | undefined;
264
+ /** Total number of rows returned by the query. */
265
+ rowsProducedCount?: bigint | undefined;
266
+ /** Time spent loading metadata and optimizing the query, in milliseconds. */
267
+ compilationTimeMs?: bigint | undefined;
268
+ /** Time spent executing the query, in milliseconds. */
269
+ executionTimeMs?: bigint | undefined;
270
+ /** Size of persistent data read from cloud object storage on your cloud tenant, in bytes. */
271
+ readRemoteBytes?: bigint | undefined;
272
+ /** Size pf persistent data written to cloud object storage in your cloud tenant, in bytes. */
273
+ writeRemoteBytes?: bigint | undefined;
274
+ /** Size of persistent data read from the cache, in bytes. */
275
+ readCacheBytes?: bigint | undefined;
276
+ /** Size of data temporarily written to disk while executing the query, in bytes. */
277
+ spillToDiskBytes?: bigint | undefined;
278
+ /** Sum of execution time for all of the query’s tasks, in milliseconds. */
279
+ taskTotalTimeMs?: bigint | undefined;
280
+ /** Number of files read after pruning */
281
+ readFilesCount?: bigint | undefined;
282
+ /** Number of partitions read after pruning. */
283
+ readPartitionsCount?: bigint | undefined;
284
+ /** Total execution time for all individual Photon query engine tasks in the query, in milliseconds. */
285
+ photonTotalTimeMs?: bigint | undefined;
286
+ /** Total number of rows read by the query. */
287
+ rowsReadCount?: bigint | undefined;
288
+ /** Time spent fetching the query results after the execution finished, in milliseconds. */
289
+ resultFetchTimeMs?: bigint | undefined;
290
+ /** Total amount of data sent over the network between executor nodes during shuffle, in bytes. */
291
+ networkSentBytes?: bigint | undefined;
292
+ /** `true` if the query result was fetched from cache, `false` otherwise. */
293
+ resultFromCache?: boolean | undefined;
294
+ /** Total number of file bytes in all tables not read due to pruning */
295
+ prunedBytes?: bigint | undefined;
296
+ /** Total number of files from all tables not read due to pruning */
297
+ prunedFilesCount?: bigint | undefined;
298
+ /**
299
+ * Timestamp of when the query was enqueued waiting for a cluster to be provisioned for the warehouse.
300
+ * This field is optional and will not appear if the query skipped the provisioning queue.
301
+ */
302
+ provisioningQueueStartTimestamp?: bigint | undefined;
303
+ /**
304
+ * Timestamp of when the query was enqueued waiting while the warehouse was at max load.
305
+ * This field is optional and will not appear if the query skipped the overloading queue.
306
+ */
307
+ overloadingQueueStartTimestamp?: bigint | undefined;
308
+ /** Timestamp of when the underlying compute started compilation of the query. */
309
+ queryCompilationStartTimestamp?: bigint | undefined;
310
+ /**
311
+ * sum of task times completed in a range of wall clock time, approximated to a configurable number of points
312
+ * aggregated over all stages and jobs in the query (based on task_total_time_ms)
313
+ */
314
+ taskTimeOverTimeRange?: TaskTimeOverRange | undefined;
315
+ /**
316
+ * remaining work to be done across all stages in the query, calculated by autoscaler StatementAnalysis.scala, in milliseconds
317
+ * deprecated: using projected_remaining_task_total_time_ms instead
318
+ */
319
+ workToBeDone?: bigint | undefined;
320
+ /**
321
+ * number of remaining tasks to complete, calculated by autoscaler StatementAnalysis.scala
322
+ * deprecated: use remaining_task_count instead
323
+ */
324
+ runnableTasks?: bigint | undefined;
325
+ /** projected remaining work to be done aggregated across all stages in the query, in milliseconds */
326
+ projectedRemainingTaskTotalTimeMs?: bigint | undefined;
327
+ /**
328
+ * number of remaining tasks to complete
329
+ * this is based on the current status and could be bigger or smaller in the future based on future updates
330
+ */
331
+ remainingTaskCount?: bigint | undefined;
332
+ /** projected lower bound on remaining total task time based on projected_remaining_task_total_time_ms / maximum concurrency */
333
+ projectedRemainingWallclockTimeMs?: bigint | undefined;
334
+ /** Total number of file bytes in all tables read */
335
+ readFilesBytes?: bigint | undefined;
336
+ }
337
+
338
+ /**
339
+ * * A query execution can be annotated with an optional key-value pair to
340
+ * allow users to attribute the executions by key and optional value to filter by.
341
+ * QueryTag is the user-facing representation.
342
+ */
343
+ export interface QueryTag {
344
+ key?: string | undefined;
345
+ value?: string | undefined;
346
+ }
347
+
348
+ export interface TaskTimeOverRange {
349
+ entries?: TaskTimeOverRangeEntry[] | undefined;
350
+ /**
351
+ * interval length for all entries (difference in start time and end time of an entry range)
352
+ * the same for all entries
353
+ * start time of first interval is query_start_time_ms
354
+ */
355
+ interval?: bigint | undefined;
356
+ }
357
+
358
+ export interface TaskTimeOverRangeEntry {
359
+ /** total task completion time in this time range, aggregated over all stages and jobs in the query */
360
+ taskCompletedTimeMs?: bigint | undefined;
361
+ }
362
+
363
+ export interface TimeRange {
364
+ /** The start time in milliseconds. */
365
+ startTimeMs?: bigint | undefined;
366
+ /** The end time in milliseconds. */
367
+ endTimeMs?: bigint | undefined;
368
+ }
369
+
370
+ export const unmarshalChannelInfoSchema: z.ZodType<ChannelInfo> = z
371
+ .object({
372
+ name: z.enum(ChannelName).optional(),
373
+ dbsql_version: z.string().optional(),
374
+ })
375
+ .transform(d => ({
376
+ name: d.name,
377
+ dbsqlVersion: d.dbsql_version,
378
+ }));
379
+
380
+ export const unmarshalExternalQuerySourceSchema: z.ZodType<ExternalQuerySource> =
381
+ z
382
+ .object({
383
+ dashboard_id: z.string().optional(),
384
+ legacy_dashboard_id: z.string().optional(),
385
+ alert_id: z.string().optional(),
386
+ notebook_id: z.string().optional(),
387
+ sql_query_id: z.string().optional(),
388
+ job_info: z
389
+ .lazy(() => unmarshalExternalQuerySource_JobInfoSchema)
390
+ .optional(),
391
+ genie_space_id: z.string().optional(),
392
+ })
393
+ .transform(d => ({
394
+ dashboardId: d.dashboard_id,
395
+ legacyDashboardId: d.legacy_dashboard_id,
396
+ alertId: d.alert_id,
397
+ notebookId: d.notebook_id,
398
+ sqlQueryId: d.sql_query_id,
399
+ jobInfo: d.job_info,
400
+ genieSpaceId: d.genie_space_id,
401
+ }));
402
+
403
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
404
+ export const unmarshalExternalQuerySource_JobInfoSchema: z.ZodType<ExternalQuerySource_JobInfo> =
405
+ z
406
+ .object({
407
+ job_id: z.string().optional(),
408
+ job_run_id: z.string().optional(),
409
+ job_task_run_id: z.string().optional(),
410
+ })
411
+ .transform(d => ({
412
+ jobId: d.job_id,
413
+ jobRunId: d.job_run_id,
414
+ jobTaskRunId: d.job_task_run_id,
415
+ }));
416
+
417
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name.
418
+ export const unmarshalListQueriesRequest_ResponseSchema: z.ZodType<ListQueriesRequest_Response> =
419
+ z
420
+ .object({
421
+ next_page_token: z.string().optional(),
422
+ has_next_page: z.boolean().optional(),
423
+ res: z.array(z.lazy(() => unmarshalQueryInfoSchema)).optional(),
424
+ })
425
+ .transform(d => ({
426
+ nextPageToken: d.next_page_token,
427
+ hasNextPage: d.has_next_page,
428
+ res: d.res,
429
+ }));
430
+
431
+ export const unmarshalQueryInfoSchema: z.ZodType<QueryInfo> = z
432
+ .object({
433
+ query_id: z.string().optional(),
434
+ status: z.enum(QueryStatus).optional(),
435
+ query_text: z.string().optional(),
436
+ query_start_time_ms: z
437
+ .union([z.number(), z.bigint()])
438
+ .transform(v => BigInt(v))
439
+ .optional(),
440
+ execution_end_time_ms: z
441
+ .union([z.number(), z.bigint()])
442
+ .transform(v => BigInt(v))
443
+ .optional(),
444
+ query_end_time_ms: z
445
+ .union([z.number(), z.bigint()])
446
+ .transform(v => BigInt(v))
447
+ .optional(),
448
+ user_id: z
449
+ .union([z.number(), z.bigint()])
450
+ .transform(v => BigInt(v))
451
+ .optional(),
452
+ user_name: z.string().optional(),
453
+ spark_ui_url: z.string().optional(),
454
+ endpoint_id: z.string().optional(),
455
+ rows_produced: z
456
+ .union([z.number(), z.bigint()])
457
+ .transform(v => BigInt(v))
458
+ .optional(),
459
+ error_message: z.string().optional(),
460
+ lookup_key: z.string().optional(),
461
+ metrics: z.lazy(() => unmarshalQueryMetricsSchema).optional(),
462
+ executed_as_user_id: z
463
+ .union([z.number(), z.bigint()])
464
+ .transform(v => BigInt(v))
465
+ .optional(),
466
+ executed_as_user_name: z.string().optional(),
467
+ session_id: z.string().optional(),
468
+ is_final: z.boolean().optional(),
469
+ channel_used: z.lazy(() => unmarshalChannelInfoSchema).optional(),
470
+ plans_state: z.enum(PlansState).optional(),
471
+ statement_type: z.enum(QueryStatementType).optional(),
472
+ warehouse_id: z.string().optional(),
473
+ duration: z
474
+ .union([z.number(), z.bigint()])
475
+ .transform(v => BigInt(v))
476
+ .optional(),
477
+ client_application: z.string().optional(),
478
+ query_source: z.lazy(() => unmarshalExternalQuerySourceSchema).optional(),
479
+ cache_query_id: z.string().optional(),
480
+ query_tags: z.array(z.lazy(() => unmarshalQueryTagSchema)).optional(),
481
+ })
482
+ .transform(d => ({
483
+ queryId: d.query_id,
484
+ status: d.status,
485
+ queryText: d.query_text,
486
+ queryStartTimeMs: d.query_start_time_ms,
487
+ executionEndTimeMs: d.execution_end_time_ms,
488
+ queryEndTimeMs: d.query_end_time_ms,
489
+ userId: d.user_id,
490
+ userName: d.user_name,
491
+ sparkUiUrl: d.spark_ui_url,
492
+ endpointId: d.endpoint_id,
493
+ rowsProduced: d.rows_produced,
494
+ errorMessage: d.error_message,
495
+ lookupKey: d.lookup_key,
496
+ metrics: d.metrics,
497
+ executedAsUserId: d.executed_as_user_id,
498
+ executedAsUserName: d.executed_as_user_name,
499
+ sessionId: d.session_id,
500
+ isFinal: d.is_final,
501
+ channelUsed: d.channel_used,
502
+ plansState: d.plans_state,
503
+ statementType: d.statement_type,
504
+ warehouseId: d.warehouse_id,
505
+ duration: d.duration,
506
+ clientApplication: d.client_application,
507
+ querySource: d.query_source,
508
+ cacheQueryId: d.cache_query_id,
509
+ queryTags: d.query_tags,
510
+ }));
511
+
512
+ export const unmarshalQueryMetricsSchema: z.ZodType<QueryMetrics> = z
513
+ .object({
514
+ total_time_ms: z
515
+ .union([z.number(), z.bigint()])
516
+ .transform(v => BigInt(v))
517
+ .optional(),
518
+ read_bytes: z
519
+ .union([z.number(), z.bigint()])
520
+ .transform(v => BigInt(v))
521
+ .optional(),
522
+ rows_produced_count: z
523
+ .union([z.number(), z.bigint()])
524
+ .transform(v => BigInt(v))
525
+ .optional(),
526
+ compilation_time_ms: z
527
+ .union([z.number(), z.bigint()])
528
+ .transform(v => BigInt(v))
529
+ .optional(),
530
+ execution_time_ms: z
531
+ .union([z.number(), z.bigint()])
532
+ .transform(v => BigInt(v))
533
+ .optional(),
534
+ read_remote_bytes: z
535
+ .union([z.number(), z.bigint()])
536
+ .transform(v => BigInt(v))
537
+ .optional(),
538
+ write_remote_bytes: z
539
+ .union([z.number(), z.bigint()])
540
+ .transform(v => BigInt(v))
541
+ .optional(),
542
+ read_cache_bytes: z
543
+ .union([z.number(), z.bigint()])
544
+ .transform(v => BigInt(v))
545
+ .optional(),
546
+ spill_to_disk_bytes: z
547
+ .union([z.number(), z.bigint()])
548
+ .transform(v => BigInt(v))
549
+ .optional(),
550
+ task_total_time_ms: z
551
+ .union([z.number(), z.bigint()])
552
+ .transform(v => BigInt(v))
553
+ .optional(),
554
+ read_files_count: z
555
+ .union([z.number(), z.bigint()])
556
+ .transform(v => BigInt(v))
557
+ .optional(),
558
+ read_partitions_count: z
559
+ .union([z.number(), z.bigint()])
560
+ .transform(v => BigInt(v))
561
+ .optional(),
562
+ photon_total_time_ms: z
563
+ .union([z.number(), z.bigint()])
564
+ .transform(v => BigInt(v))
565
+ .optional(),
566
+ rows_read_count: z
567
+ .union([z.number(), z.bigint()])
568
+ .transform(v => BigInt(v))
569
+ .optional(),
570
+ result_fetch_time_ms: z
571
+ .union([z.number(), z.bigint()])
572
+ .transform(v => BigInt(v))
573
+ .optional(),
574
+ network_sent_bytes: z
575
+ .union([z.number(), z.bigint()])
576
+ .transform(v => BigInt(v))
577
+ .optional(),
578
+ result_from_cache: z.boolean().optional(),
579
+ pruned_bytes: z
580
+ .union([z.number(), z.bigint()])
581
+ .transform(v => BigInt(v))
582
+ .optional(),
583
+ pruned_files_count: z
584
+ .union([z.number(), z.bigint()])
585
+ .transform(v => BigInt(v))
586
+ .optional(),
587
+ provisioning_queue_start_timestamp: z
588
+ .union([z.number(), z.bigint()])
589
+ .transform(v => BigInt(v))
590
+ .optional(),
591
+ overloading_queue_start_timestamp: z
592
+ .union([z.number(), z.bigint()])
593
+ .transform(v => BigInt(v))
594
+ .optional(),
595
+ query_compilation_start_timestamp: z
596
+ .union([z.number(), z.bigint()])
597
+ .transform(v => BigInt(v))
598
+ .optional(),
599
+ task_time_over_time_range: z
600
+ .lazy(() => unmarshalTaskTimeOverRangeSchema)
601
+ .optional(),
602
+ work_to_be_done: z
603
+ .union([z.number(), z.bigint()])
604
+ .transform(v => BigInt(v))
605
+ .optional(),
606
+ runnable_tasks: z
607
+ .union([z.number(), z.bigint()])
608
+ .transform(v => BigInt(v))
609
+ .optional(),
610
+ projected_remaining_task_total_time_ms: z
611
+ .union([z.number(), z.bigint()])
612
+ .transform(v => BigInt(v))
613
+ .optional(),
614
+ remaining_task_count: z
615
+ .union([z.number(), z.bigint()])
616
+ .transform(v => BigInt(v))
617
+ .optional(),
618
+ projected_remaining_wallclock_time_ms: z
619
+ .union([z.number(), z.bigint()])
620
+ .transform(v => BigInt(v))
621
+ .optional(),
622
+ read_files_bytes: z
623
+ .union([z.number(), z.bigint()])
624
+ .transform(v => BigInt(v))
625
+ .optional(),
626
+ })
627
+ .transform(d => ({
628
+ totalTimeMs: d.total_time_ms,
629
+ readBytes: d.read_bytes,
630
+ rowsProducedCount: d.rows_produced_count,
631
+ compilationTimeMs: d.compilation_time_ms,
632
+ executionTimeMs: d.execution_time_ms,
633
+ readRemoteBytes: d.read_remote_bytes,
634
+ writeRemoteBytes: d.write_remote_bytes,
635
+ readCacheBytes: d.read_cache_bytes,
636
+ spillToDiskBytes: d.spill_to_disk_bytes,
637
+ taskTotalTimeMs: d.task_total_time_ms,
638
+ readFilesCount: d.read_files_count,
639
+ readPartitionsCount: d.read_partitions_count,
640
+ photonTotalTimeMs: d.photon_total_time_ms,
641
+ rowsReadCount: d.rows_read_count,
642
+ resultFetchTimeMs: d.result_fetch_time_ms,
643
+ networkSentBytes: d.network_sent_bytes,
644
+ resultFromCache: d.result_from_cache,
645
+ prunedBytes: d.pruned_bytes,
646
+ prunedFilesCount: d.pruned_files_count,
647
+ provisioningQueueStartTimestamp: d.provisioning_queue_start_timestamp,
648
+ overloadingQueueStartTimestamp: d.overloading_queue_start_timestamp,
649
+ queryCompilationStartTimestamp: d.query_compilation_start_timestamp,
650
+ taskTimeOverTimeRange: d.task_time_over_time_range,
651
+ workToBeDone: d.work_to_be_done,
652
+ runnableTasks: d.runnable_tasks,
653
+ projectedRemainingTaskTotalTimeMs: d.projected_remaining_task_total_time_ms,
654
+ remainingTaskCount: d.remaining_task_count,
655
+ projectedRemainingWallclockTimeMs: d.projected_remaining_wallclock_time_ms,
656
+ readFilesBytes: d.read_files_bytes,
657
+ }));
658
+
659
+ export const unmarshalQueryTagSchema: z.ZodType<QueryTag> = z
660
+ .object({
661
+ key: z.string().optional(),
662
+ value: z.string().optional(),
663
+ })
664
+ .transform(d => ({
665
+ key: d.key,
666
+ value: d.value,
667
+ }));
668
+
669
+ export const unmarshalTaskTimeOverRangeSchema: z.ZodType<TaskTimeOverRange> = z
670
+ .object({
671
+ entries: z
672
+ .array(z.lazy(() => unmarshalTaskTimeOverRangeEntrySchema))
673
+ .optional(),
674
+ interval: z
675
+ .union([z.number(), z.bigint()])
676
+ .transform(v => BigInt(v))
677
+ .optional(),
678
+ })
679
+ .transform(d => ({
680
+ entries: d.entries,
681
+ interval: d.interval,
682
+ }));
683
+
684
+ export const unmarshalTaskTimeOverRangeEntrySchema: z.ZodType<TaskTimeOverRangeEntry> =
685
+ z
686
+ .object({
687
+ task_completed_time_ms: z
688
+ .union([z.number(), z.bigint()])
689
+ .transform(v => BigInt(v))
690
+ .optional(),
691
+ })
692
+ .transform(d => ({
693
+ taskCompletedTimeMs: d.task_completed_time_ms,
694
+ }));
695
+
696
+ export const marshalQueryFilterSchema: z.ZodType = z
697
+ .object({
698
+ queryStartTimeRange: z.lazy(() => marshalTimeRangeSchema).optional(),
699
+ userIds: z.array(z.bigint()).optional(),
700
+ statuses: z.array(z.enum(QueryStatus)).optional(),
701
+ warehouseIds: z.array(z.string()).optional(),
702
+ statementIds: z.array(z.string()).optional(),
703
+ })
704
+ .transform(d => ({
705
+ query_start_time_range: d.queryStartTimeRange,
706
+ user_ids: d.userIds,
707
+ statuses: d.statuses,
708
+ warehouse_ids: d.warehouseIds,
709
+ statement_ids: d.statementIds,
710
+ }));
711
+
712
+ export const marshalTimeRangeSchema: z.ZodType = z
713
+ .object({
714
+ startTimeMs: z.bigint().optional(),
715
+ endTimeMs: z.bigint().optional(),
716
+ })
717
+ .transform(d => ({
718
+ start_time_ms: d.startTimeMs,
719
+ end_time_ms: d.endTimeMs,
720
+ }));