Skip to main content

queries

Operations on a queries resource.

Overview

Namequeries
TypeResource
Iddatabricks_workspace.dbsql.queries

Fields

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

Methods

NameAccessible byRequired ParamsDescription
getSELECTid, deployment_nameGets a query.
listSELECTdeployment_nameGets a list of queries accessible to the user, ordered by creation time.
createINSERTdeployment_nameCreates a query.
deleteDELETEid, deployment_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.
updateUPDATEid, deployment_nameUpdates a query.

SELECT examples

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

INSERT example

Use the following StackQL query and manifest file to create a new queries resource.

/*+ create */
INSERT INTO databricks_workspace.dbsql.queries (
deployment_name,
data__query
)
SELECT
'{{ deployment_name }}',
'{{ query }}'
;

UPDATE example

Updates a queries resource.

/*+ update */
-- replace field1, field2, etc. with the fields you want to update
UPDATE databricks_workspace.dbsql.queries
SET field1 = '{{ value1 }}',
field2 = '{{ value2 }}', ...
WHERE id = '{{ id }}' AND
deployment_name = '{{ deployment_name }}';

DELETE example

Deletes a queries resource.

/*+ delete */
DELETE FROM databricks_workspace.dbsql.queries
WHERE id = '{{ id }}' AND
deployment_name = '{{ deployment_name }}';