Cloudformation AWS::Athena::NamedQuery 模板中的 "Athena database" 是什么?

What is the "Athena database" in the Cloudformation AWS::Athena::NamedQuery template?

AWS::Athena::NamedQuerydocumentation 中,我们有一个可爱的 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

但是Database: "swfnetadata"是什么? Where/how 我定义了吗?

A​​WS Athena tables 只能存在于数据库中。

来自文档:

Athena uses Apache Hive to define tables and create databases, which are essentially a logical namespace of tables. When you create a database and table in Athena, you are simply describing the schema and where the table data are located in Amazon S3 for read-time querying.

因此,在您的情况下,您必须说明创建 table 的数据库。

Creating Databases and Tables

创建 Athena 数据库的 Cloudformation 代码段,这是一个 Glue 数据库。

Parameters:
  DatabaseName:
    Type: String
    Default: dev_db
Resources:
 # Create an AWS Glue database
  MyDevAthenaDatabase:
    Type: AWS::Glue::Database
    Properties:
      # The database is created in the Data Catalog for your account
      CatalogId: !Ref AWS::AccountId
      DatabaseInput:
        # The name of the database is defined in the Parameters section above
        Name: !Ref DatabaseName
        Description: Database to hold dev tables
# Create tables
  MyGlueTable1:
    Type: AWS::Glue::Table
    DependsOn: MyDevAthenaDatabase