DataFormatConversion.InvalidSchema 在 AWS Glue 和 Firehose 中使用连字符/破折号

问题描述

我有这个 CloudFormation glue 模板,它在结构字段之一中包含一个连字符:

  Testglue:
    Type: AWS::glue::Table
    Properties:
      CatalogId: !Ref AWS::AccountId
      DatabaseName: testdatabase
        Name: 'test'
        StorageDescriptor:
          Location: "s3://testpath"
          Columns:
            - Name: test
              Type: struct<testcol:string,item-testcol:string>

此表用于 Kinesis Firehose 记录转换,但每当我尝试发送数据进行处理时,都会出现以下错误。有没有办法强制使用破折号或连字符,到目前为止我无法将其更改为下划线,因为当前数据使用连字符并且会产生很大影响。

"lastErrorCode":"DataFormatConversion.InvalidSchema","lastErrorMessage":"The schema is invalid. Error parsing the schema: Error:: expected at the position XX of 'struct<testcol:string,item-testcol:string>' but '-' is found."

解决方法

由于 Glue 数据目录在 Hive Metastore 上运行,我认为在名称中使用破折号是不可能的。

,

正如@Robert 也提到的,Glue 不支持在列名中使用“连字符”。

来自 Glue 文档:

When you create schema in AWS Glue to query in Athena,consider the following:

- database name cannot be longer than 252 characters.
- table name cannot be longer than 255 characters.
- column name cannot be longer than 128 characters.
- The only acceptable characters for database names,table names,and column names are lowercase letters,numbers,and the underscore character.

有关详细信息,请参阅 Glue best practices