[英]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.