gpt4 book ai didi

amazon-athena - 如何解决这个 HIVE_PARTITION_SCHEMA_MISMATCH?

转载 作者:行者123 更新时间:2023-12-03 18:05:29 28 4
gpt4 key购买 nike

我在 S3 上对 CSV 文件中的数据进行了分区:

  • s3://bucket/dataset/p=1/*.csv(分区#1)
  • ...
  • s3://bucket/dataset/p=100/*.csv(分区#100)

  • 我在 s3://bucket/dataset/上运行一个分类器,结果看起来非常有希望,因为它检测到 150 列 (c1,...,c150) 并分配了各种数据类型。

    在 Athena 中加载结果表并查询( select * from dataset limit 10 )它会产生错误消息:

    HIVE_PARTITION_SCHEMA_MISMATCH: There is a mismatch between the table and partition schemas. The types are incompatible and cannot be coerced. The column 'c100' in table 'tests.dataset' is declared as type 'string', but partition 'AANtbd7L1ajIwMTkwOQ' declared column 'c100' as type 'boolean'.



    首先,我不知道如何使用“AANtbd7L1ajIwMTkwOQ”……但我可以从 Glue 中的分区列表中看出,有些分区将 c100 归类为字符串,而另一些则归类为 bool 值。而表模式将其列为字符串。

    这也意味着,如果我将查询限制为将 c100 分类为与表模式一致的字符串的分区,那么该查询将起作用。如果我使用将 c100 分类为 bool 值的分区,则查询将失败并显示上述错误消息。

    现在查看一些 CSV 列 c100 似乎包含三个不同的值:
  • [空](如...、、...)

  • 可能某些行包含拼写错误(可能),因此某些分区被归类为字符串 - 但这只是一个理论,并且由于文件的数量和大小而难以验证。

    我也试过 MSCK REPAIR TABLE dataset无济于事。

    有没有快速解决方案?也许强制所有分区使用字符串?如果我查看分区列表,则有一个已停用的“编辑架构”按钮。

    或者我是否必须编写一个 Glue 作业来检查和丢弃或修复每一行?

    最佳答案

    如果您使用爬虫,您应该选择以下选项:

    Update all new and existing partitions with metadata from the table

    您也可以在创建表时执行此操作。查询 https://docs.aws.amazon.com/glue/latest/dg/crawler-configuration.html#crawler-schema-changes-prevent更多细节。

    这应该可以解决问题。如果没有,请检查 https://github.com/awsdocs/amazon-athena-user-guide/blob/master/doc_source/glue-best-practices.md#schema-syncing 中的其他选项

    要了解雅典娜中的问题,请查看 https://docs.aws.amazon.com/athena/latest/ug/updates-and-partitions.html

    关于amazon-athena - 如何解决这个 HIVE_PARTITION_SCHEMA_MISMATCH?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57890280/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com