HIVE_CANNOT_OPEN_SPLIT:从 Athena 查询镶木地板文件时架构不匹配

HIVE_CANNOT_OPEN_SPLIT: Schema mismatch when querying parquet files from Athena

我在从 Athena 查询镶木地板数据时收到模式不匹配错误。

错误是:

HIVE_CANNOT_OPEN_SPLIT: Error opening Hive split s3://datalake/googleanalytics/version=0/eventDate=2017-06-11/part-00001-9c9312f7-f9a5-47c3-987e-9348b78aaebc-c000.snappy.parquet (offset=0, length=48653579): Schema mismatch, metastore schema for row column totals has 13 fields but parquet schema has 12 fields

在 AWS Glue Crawler 中,我尝试启用 使用 table 中的元数据更新所有新的和现有的分区,我认为这可以解决这个问题,但我仍然出现上述错误。 我这样做是因为类似的问题:

总计列的 table 架构是:

struct<visits:bigint,hits:bigint,pageviews:bigint,timeOnSite:bigint,bounces:bigint,transactions:bigint,transactionRevenue:bigint,newVisits:bigint,screenviews:bigint,uniqueScreenviews:bigint,timeOnScreen:bigint,totalTransactionRevenue:bigint,sessionQualityDim:bigint>

分区 eventDate=2017-06-11 的镶木地板文件缺少最后一个字段 "sessionQualityDim".

您的镶木地板文件具有两种不同的架构,Athena table 架构与较新的架构相匹配。您可以执行以下操作之一:

1) 在athena中创建两个不同的tables,一个指向2017年之前的数据,另一个指向post 2017年的数据。

2) 如果旧数据对当前用例不再有效,那么您可以简单地存档该数据并从当前 table.

中删除 2017 年及更旧的分区