AWS CloudFormation
User Guide (Version )

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

AWS::Athena::NamedQuery

The AWS::Athena::NamedQuery resource specifies an Amazon Athena query, where QueryString is the list of SQL query statements that comprise the query. For more information, see CreateNamedQuery in the Amazon Athena API Reference.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::Athena::NamedQuery", "Properties" : { "Database" : String, "Description" : String, "Name" : String, "QueryString" : String } }

YAML

Type: AWS::Athena::NamedQuery Properties: Database: String Description: String Name: String QueryString: String

Properties

Database

The database to which the query belongs.

Required: Yes

Type: String

Minimum: 1

Maximum: 255

Update requires: Replacement

Description

The query description.

Required: No

Type: String

Minimum: 1

Maximum: 1024

Update requires: Replacement

Name

The query name.

Required: No

Type: String

Minimum: 1

Maximum: 128

Update requires: Replacement

QueryString

The SQL query statements that comprise the query.

Required: Yes

Type: String

Minimum: 1

Maximum: 262144

Update requires: Replacement

Return Values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the resource name.

For more information about using the Ref function, see Ref.

Examples

The following example creates a named query.

JSON

{ "Resources": { "AthenaNamedQuery": { "Type": "AWS::Athena::NamedQuery", "Properties": { "Database": "swfnetadata", "Description": "A query that selects all aggregated data", "Name": "MostExpensiveWorkflow", "QueryString": "SELECT workflowname, AVG(activitytaskstarted) AS AverageWorkflow FROM swfmetadata WHERE year='17' AND GROUP BY workflowname ORDER BY AverageWorkflow DESC LIMIT 10" } } } }

YAML

Resources: AthenaNamedQuery: Type: AWS::Athena::NamedQuery Properties: Database: "swfnetadata" Description: "A query that selects all aggregated data" Name: "MostExpensiveWorkflow" QueryString: > SELECT workflowname, AVG(activitytaskstarted) AS AverageWorkflow FROM swfmetadata WHERE year='17' AND GROUP BY workflowname ORDER BY AverageWorkflow DESC LIMIT 10