AWS Glue-将fileld添加到结构字段

我有一个在AWS Glue中定义的表。我使用AWS Kinesis流使用此表定义(使用木地板文件格式)将日志流式传输到S3。它是按日期划分的。

表中的字段之一是具有多个字段event_payload的结构,其中一个是结构数组。最近,我在日志数据的内部结构中添加了一个新字段。我想在表定义中添加它,以便将其写入S3,以便可以使用AWS Athena查询它。

我尝试直接在控制台中编辑表架构。它确实将数据写入S3,但是查询时我在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_payload' in table 'c2s.logs' is declared as type 'struct<...>',but partition 'year=2019/month=201910/day=20191026/hour=2019102623' declared column 'event_payload' as type 'struct<...>'.

我尝试按照指定的here删除所有分区并修复表,但是又出现了另一个错误:

HIVE_CANNOT_OPEN_SPLIT: Error opening Hive split s3://.../year=2019/month=201910/day=20191022/hour=2019102216/beaconFirehose-4-2019-10-22-16-34-21-71f183d2-207e-4ae9-98fe-07dda0bab70c.parquet (offset=0,length=801679): Schema mismatch,metastore schema for row column event_payload.markings.element has 8 fields but parquet schema has 7 fields

因此,架构具有数据中不存在的字段。 有没有办法指定一个可选字段?如果不存在,请将其设置为空。

zhoulang914 回答:AWS Glue-将fileld添加到结构字段

根据link,雅典娜不支持嵌套结构的架构更新。进行此工作的一种方法是借助Glue中的相关化运算符来展平结构类型。例如:

val frames: Seq[DynamicFrame] = lHistory.relationalize(rootTableName = "hist_root",stagingPath = redshiftTmpDir,JsonOptions.empty)
本文链接:https://www.f2er.com/3168033.html

大家都在问