AWS::Athena::NamedQuery - AWS CloudFormation

AWS::Athena::NamedQuery

The AWS::Athena::NamedQuery resource specifies an Amazon Athena saved query, where QueryString contains the SQL query statements that make up the query.

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, "WorkGroup" : String } }

YAML

Type: AWS::Athena::NamedQuery Properties: Database: String Description: String Name: String QueryString: String WorkGroup: 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 statements that make up the query.

Required: Yes

Type: String

Minimum: 1

Maximum: 262144

Update requires: Replacement

WorkGroup

The name of the workgroup that contains the named query.

Required: No

Type: String

Minimum: 1

Maximum: 128

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.

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

NamedQueryId

The unique ID of the query.

Examples

Create a named query

The following example creates a named query.

JSON

{ "Resources": { "AthenaNamedQuery": { "Type": "AWS::Athena::NamedQuery", "Properties": { "Database": "swfmetadata", "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: "swfmetadata" 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