如何在CloudFormation中使用Glue / Athena / Quicksight

时间:2018-12-06 16:28:12

标签: amazon-web-services amazon-cloudformation amazon-athena aws-glue amazon-quicksight

我在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创建的表进行了比较,它们似乎相同。

1 个答案:

答案 0 :(得分:-1)

Max的答案应为此处接受的答案。复制了此方法,唯一可行的解​​决方案是添加PartitionKeys:[]参数。我最初将其添加为子项或StorageDescription,但该方法无效。必须在docs中指定的TableInput子级别添加。这是正确的答案,因为此处列出的其他任何条件(安全性等)都不会给出问题中引用的NullPointerException。