hive修改欄位後查詢不了資料

2021-09-29 05:53:26 字數 926 閱讀 1190

hive版本為: apache-hive-2.1.0

hadoop版本為: apache-hadoop-2.6.0-cdh-5.13.3

修改新增兩個字段刪除乙個字段,但跟日誌檔案資料是一一對應的。

發現修改後,在hive中用mapreduce查詢這兩個新加的字段,值為null。

而用hive中用spark引擎卻可以找到欄位的值。

通過alert table tablename add column(舊欄位1,舊欄位2,…,舊欄位n,新字段1,新字段2)

修改。在hive中,修改後發現查詢舊字段時正常的,而新加的字段1,欄位2值為null。

使用spark引擎,發現該資料查詢正常。

分割槽按日期分,重新關聯hdfs。

寫個執行指令碼,從開始日期的日誌當最新的日誌

#!/bin/sh

begin =

$(date +%s -d "20151101"

) end =

$(date +%s -d "20191101"

) db=sss

tmpfile = /tmp/tmp.sql

while[

$begin -le $end]do

dt =

$(date +%y%m%d -d @begin)

echo

"alert table tablename drop partition(date=$dt);alert table $db.tablename add

partition(pdate=$dt) location '/$db/$dt/';"

>>

$tmpfile

begin=

$((begin+

86400

)) done

hive -f $tmpfile

Hive表字段型別修改

a 建立一張和原表一樣表結構的複製表 b 通過插入語句 insert overwrite 使用動態分割槽把資料匯入複製表 set hive.exec dynamic.partition mode nonstrict create table table copy like table origina...

hive表新增字段或者修改字段

1.hive表操作 1.修改表字段的資料型別或者修改表字段名字 如果表是外部表,需要先修改為內部表 alter table 資料庫名.表名set tblproperties external false alter table 資料庫名.表名 change column 欄位名 新的欄位名 如果不變...

Oracle查詢後直接修改資料,查詢修改

oracle如何通過兩個表關聯,修改其中一表中某列的資料 update a set a.e b.h where a.g in select b.g from b for update 可查詢更改 統計重複的記錄 to char to date f rzsj,yyyymmdd 90,yyyymmdd ...