繁体   English   中英

在Hive中选择数据时,如果外部表分区位置数据丢失,如何通过错误?

[英]In Hive how to through error if external table partition location data is missing while selecting data?

我已经创建了带有分区列日期的表外部表"test"

由于将数据导入"test"时出现一些错误。它只是创建目录(分区目录)但未加载到数据中,数据丢失。

从特定分区中选择数据时, it is not showing any error it is giving zero records

但是如果选择时数据丢失,我想抛出错误,有什么方法可以在 hive 中处理?

您可以使用 Hive 中的动态分区属性来使加载过程失败,该属性可以在写入时控制该行为。 根据此处的文档,您可以找到

hive.error.on.empty.partition

    Default Value: false
    Added In: Hive 0.7.0

Whether to throw an exception if dynamic partition insert generates empty results.

我在 static 分区上看不到等效的分区,因此您可能需要查询该特定分区并查看它是否为空。 如果行数低于 1,这可能会使加载过程失败(例如)

阅读时的另一个选择是使用名为assert_true的 Hive UDF,您可以在此处找到。 如您所见,它返回一个void,格式为

assert_true(boolean condition)


Throw an exception if 'condition' is not true, otherwise return null (as of Hive 0.8.0). For example, select assert_true (2<1).

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM