queries_legacy
Operations on a queries_legacy
resource.
Overview
Name | queries_legacy |
Type | Resource |
Id | databricks_workspace.dbsql.queries_legacy |
Fields
Name | Datatype |
---|---|
id | string |
name | string |
description | string |
can_edit | boolean |
created_at | string |
data_source_id | string |
is_archived | boolean |
is_draft | boolean |
is_favorite | boolean |
is_safe | boolean |
last_modified_by | object |
last_modified_by_id | integer |
latest_query_data_id | string |
options | object |
parent | string |
permission_tier | string |
query | string |
query_hash | string |
run_as_role | string |
tags | array |
updated_at | string |
user | object |
user_id | integer |
visualizations | array |
Methods
Name | Accessible by | Required Params | Description |
---|---|---|---|
get | SELECT | query_id, deployment_name | Retrieve a query object definition along with contextual permissions information about the currently authenticated user. |
list | SELECT | deployment_name | Gets a list of queries. Optionally, this list can be filtered by a search term. |
create | INSERT | deployment_name | Creates a new query definition. Queries created with this endpoint belong to the authenticated user making the request. |
delete | DELETE | query_id, deployment_name | Moves a query to the trash. Trashed queries immediately disappear from searches and list views, and they cannot be used for alerts. The trash is deleted after 30 days. |
update | UPDATE | query_id, deployment_name | Modify this query definition. |
restore | EXEC | query_id, deployment_name | Restore a query that has been moved to the trash. A restored query appears in list views and searches. You can use restored queries for alerts. |
SELECT
examples
- queries_legacy (list)
- queries_legacy (get)
SELECT
id,
name,
description,
can_edit,
created_at,
data_source_id,
is_archived,
is_draft,
is_favorite,
is_safe,
last_modified_by,
last_modified_by_id,
latest_query_data_id,
options,
parent,
permission_tier,
query,
query_hash,
run_as_role,
tags,
updated_at,
user,
user_id,
visualizations
FROM databricks_workspace.dbsql.queries_legacy
WHERE deployment_name = '{{ deployment_name }}';
SELECT
id,
name,
description,
can_edit,
created_at,
data_source_id,
is_archived,
is_draft,
is_favorite,
is_safe,
last_modified_by,
last_modified_by_id,
latest_query_data_id,
options,
parent,
permission_tier,
query,
query_hash,
run_as_role,
tags,
updated_at,
user,
user_id,
visualizations
FROM databricks_workspace.dbsql.queries_legacy
WHERE query_id = '{{ query_id }}' AND
deployment_name = '{{ deployment_name }}';
INSERT
example
Use the following StackQL query and manifest file to create a new queries_legacy
resource.
- queries_legacy
- Manifest
/*+ create */
INSERT INTO databricks_workspace.dbsql.queries_legacy (
deployment_name,
data__data_source_id,
data__query,
data__name,
data__parent,
data__description,
data__options,
data__run_as_role,
data__tags
)
SELECT
'{{ deployment_name }}',
'{{ data_source_id }}',
'{{ query }}',
'{{ name }}',
'{{ parent }}',
'{{ description }}',
'{{ options }}',
'{{ run_as_role }}',
'{{ tags }}'
;
- name: your_resource_model_name
props:
- name: data_source_id
value: 0c205e24-5db2-4940-adb1-fb13c7ce960b
- name: query
value: SELECT field FROM table WHERE field = {{ param }}
- name: name
value: Orders by month by customer
- name: parent
value: folders/2025532471912059
- name: description
value: Summarizes total order dollars for customers in the Europe/Asia region.
- name: options
value:
parameters:
- title: customer
name: param
type: text
value: acme
- name: run_as_role
value: viewer
- name: tags
value:
- Payroll
UPDATE
example
Updates a queries_legacy
resource.
/*+ update */
-- replace field1, field2, etc. with the fields you want to update
UPDATE databricks_workspace.dbsql.queries_legacy
SET field1 = '{{ value1 }}',
field2 = '{{ value2 }}', ...
WHERE query_id = '{{ query_id }}' AND
deployment_name = '{{ deployment_name }}';
DELETE
example
Deletes a queries_legacy
resource.
/*+ delete */
DELETE FROM databricks_workspace.dbsql.queries_legacy
WHERE query_id = '{{ query_id }}' AND
deployment_name = '{{ deployment_name }}';