Skip to main content

queries

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

Overview

Namequeries
TypeResource
Iddatabricks_workspace.dbsql.queries

Fields

The following fields are returned by SELECT queries:

Request completed successfully.

NameDatatypeDescription
idstring
warehouse_idstring
display_namestring
last_modifier_user_namestring
owner_user_namestring
create_timestring
descriptionstring
lifecycle_statestring
parametersarray
parent_pathstring
query_textstring
run_as_modestring
tagsarray
update_timestring

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectdeployment_nameGets a query.
listselectdeployment_nameGets a list of queries accessible to the user, ordered by creation time.
createinsertdeployment_nameCreates a query.
updateupdatedeployment_nameUpdates a query.
deletedeletedeployment_nameMoves a query to the trash. Trashed queries immediately disappear from searches and list views, and cannot be used for alerts. You can restore a trashed query through the UI. A trashed query is permanently deleted after 30 days.

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)

SELECT examples

Gets a query.

SELECT
id,
warehouse_id,
display_name,
last_modifier_user_name,
owner_user_name,
create_time,
description,
lifecycle_state,
parameters,
parent_path,
query_text,
run_as_mode,
tags,
update_time
FROM databricks_workspace.dbsql.queries
WHERE deployment_name = '{{ deployment_name }}' -- required;

INSERT examples

Creates a query.

INSERT INTO databricks_workspace.dbsql.queries (
data__query,
deployment_name
)
SELECT
'{{ query }}',
'{{ deployment_name }}'
RETURNING
id,
warehouse_id,
display_name,
last_modifier_user_name,
owner_user_name,
create_time,
description,
lifecycle_state,
parameters,
parent_path,
query_text,
run_as_mode,
tags
;

UPDATE examples

Updates a query.

UPDATE databricks_workspace.dbsql.queries
SET
data__update_mask = '{{ update_mask }}',
data__query = '{{ query }}'
WHERE
deployment_name = '{{ deployment_name }}' --required
RETURNING
id,
warehouse_id,
display_name,
last_modifier_user_name,
owner_user_name,
create_time,
description,
lifecycle_state,
parameters,
parent_path,
query_text,
run_as_mode,
tags,
update_time;

DELETE examples

Moves a query to the trash. Trashed queries immediately disappear from searches and list views, and cannot be used for alerts. You can restore a trashed query through the UI. A trashed query is permanently deleted after 30 days.

DELETE FROM databricks_workspace.dbsql.queries
WHERE deployment_name = '{{ deployment_name }}' --required;