amazon-web-services - AWS 雅典娜 - HIVE_UNKNOWN_ERROR : Unable to create input format on Athena

标签 amazon-web-services amazon-s3 aws-cloudformation amazon-athena

我正在尝试从 S3 csv 文件创建 GLUE 表,下面是我的 CF 模板

#######################################################################################################
# AWS RESOURCE CHILD STACKS CONFIGURATION DETAILS
#######################################################################################################
Resources:

    TempDataMasterTable:
       Type: AWS::Glue::Table
       Properties:
         DatabaseName: "temp_db"
         CatalogId: !Ref AWS::AccountId
         TableInput:
           Name: "temp_table"
           Description: "Master table"
           TableType: EXTERNAL_TABLE
           Parameters: { "classification" : "csv", "compressionType" : "none", "typeOfData": "file" }
           StorageDescriptor:
             Location: s3://temp-location/temp-folder/
             InputFormat: ''
             OutputFormat: ''
             SerdeInfo:
               Parameters:
                 serialization.format: ','
                 field.delim: ','
             Columns:
             - {"Name": "name", "Type": "string"}
             - {"Name": "lastname", "Type": "string"}

当我进入 Athena 控制台时,我可以看到表已创建,但在尝试查询表时,我收到错误 - “HIVE_UNKNOWN_ERROR:无法在 Athena 上创建输入格式”,很明显我在做错事给出 CF 模板中的输入或输出格式。请您告知 CF 模板中的格式应该是什么。此外,此处的位置 -“s3://temp-location/temp-folder/” 包含每天的文件,因此格式为文件名-日期。您能否告知 CF 模板有什么问题导致 Athena 无法读取此表?

最佳答案

您应该传递org.apache.hadoop.mapred.TextInputFormat作为输入,并传递org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat作为输出。该模板还需要有 SerdeInfo ,其中包含可以帮助您从 S3 读取数据的库。下面是一个在 Athena 中为我工作的示例模板。请参阅 this了解更多示例。

AWSTemplateFormatVersion: 2010-09-09
Description: Glue Table
Resources:
  MyGlueTable:
    Type: AWS::Glue::Table
    Properties:
      DatabaseName: ddddd
      CatalogId: !Ref AWS::AccountId
      TableInput:
        Name: my_glue_table
        TableType: EXTERNAL_TABLE
        StorageDescriptor:
          Columns:
          - {"Name": "name", "Type": "string"}
          - {"Name": "lastname", "Type": "string"}
          Compressed: false
          InputFormat: org.apache.hadoop.mapred.TextInputFormat
          Location: s3://<>
          NumberOfBuckets: -1
          OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
          SerdeInfo:
            SerializationLibrary: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
          SortColumns: []
          StoredAsSubDirectories: false 

关于amazon-web-services - AWS 雅典娜 - HIVE_UNKNOWN_ERROR : Unable to create input format on Athena,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64118078/

相关文章:

java - 如何通过 cloudformation 模板中的另一个实例访问现有的 ec2 实例?

python - 无法将 S3 与 Pyspark 连接。错误消息 : Bad Request, S3 扩展请求 ID:my_extend_request_id

amazon-web-services - S3 选择 CSV header

amazon-web-services - CodePipeline如何部署多个CFN堆栈

amazon-web-services - 无法将服务角色策略附加到客户角色。 (服务: AmazonIdentityManagement; Status Code: 400; Error Code: PolicyNotAttachable

amazon-web-services - cloudformation 上的 HoztedZone 错误

amazon-web-services - AWS-SDK : SQS How identify messages that were not deleted in BatchDeleteOperation

javascript - 在 Lambda 函数中从 AWS SES 发送电子邮件时访问被拒绝

amazon-web-services - 如何在本地配置/安装 Amazon S3

audio - 创建.ram,.wvx,.m3u文件以托管和流式传输音频/视频文件的优势?