Skip to main content

named_queries

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

Overview

Namenamed_queries
TypeResource
Idaws.athena.named_queries

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
named_queriesarrayInformation about the named query IDs submitted.
unprocessed_named_query_idsarrayInformation about provided query IDs.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
batch_get_named_queryselectregionReturns the details of a single named query or a list of up to 50 queries, which you provide as an array of query ID strings. Requires you to have access to the workgroup in which the queries were saved. Use ListNamedQueriesInput to get the list of named query IDs in the specified workgroup. If information could not be retrieved for a submitted query ID, information about the query ID submitted is listed under UnprocessedNamedQueryId. Named queries differ from executed queries. Use BatchGetQueryExecutionInput to get details about each unique query execution, and ListQueryExecutionsInput to get a list of query execution IDs.
get_named_queryselectregionReturns information about a single query. Requires that you have access to the workgroup in which the query was saved.
list_named_queriesselectregionProvides a list of available query IDs only for queries saved in the specified workgroup. Requires that you have access to the specified workgroup. If a workgroup is not specified, lists the saved queries for the primary workgroup.
create_named_queryinsertregion, Name, Database, QueryStringCreates a named query in the specified workgroup. Requires that you have access to the workgroup.
update_named_queryupdateregion, NamedQueryId, Name, QueryStringUpdates a NamedQuery object. The database or workgroup cannot be updated.
delete_named_querydeleteregionDeletes the named query if you have access to the workgroup in which the query was saved.

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
regionstringAWS region (default: us-east-1)

SELECT examples

Returns the details of a single named query or a list of up to 50 queries, which you provide as an array of query ID strings. Requires you to have access to the workgroup in which the queries were saved. Use ListNamedQueriesInput to get the list of named query IDs in the specified workgroup. If information could not be retrieved for a submitted query ID, information about the query ID submitted is listed under UnprocessedNamedQueryId. Named queries differ from executed queries. Use BatchGetQueryExecutionInput to get details about each unique query execution, and ListQueryExecutionsInput to get a list of query execution IDs.

SELECT
named_queries,
unprocessed_named_query_ids
FROM aws.athena.named_queries
WHERE region = '{{ region }}' -- required
;

INSERT examples

Creates a named query in the specified workgroup. Requires that you have access to the workgroup.

INSERT INTO aws.athena.named_queries (
Name,
Description,
Database,
QueryString,
ClientRequestToken,
WorkGroup,
region
)
SELECT
'{{ Name }}' /* required */,
'{{ Description }}',
'{{ Database }}' /* required */,
'{{ QueryString }}' /* required */,
'{{ ClientRequestToken }}',
'{{ WorkGroup }}',
'{{ region }}'
RETURNING
named_query_id
;

UPDATE examples

Updates a NamedQuery object. The database or workgroup cannot be updated.

UPDATE aws.athena.named_queries
SET
NamedQueryId = '{{ NamedQueryId }}',
Name = '{{ Name }}',
Description = '{{ Description }}',
QueryString = '{{ QueryString }}'
WHERE
region = '{{ region }}' --required
AND NamedQueryId = '{{ NamedQueryId }}' --required
AND Name = '{{ Name }}' --required
AND QueryString = '{{ QueryString }}' --required;

DELETE examples

Deletes the named query if you have access to the workgroup in which the query was saved.

DELETE FROM aws.athena.named_queries
WHERE region = '{{ region }}' --required
;