hadoop - Hive alter table change column name 将 'NULL' 赋予重命名的列

标签 hadoop hive bigdata hiveql parquet

我曾尝试将表中的现有列重命名为新列。但在名称更改后,新列只给我“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/

相关文章:

java - 使用 hadoop mapreduce 进行矩阵计算

hadoop - yarn java进程没有被杀死

apache - 使用 Hadoop YARN 在本地模式下运行 Hive 查询

hadoop - Hive Testbench数据生成失败

java - Parquet .io.ParquetDecodingException : Can not read value at 0 in block -1 in file

apache-spark - Spark 作为 HDFS 的数据摄取/载入

hive - 如何在 hive CLI 中识别用户正在使用哪个数据库?

hadoop - hbase作为Web应用程序中的数据库

mysql - 使用 Hive 进行实时查询

java - 计算庞大数据集中的唯一 URL(超过 150 亿个)