我曾尝试将表中的现有列重命名为新列。但在名称更改后,新列只给我“NULL”值。
Parquet 中表的存储格式。
例如,
'user' is a column in 'Test' table of string data type. Inserted a sample record with value as 'John'.
Select user from Test;
Result : John
I have renamed 'user' to 'user_name' without changing any data type.
ALTER TABLE Test CHANGE user user_name String;
Select user_name from Test;
Result : NULL
请让我知道如何解决这个问题?
Whether MSCK Repair table command be of any use in this case?
Do I need to reload this table again to fix this issue?
问候, 阿达什KS
最佳答案
你可以做的是添加新字段,执行一次插入覆盖,然后删除旧字段。 像这样:
ALTER TABLE temp.Test ADD COLUMNS (user_new string) CASCADE;
insert overwrite table temp.Test
select
user_a,
a,
b,
c,
user_a as user_new
from temp.test;
ALTER TABLE temp.test REPLACE COLUMNS(user_new string, a string, b string, c string );
关于hadoop - Hive alter table change column name 将 'NULL' 赋予重命名的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52091433/