hive分割槽表修改增加列遇到的兩個問題

2021-10-10 21:17:32 字數 399 閱讀 5999

由於需求改變,需要在原有的hive分割槽表中新增列,並每次充寫最近30天的分割槽資料。

問題:

問題原因:

1.hive增加列只是修改了hive的元資料,並沒有改變hdfs的資料檔案,其查詢結果按照列的順序和hdfs按分隔符分割後的資料對應,導致錯列。

2.原因與上面的相同,解決方法為刪除舊分割槽後再重新寫入,

alter table db.table drop partition (partition = '' );
或者在alter語句後增加cascade

alter table tb add columns(col1 string) cascade;

hive 分割槽表 Hive的DDL分割槽表建立

1.單分割槽表 建立表t user,指定分割槽hive xiaoliu create table t user id int,name string partitioned by country string row format delimited fields terminated by xia...

hive 分割槽表

partitioned by create table tb name name string partitioned by age int row format delimited fields terminated by t load data local inpath file path in...

hive分割槽表

partition對應於資料庫的 partition 列的密集索引 在 hive 中,表中的乙個 partition 對應於表下的乙個目錄,所有的 partition 的資料都儲存在對應的目錄中 例如 test表中包含 date 和 city 兩個 partition 則對應於date 201302...