首页 > 解决方案 > 如何将 Glue/Athena/Quicksight 与 CloudFormation 结合使用

问题描述

我在 S3 中有一些数据,在 Glue 目录中创建了一个模式,然后通过 Athena 将其公开给 QuickSight。当我通过单击控制台创建它时,所有这些都很好。

然后我将其转换为以下 CloudFormation:

AnalyticsDatabase:
  Type: AWS::Glue::Database
  Properties:
    DatabaseInput: 
      Name: analytics
    CatalogId: !Ref AWS::AccountId
RawAnalysisAnalyticsTable:
  Type: AWS::Glue::Table
  Properties:
    DatabaseName: !Ref AnalyticsDatabase
    CatalogId: !Ref AWS::AccountId
    TableInput:
      Name: analysis_raw
      TableType: EXTERNAL_TABLE
      Parameters:
        classification: json
      StorageDescriptor:
        Columns:
          - {Name: id, Type: string}
          - {Name: treeid, Type: string}
          - {Name: patientid, Type: string}
        Compressed: false
        InputFormat: org.apache.hadoop.mapred.TextInputFormat
        OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
        Location: s3://my-bucket/dynamodb/Analysis/
        NumberOfBuckets: 0
        SerdeInfo:
          Parameters: {paths: 'id,patientid,treeid'}
          SerializationLibrary: org.openx.data.jsonserde.JsonSerDe
        SortColumns: []
        StoredAsSubDirectories: false

但是,当我尝试将 CF 创建的表拉入 QuickSight 时,我得到:

Your database generated a SQL exception. This can be caused by query timeouts, resource constraints, unexpected DDL alterations before or during a query, and other database errors. Check your database settings and your query, and try again.

region:             us-east-1
timestamp:          1544113019756
requestId:          5ab8f9a2-f972-11e8-b201-154c30728c75
sourceErrorCode:    0
sourceErrorMessage: [Simba][JDBC](11380) Null pointer exception.
sourceErrorState:   HY000
sourceException:    java.sql.SQLException
sourceType:         ATHENA

有谁知道这个错误是什么意思或我如何解决它?我已经将手动创建的表的所有属性与 CloudFormation 创建的表进行了比较,它们看起来是相同的。

标签: amazon-web-servicesamazon-cloudformationamazon-athenaaws-glueamazon-quicksight

解决方案


Max 的答案应该是这里公认的答案。复制这个并且唯一有效的解决方案是添加 PartitionKeys: [] 参数。我最初将它添加为子项或 StorageDescription,但它不起作用。必须在文档中指定的 TableInput 子级别添加。这是正确的答案,因为此处列出的其他条件(安全性等)都不会给出问题中引用的 NullPointerException。


推荐阅读