queries
Creates, updates, deletes, gets or lists a queries resource.
Overview
| Name | queries |
| Type | Resource |
| Id | databricks_workspace.sql.queries |
Fields
The following fields are returned by SELECT queries:
- get
- list
| Name | Datatype | Description |
|---|---|---|
id | string | UUID identifying the query. |
warehouse_id | string | ID of the SQL warehouse attached to the query. |
display_name | string | Display name of the query that appears in list views, widget headings, and on the query page. |
last_modifier_user_name | string | Username of the user who last saved changes to this query. |
owner_user_name | string | Username of the user that owns the query. |
apply_auto_limit | boolean | |
catalog | string | Name of the catalog where this query will be executed. |
create_time | string | Timestamp when this query was created. |
description | string | General description that conveys additional information about this query such as usage notes. |
lifecycle_state | string | Indicates whether the query is trashed. (ACTIVE, TRASHED) |
parameters | array | List of query parameter definitions. |
parent_path | string | Workspace path of the workspace folder containing the object. |
query_text | string | Text of the query to be run. |
run_as_mode | string | Sets the "Run as" role for the object. (OWNER, VIEWER) |
schema | string | Name of the schema where this query will be executed. |
tags | array | |
update_time | string | Timestamp when this query was last updated. |
| Name | Datatype | Description |
|---|---|---|
id | string | UUID identifying the query. |
warehouse_id | string | ID of the SQL warehouse attached to the query. |
display_name | string | Display name of the query that appears in list views, widget headings, and on the query page. |
last_modifier_user_name | string | Username of the user who last saved changes to this query. |
owner_user_name | string | Username of the user that owns the query. |
apply_auto_limit | boolean | |
catalog | string | Name of the catalog where this query will be executed. |
create_time | string | Timestamp when this query was created. |
description | string | General description that conveys additional information about this query such as usage notes. |
lifecycle_state | string | Indicates whether the query is trashed. (ACTIVE, TRASHED) |
parameters | array | List of query parameter definitions. |
query_text | string | Text of the query to be run. |
run_as_mode | string | Sets the "Run as" role for the object. (OWNER, VIEWER) |
schema | string | Name of the schema where this query will be executed. |
tags | array | |
update_time | string | Timestamp when this query was last updated. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | id, deployment_name | Gets a query. | |
list | select | deployment_name | page_size, page_token | Gets a list of queries accessible to the user, ordered by creation time. Warning: Calling this API |
create | insert | deployment_name | Creates a query. | |
update | update | id, deployment_name, update_mask | Updates a query. | |
delete | delete | id, deployment_name | Moves a query to the trash. Trashed queries immediately disappear from searches and list views, and |
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.
| Name | Datatype | Description |
|---|---|---|
deployment_name | string | The Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc) |
id | string | str |
page_size | integer | :param page_token: str (optional) |
page_token | string |
SELECT examples
- get
- list
Gets a query.
SELECT
id,
warehouse_id,
display_name,
last_modifier_user_name,
owner_user_name,
apply_auto_limit,
catalog,
create_time,
description,
lifecycle_state,
parameters,
parent_path,
query_text,
run_as_mode,
schema,
tags,
update_time
FROM databricks_workspace.sql.queries
WHERE id = '{{ id }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
;
Gets a list of queries accessible to the user, ordered by creation time. Warning: Calling this API
SELECT
id,
warehouse_id,
display_name,
last_modifier_user_name,
owner_user_name,
apply_auto_limit,
catalog,
create_time,
description,
lifecycle_state,
parameters,
query_text,
run_as_mode,
schema,
tags,
update_time
FROM databricks_workspace.sql.queries
WHERE deployment_name = '{{ deployment_name }}' -- required
AND page_size = '{{ page_size }}'
AND page_token = '{{ page_token }}'
;
INSERT examples
- create
- Manifest
Creates a query.
INSERT INTO databricks_workspace.sql.queries (
auto_resolve_display_name,
query,
deployment_name
)
SELECT
{{ auto_resolve_display_name }},
'{{ query }}',
'{{ deployment_name }}'
RETURNING
id,
warehouse_id,
display_name,
last_modifier_user_name,
owner_user_name,
apply_auto_limit,
catalog,
create_time,
description,
lifecycle_state,
parameters,
parent_path,
query_text,
run_as_mode,
schema,
tags,
update_time
;
# Description fields are for documentation purposes
- name: queries
props:
- name: deployment_name
value: "{{ deployment_name }}"
description: Required parameter for the queries resource.
- name: auto_resolve_display_name
value: {{ auto_resolve_display_name }}
description: |
If true, automatically resolve query display name conflicts. Otherwise, fail the request if the query's display name conflicts with an existing query's display name.
- name: query
description: |
:returns: :class:`Query`
value:
apply_auto_limit: {{ apply_auto_limit }}
catalog: "{{ catalog }}"
description: "{{ description }}"
display_name: "{{ display_name }}"
parameters:
- date_range_value:
date_range_value:
start: "{{ start }}"
end: "{{ end }}"
dynamic_date_range_value: "{{ dynamic_date_range_value }}"
precision: "{{ precision }}"
start_day_of_week: {{ start_day_of_week }}
date_value:
date_value: "{{ date_value }}"
dynamic_date_value: "{{ dynamic_date_value }}"
precision: "{{ precision }}"
enum_value:
enum_options: "{{ enum_options }}"
multi_values_options:
prefix: "{{ prefix }}"
separator: "{{ separator }}"
suffix: "{{ suffix }}"
values:
- "{{ values }}"
name: "{{ name }}"
numeric_value:
value: {{ value }}
query_backed_value:
multi_values_options:
prefix: "{{ prefix }}"
separator: "{{ separator }}"
suffix: "{{ suffix }}"
query_id: "{{ query_id }}"
values:
- "{{ values }}"
text_value:
value: "{{ value }}"
title: "{{ title }}"
parent_path: "{{ parent_path }}"
query_text: "{{ query_text }}"
run_as_mode: "{{ run_as_mode }}"
schema: "{{ schema }}"
tags:
- "{{ tags }}"
warehouse_id: "{{ warehouse_id }}"
UPDATE examples
- update
Updates a query.
UPDATE databricks_workspace.sql.queries
SET
update_mask = '{{ update_mask }}',
auto_resolve_display_name = {{ auto_resolve_display_name }},
query = '{{ query }}'
WHERE
id = '{{ id }}' --required
AND deployment_name = '{{ deployment_name }}' --required
AND update_mask = '{{ update_mask }}' --required
RETURNING
id,
warehouse_id,
display_name,
last_modifier_user_name,
owner_user_name,
apply_auto_limit,
catalog,
create_time,
description,
lifecycle_state,
parameters,
parent_path,
query_text,
run_as_mode,
schema,
tags,
update_time;
DELETE examples
- delete
Moves a query to the trash. Trashed queries immediately disappear from searches and list views, and
DELETE FROM databricks_workspace.sql.queries
WHERE id = '{{ id }}' --required
AND deployment_name = '{{ deployment_name }}' --required
;