【问题标题】:What is the "Athena database" in the Cloudformation AWS::Athena::NamedQuery template?Cloudformation AWS::Athena::NamedQuery 模板中的“Athena 数据库”是什么?
【发布时间】:2020-01-16 07:30:37
【问题描述】:

documentationAWS::Athena::NamedQuery 中,我们有一个可爱的 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" 是什么?我在哪里/如何定义它?

【问题讨论】:

    标签: amazon-cloudformation amazon-athena


    【解决方案1】:

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

    来自文档:

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

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

    Creating Databases and Tables

    【讨论】:

    • 如何在 Cloudformation 中创建 Apache Hive 数据库?
    • almost looks like 不需要数据库,使用default 可以正常工作
    【解决方案2】:

    Cloudformation sn-p 创建一个 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
    

    【讨论】:

      猜你喜欢
      • 2020-08-17
      • 2021-12-14
      • 1970-01-01
      • 2018-10-21
      • 1970-01-01
      • 2020-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多