queries
Operations on a queries
resource.
Overview
Name | queries |
Type | Resource |
Id | databricks_workspace.dbsql.queries |
Fields
Name | Datatype |
---|---|
id | string |
description | string |
create_time | string |
display_name | string |
last_modifier_user_name | string |
lifecycle_state | string |
owner_user_name | string |
parameters | array |
parent_path | string |
query_text | string |
run_as_mode | string |
tags | array |
update_time | string |
warehouse_id | string |
Methods
Name | Accessible by | Required Params | Description |
---|---|---|---|
get | SELECT | id, deployment_name | Gets a query. |
list | SELECT | deployment_name | Gets a list of queries accessible to the user, ordered by creation time. |
create | INSERT | deployment_name | Creates a query. |
delete | DELETE | id, deployment_name | 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. |
update | UPDATE | id, deployment_name | Updates a query. |
SELECT
examples
- queries (list)
- queries (get)
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 }}';
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 id = '{{ id }}' AND
deployment_name = '{{ deployment_name }}';
INSERT
example
Use the following StackQL query and manifest file to create a new queries
resource.
- queries
- Manifest
/*+ create */
INSERT INTO databricks_workspace.dbsql.queries (
deployment_name,
data__query
)
SELECT
'{{ deployment_name }}',
'{{ query }}'
;
- name: your_resource_model_name
props:
- name: query
value:
description: Example description
tags:
- Tag 1
display_name: Example query
parent_path: /Workspace/Users/user@acme.com
query_text: SELECT 1
parameters:
- name: foo
text_value:
value: bar
title: foo
warehouse_id: a7066a8ef796be84
run_as_mode: OWNER
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 }}';