AWS Glue-将列更改为类型数组或结构

我最近开始使用AWS Glue来读取S3上的一些文件。

花了很多时间来获取正确的搜寻器之后,我有了三个表。其中之一称为raw。它包含按年/月/日划分的文件夹中的csv文件

创建的架构将event_features的一个特定列显示为string

但是在Athena中运行查询时,出现此错误:

HIVE_PARTITION_SCHEMA_MISMATCH: There is a mismatch between the table and partition schemas. The types are incompatible and cannot be coerced. The column 'event_features' in table 'raw' is declared as type 'string',but partition '___' declared column 'event_features' as type 'array<string>'.

事实上,我检查了一下,该列的值可以是:

我理解的

[]被视为字符串而非空数组

[{'type':'value'},{'type':'value'}],然后正确解释为数组

即使爬虫显然是JSON结构数组,为什么爬虫仍会决定字符串呢?我该如何解决?我找不到强制将列类型设置为数组/结构的选项。

奇怪的是,相似的列event_metrics具有完全相同的值类型(有时[]有时是jsons数组)并且正确定义为array

我在StackOverlow上查看了其他一些问题,并在搜寻器中选择了此设置:

Update all new and existing partitions with metadata from the table.

但是列的类型没有改变。.

---编辑 我唯一想到的就是编写一个自定义分类器,但希望我能避免这种情况

mj5an 回答:AWS Glue-将列更改为类型数组或结构

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3150475.html

大家都在问