【发布时间】:2020-02-29 13:44:57
【问题描述】:
我在 AWS Glue 中定义了一个表。我使用 AWS Kinesis 流通过这个表定义和 parquet 文件格式将日志流式传输到 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
因此,架构有一个数据中不存在的字段。 有没有办法指定一个可选字段?如果它不存在,则将其设为 null。
【问题讨论】:
标签: amazon-web-services parquet aws-glue amazon-athena amazon-kinesis-firehose