什么是#34; Athena数据库"在Cloudformation AWS :: Athena :: NamedQuery模板中?

时间:2017-10-18 22:14:00

标签: amazon-cloudformation amazon-athena

AWS::Athena::NamedQuery 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,

Database: "swfnetadata"

但是var id = databaseReturn["id"]; //-> int 2 是什么?我在哪里/如何定义?

2 个答案:

答案 0 :(得分:1)

AWS Athena表只能存在于数据库中。

来自文档:

  

Athena使用Apache Hive定义表并创建数据库   本质上是表的逻辑命名空间。当你创建一个   在Athena中的数据库和表中,您只是在描述模式和   表数据位于Amazon S3中以进行读取时查询。

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

Creating Databases and Tables

答案 1 :(得分:0)

Cloudformation片段创建一个Athena数据库,它是一个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