Skip to main content

queries_legacy

Operations on a queries_legacy resource.

Overview

Namequeries_legacy
TypeResource
Iddatabricks_workspace.dbsql.queries_legacy

Fields

NameDatatype
idstring
namestring
descriptionstring
can_editboolean
created_atstring
data_source_idstring
is_archivedboolean
is_draftboolean
is_favoriteboolean
is_safeboolean
last_modified_byobject
last_modified_by_idinteger
latest_query_data_idstring
optionsobject
parentstring
permission_tierstring
querystring
query_hashstring
run_as_rolestring
tagsarray
updated_atstring
userobject
user_idinteger
visualizationsarray

Methods

NameAccessible byRequired ParamsDescription
getSELECTquery_id, deployment_nameRetrieve a query object definition along with contextual permissions information about the currently authenticated user.
listSELECTdeployment_nameGets a list of queries. Optionally, this list can be filtered by a search term.
createINSERTdeployment_nameCreates a new query definition. Queries created with this endpoint belong to the authenticated user making the request.
deleteDELETEquery_id, deployment_nameMoves 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.
updateUPDATEquery_id, deployment_nameModify this query definition.
restoreEXECquery_id, deployment_nameRestore 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

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 }}';

INSERT example

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

/*+ 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 }}'
;

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 }}';