gpt4 book ai didi

hadoop - 创建表后的Hive分区和新属性介绍

转载 作者:行者123 更新时间:2023-12-02 21:34:42 24 4
gpt4 key购买 nike

这与Apache Hive分区问题有关。

创建分区表后,请帮助我添加新属性。
新属性数据未加载。

我们有什么需要调整的吗?

数据:

header: id,  name, date,   sal

dummy.txt
---------

1,Narayana,20150201,20.345
2,Narayana1,20150202,23.654
3,Narayana2,20150203,776.23
4,Narayana3,20150204,23.224
5,Narayana4,20150205,77.88
6,Narayana5,20150206,99.765

DDL
create schema nari;
use nari;

drop table x_1;
create external table x_1(
id int
,name string
,dt string
,sal double)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
LOCATION '/user/hdpcsc/data';

drop table p_emp;
create table p_emp(
id int
,name string
,dt string)
partitioned by(fp string)
CLUSTERED BY (id) SORTED BY (id asc) INTO 256 BUCKETS
STORED AS ORC TBLPROPERTIES("orc.compress"="SNAPPY");

insert1
insert overwrite table  p_emp partition(fp="Q1FY15")
select id, name, dt from x_1;

选择
select * from p_emp; -- works well 

insert2
insert overwrite table  p_emp partition(fp="FCQ116")
select id, name, dt from x_1;

选择
select * from p_emp; -- works well 

现在添加新属性
alter table p_emp add columns (sal double);

insert4
insert overwrite table  p_emp partition(fp="Q1FY15")
select id, name, dt, sal from x_1;

选择
select * from p_emp; -- sal attr null data

insert5
insert overwrite table  p_emp partition(fp="FCQ116")
select id, name, dt, sal from x_1;

选择
select * from p_emp; -- sal attr null data

最佳答案

如果使用hive0.14.0,是否可以尝试以下查询以添加列并执行插入操作:

alter table p_emp partition(fp="Q1FY15") add columns (sal double);
alter table p_emp partition(fp="FCQ116") add columns (sal double);

您面临的问题是0.11.0、0.12.0和0.13.0版本中的 hive 中的错误(HIVE-6131)。

如果执行上述alter语句时遇到错误,请尝试删除分区并再次插入数据。希望这可以帮助....

关于hadoop - 创建表后的Hive分区和新属性介绍,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33163385/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com