hive刪除表或分割槽但是HDFS裡面資料還在

2021-09-29 15:37:23 字數 345 閱讀 4306

僅在這裡說一下自己遇到的問題,以及解決方案。不保證正確。
在spark裡面建立了乙個分割槽表,刪除分割槽後匯入新的資料到相同分割槽。發現有兩份資料。

後來排查,刪除分割槽後,在hive裡面看不到分割槽了,但是在hdfs裡面資料仍然存在,所以當相應分割槽重新建立時,hdfs裡的資料又能查詢到了。

truncate table時遇到錯誤,不能truncate外部表。

於是使用desc formatted table-name 發現果然當前表是外部表

具體衛生me建立了外部表

其實我的建表語句裡面沒有指定external

應該是因為使用spark建立表導致的

hive表分割槽

hive對錶有分割槽的功能。hive根據表的列屬性值 諸如日期,城市 部門對錶進行分割槽 使用分割槽,能夠很容易查詢 到資料的一部分。表或分割槽被分為 buckets 桶 以便為資料 提供額外的資料結構,該資料結構被 用於提公升 查詢的有效性。buckets 桶 的工作依賴於表中某個列的 雜湊函式值...

Hive 表分割槽

基本知識 hadoop fs rmr hdfs hdfs hadoop fs put user hive warehouse data.txt hdfs hdfs data.txt 建立分割槽表 外部表 create external table if not exists employee id ...

Hive 表分割槽

基本知識 hadoop fs rmr hdfs hdfs hadoop fs put user hive warehouse data.txt hdfs hdfs data.txt 建立分割槽表 外部表 create external table if not exists employee id ...