Skip to main content

query_history

Creates, updates, deletes, gets or lists a query_history resource.

Overview

Namequery_history
TypeResource
Iddatabricks_workspace.sql.query_history

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
has_next_pageboolean
next_page_tokenstringA token that can be used to get the next page of results.
resarray

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectdeployment_namefilter_by, include_metrics, max_results, page_tokenList the history of queries through SQL warehouses, and serverless compute.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
deployment_namestringThe Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc)
filter_byobjectAn 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.
include_metricsbooleanWhether to include the query metrics with each query. Only use this for a small subset of queries (max_results). Defaults to false.
max_resultsintegerLimit the number of results returned in one page. Must be less than 1000 and the default is 100.
page_tokenstringA 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.

SELECT examples

List the history of queries through SQL warehouses, and serverless compute.

SELECT
has_next_page,
next_page_token,
res
FROM databricks_workspace.sql.query_history
WHERE deployment_name = '{{ deployment_name }}' -- required
AND filter_by = '{{ filter_by }}'
AND include_metrics = '{{ include_metrics }}'
AND max_results = '{{ max_results }}'
AND page_token = '{{ page_token }}'
;