named_queries
Creates, updates, deletes, gets or lists a named_queries resource.
Overview
| Name | named_queries |
| Type | Resource |
| Id | aws.athena.named_queries |
Fields
The following fields are returned by SELECT queries:
- batch_get_named_query
- get_named_query
- list_named_queries
| Name | Datatype | Description |
|---|---|---|
named_queries | array | Information about the named query IDs submitted. |
unprocessed_named_query_ids | array | Information about provided query IDs. |
| Name | Datatype | Description |
|---|---|---|
database | string | The database to which the query belongs. |
description | string | The query description. |
name | string | The query name. |
named_query_id | string | The unique identifier of the query. (pattern: <code>\S+</code>) |
query_string | string | The SQL statements that make up the query. |
work_group | string | The name of the workgroup that contains the named query. (pattern: <code>[a-zA-Z0-9._-]{1,128}</code>) |
| Name | Datatype | Description |
|---|---|---|
named_query_id | string | The list of unique query IDs. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
batch_get_named_query | select | region | 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. | |
get_named_query | select | region | Returns information about a single query. Requires that you have access to the workgroup in which the query was saved. | |
list_named_queries | select | region | Provides 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_query | insert | region, Name, Database, QueryString | Creates a named query in the specified workgroup. Requires that you have access to the workgroup. | |
update_named_query | update | region, NamedQueryId, Name, QueryString | Updates a NamedQuery object. The database or workgroup cannot be updated. | |
delete_named_query | delete | region | Deletes 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.
| Name | Datatype | Description |
|---|---|---|
region | string | AWS region (default: us-east-1) |
SELECT examples
- batch_get_named_query
- get_named_query
- list_named_queries
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
;
Returns information about a single query. Requires that you have access to the workgroup in which the query was saved.
SELECT
database,
description,
name,
named_query_id,
query_string,
work_group
FROM aws.athena.named_queries
WHERE region = '{{ region }}' -- required
;
Provides 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.
SELECT
named_query_id
FROM aws.athena.named_queries
WHERE region = '{{ region }}' -- required
;
INSERT examples
- create_named_query
- Manifest
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
;
# Description fields are for documentation purposes
- name: named_queries
props:
- name: region
value: "{{ region }}"
description: Required parameter for the named_queries resource.
- name: Name
value: "{{ Name }}"
description: |
The query name.
- name: Description
value: "{{ Description }}"
description: |
The query description.
- name: Database
value: "{{ Database }}"
description: |
The database to which the query belongs.
- name: QueryString
value: "{{ QueryString }}"
description: |
The contents of the query with all query statements.
- name: ClientRequestToken
value: "{{ ClientRequestToken }}"
description: |
A unique case-sensitive string used to ensure the request to create the query is idempotent (executes only once). If another CreateNamedQuery request is received, the same response is returned and another query is not created. If a parameter has changed, for example, the QueryString, an error is returned. This token is listed as not required because Amazon Web Services SDKs (for example the Amazon Web Services SDK for Java) auto-generate the token for users. If you are not using the Amazon Web Services SDK or the Amazon Web Services CLI, you must provide this token or the action will fail.
- name: WorkGroup
value: "{{ WorkGroup }}"
description: |
The name of the workgroup in which the named query is being created.
UPDATE examples
- update_named_query
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
- delete_named_query
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
;