Query
QueryInfo object
- query_idstring
The query ID.
- statusstring
Query status with one the following values:
QUEUED: Query has been received and queued.RUNNING: Query has started.CANCELED: Query has been cancelled by the user.FAILED: Query has failed.FINISHED: Query has completed.
- query_textstring
The text of the query.
- query_start_time_msint64
The time the query started.
- execution_end_time_msint64
The time execution of the query ended.
- query_end_time_msint64
The time the query ended.
- user_idint64
The ID of the user who ran the query.
- user_namestring
The email address or username of the user who ran the query.
- spark_ui_urlstring
URL to the Spark UI query plan.
- endpoint_idstring
Alias for
warehouse_id.
- rows_producedint64
The number of results returned by the query.
- error_messagestring
Message describing why the query could not complete.
- lookup_keystring
A key that can be used to look up query details.
- metricsobject
Metrics about query execution.
Show child attributesHide child attributes
- total_time_msint64
Total execution time of the query from the client’s point of view, in milliseconds.
- read_bytesint64
Total size of data read by the query, in bytes.
- rows_produced_countint64
Total number of rows returned by the query.
- compilation_time_msint64
Time spent loading metadata and optimizing the query, in milliseconds.
- execution_time_msint64
Time spent executing the query, in milliseconds.
- read_remote_bytesint64
Size of persistent data read from cloud object storage on your cloud tenant, in bytes.
- write_remote_bytesint64
Size pf persistent data written to cloud object storage in your cloud tenant, in bytes.
- read_cache_bytesint64
Size of persistent data read from the cache, in bytes.
- spill_to_disk_bytesint64
Size of data temporarily written to disk while executing the query, in bytes.
- task_total_time_msint64
Sum of execution time for all of the query’s tasks, in milliseconds.
- read_files_countint64
Number of files read after pruning
- read_partitions_countint64
Number of partitions read after pruning.
- photon_total_time_msint64
Total execution time for all individual Photon query engine tasks in the query, in milliseconds.
- rows_read_countint64
Total number of rows read by the query.
- result_fetch_time_msint64
Time spent fetching the query results after the execution finished, in milliseconds.
- network_sent_bytesint64
Total amount of data sent over the network between executor nodes during shuffle, in bytes.
- result_from_cacheboolean
trueif the query result was fetched from cache,falseotherwise.
- pruned_bytesint64
Total number of file bytes in all tables not read due to pruning
- pruned_files_countint64
Total number of files from all tables not read due to pruning
- provisioning_queue_start_timestampint64
Timestamp of when the query was enqueued waiting for a cluster to be provisioned for the warehouse. This field is optional and will not appear if the query skipped the provisioning queue.
- overloading_queue_start_timestampint64
Timestamp of when the query was enqueued waiting while the warehouse was at max load. This field is optional and will not appear if the query skipped the overloading queue.
- query_compilation_start_timestampint64
Timestamp of when the underlying compute started compilation of the query.
- task_time_over_time_rangeobject
sum of task times completed in a range of wall clock time, approximated to a configurable number of points aggregated over all stages and jobs in the query (based on task_total_time_ms)
Show child attributesHide child attributes
- entriesarray of object
Show child attributesHide child attributes
- task_completed_time_msint64
total task completion time in this time range, aggregated over all stages and jobs in the query
- intervalint64
interval length for all entries (difference in start time and end time of an entry range) the same for all entries start time of first interval is query_start_time_ms
- work_to_be_doneint64
remaining work to be done across all stages in the query, calculated by autoscaler StatementAnalysis.scala, in milliseconds deprecated: using projected_remaining_task_total_time_ms instead
- runnable_tasksint64
number of remaining tasks to complete, calculated by autoscaler StatementAnalysis.scala deprecated: use remaining_task_count instead
- projected_remaining_task_total_time_msint64
projected remaining work to be done aggregated across all stages in the query, in milliseconds
- remaining_task_countint64
number of remaining tasks to complete this is based on the current status and could be bigger or smaller in the future based on future updates
- projected_remaining_wallclock_time_msint64
projected lower bound on remaining total task time based on projected_remaining_task_total_time_ms / maximum concurrency
- read_files_bytesint64
Total number of file bytes in all tables read
- executed_as_user_idint64
The ID of the user whose credentials were used to run the query.
- executed_as_user_namestring
The email address or username of the user whose credentials were used to run the query.
- session_idstring
The spark session UUID that query ran on. This is either the Spark Connect, DBSQL, or SDP session ID.
- is_finalboolean
Whether more updates for the query are expected.
- channel_usedobject
SQL Warehouse channel information at the time of query execution
Show child attributesHide child attributes
- namestring
Name of the channel
- dbsql_versionstring
DB SQL Version the Channel is mapped to.
- plans_statestring
Whether plans exist for the execution, or the reason why they are missing
- statement_typestring
Type of statement for this query
- warehouse_idstring
Warehouse ID.
- durationint64
Total time of the statement execution. This value does not include the time taken to retrieve the results, which can result in a discrepancy between this value and the start-to-finish wall-clock time.
- client_applicationstring
Client application that ran the statement. For example: Databricks SQL Editor, Tableau, and Power BI. This field is derived from information provided by client applications. While values are expected to remain static over time, this cannot be guaranteed.
- query_sourceobject
A struct that contains key-value pairs representing <Databricks> entities that were involved in the execution of this statement, such as jobs, notebooks, or dashboards. This field only records <Databricks> entities.
Show child attributesHide child attributes
- dashboard_idstring
The canonical identifier for this Lakeview dashboard
- legacy_dashboard_idstring
The canonical identifier for this legacy dashboard
- alert_idstring
The canonical identifier for this SQL alert
- notebook_idstring
The canonical identifier for this notebook
- sql_query_idstring
The canonical identifier for this SQL query
- job_infoobject
Show child attributesHide child attributes
- job_idstring
The canonical identifier for this job.
- job_run_idstring
The canonical identifier of the run. This ID is unique across all runs of all jobs.
- job_task_run_idstring
The canonical identifier of the task run.
- genie_space_idstring
The canonical identifier for this Genie space
- cache_query_idstring
The ID of the cached query if this result retrieved from cache
- query_tagsarray of object
A query execution can be optionally annotated with query tags
Show child attributesHide child attributes
- keystring
- valuestring
List
GET
List the history of queries through SQL warehouses, and serverless compute.
You can filter by user ID, warehouse ID, status, and time range. Most recently started queries are returned first (up to max_results in request). The pagination token returned in response can be used to list subsequent query statuses.
API scopes: query-history
Parameters
- filter_byobjectquery
An optional filter object to limit query history results. Accepts parameters such as user IDs, endpoint IDs, and statuses to narrow the returned data. In a URL, the parameters of this filter are specified with dot notation. For example:
filter_by.statement_ids.Show child attributesHide child attributes
- query_start_time_rangeobject
A range filter for query submitted time. The time range must be less than or equal to 30 days.
Show child attributesHide child attributes
- start_time_msint64
The start time in milliseconds.
- end_time_msint64
The end time in milliseconds.
- user_idsarray of int64
A list of user IDs who ran the queries.
- statusesarray of string
A list of statuses (QUEUED, RUNNING, CANCELED, FAILED, FINISHED) to match query results. Corresponds to the
statusfield in the response. Filtering for multiple statuses is not recommended. Instead, opt to filter by a single status multiple times and then combine the results.
- warehouse_idsarray of string
A list of warehouse IDs.
- statement_idsarray of string
A list of statement IDs.
- max_resultsint32query
Limit the number of results returned in one page. Must be less than 1000 and the default is 100.
- page_tokenstringquery
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. For example, the character '+' needs to be replaced by %2B. This field is optional.
- include_metricsbooleanquery
Whether to include the query metrics with each query. Only use this for a small subset of queries (max_results). Defaults to false.
Response
Returns a list of QueryInfo objects.