Skip to main content

queries_legacy

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

Overview

Namequeries_legacy
TypeResource
Iddatabricks_workspace.dbsql.queries_legacy

Fields

The following fields are returned by SELECT queries:

Query fetched successfully.

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

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectdeployment_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.
updateupdatedeployment_nameModify this query definition.
deletedeletedeployment_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.
restoreexecdeployment_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.

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

Retrieve a query object definition along with contextual permissions information about the currently authenticated user.

SELECT
id,
name,
data_source_id,
last_modified_by_id,
latest_query_data_id,
user_id,
can_edit,
created_at,
description,
is_archived,
is_draft,
is_favorite,
is_safe,
last_modified_by,
options,
parent,
permission_tier,
query,
query_hash,
run_as_role,
tags,
updated_at,
user,
visualizations
FROM databricks_workspace.dbsql.queries_legacy
WHERE deployment_name = '{{ deployment_name }}' -- required;

INSERT examples

Creates a new query definition. Queries created with this endpoint belong to the authenticated user making the request.

INSERT INTO databricks_workspace.dbsql.queries_legacy (
data__data_source_id,
data__query,
data__name,
data__parent,
data__description,
data__options,
data__run_as_role,
data__tags,
deployment_name
)
SELECT
'{{ data_source_id }}',
'{{ query }}',
'{{ name }}',
'{{ parent }}',
'{{ description }}',
'{{ options }}',
'{{ run_as_role }}',
'{{ tags }}',
'{{ deployment_name }}'
RETURNING
id,
name,
data_source_id,
last_modified_by_id,
latest_query_data_id,
user_id,
can_edit,
created_at,
description,
is_archived,
is_draft,
is_favorite,
is_safe,
last_modified_by,
options,
parent,
permission_tier,
query,
query_hash,
run_as_role,
tags,
updated_at,
user,
visualizations
;

UPDATE examples

Modify this query definition.

UPDATE databricks_workspace.dbsql.queries_legacy
SET
data__data_source_id = '{{ data_source_id }}',
data__query = '{{ query }}',
data__name = '{{ name }}',
data__description = '{{ description }}',
data__options = '{{ options }}',
data__run_as_role = '{{ run_as_role }}',
data__tags = '{{ tags }}'
WHERE
deployment_name = '{{ deployment_name }}' --required
RETURNING
id,
name,
data_source_id,
last_modified_by_id,
latest_query_data_id,
user_id,
can_edit,
created_at,
description,
is_archived,
is_draft,
is_favorite,
is_safe,
last_modified_by,
options,
parent,
permission_tier,
query,
query_hash,
run_as_role,
tags,
updated_at,
user,
visualizations;

DELETE examples

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.

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

Lifecycle Methods

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.

EXEC databricks_workspace.dbsql.queries_legacy.restore 
@deployment_name='{{ deployment_name }}' --required;