Hi how to overwrite columns value by selecting same partition table in hive.
I have created table by executing below query
CREATE TABLE user (fname string,lname string) partitioned By (day int);
And i insert the data , after inserting data into table . I executed select query it looks like below:
AA AA 20170201
BB BB 20170201
CC CC 20170201
DD DD 20170202
EE EE 20170203
As per my requirement, I want to add one more column to my table(user) ,with the help of below query I added.
ALTER TABLE user ADD COLUMNS ( day2 int);
After adding column,my table look like below
AA AA NULL 20170201
BB BB NULL 20170201
CC CC NULL 20170201
DD DD NULL 20170202
EE EE NULL 20170203
But I want table like.
AA AA 20170201 20170202
BB BB 20170201 20170202
CC CC 20170201 20170202
DD DD 20170202 20170202
EE EE 20170203 20170203
So I executed below query
insert overwrite table user partition (day)
select
fname,
lname,
day as day2,
case
when day <= 20170202 then 20170202
when day > 20170202 then day
end as day
from user;
then I have executed select query like below
select * from user;
result is :
AA AA NULL 20170201
BB BB NULL 20170201
CC CC NULL 20170201
AA AA NULL 20170202
BB BB NULL 20170202
CC CC NULL 20170202
DD DD NULL 20170202
EE EE NULL 20170203
why i am getting null values.Can please let me know anything I missed out, let how to achieve this.i.e
AA AA 20170201 20170202
BB BB 20170201 20170202
CC CC 20170201 20170202
DD DD 20170202 20170202
EE EE 20170203 20170203