我正在尝试从 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/