[
https://issues.apache.org/jira/browse/HIVE-17460?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Chaozhong Yang updated HIVE-17460:
----------------------------------
Description:
In Hive, adding columns into original table is a common use case. However, if
we insert overwrite older partitions after adding columns, added columns will
not be accessed.
```
create table src_table(
i int
)
PARTITIONED BY (`date` string);
insert overwrite table src_table partition(`date`='20170905') valu
es (3);
select * from src_table where `date` = '20170905';
alter table src_table add columns (bi bigint);
insert overwrite table src_table partition(`date`='20170905') valu
es (3, 5);
select * from src_table where `date` = '20170905';
```
The result will be as follows:
```
3, NULL, '20170905'
```
Obviously, it doesn't meet our expectation. The expected result should be:
```
3, 5, '20170905'
```
was:
In Hive, adding columns into original table is a common use case. However, If
we insert overwrite older partitions after adding columns, added columns will
not be accessed.
```
create table src_table(
i int
)
PARTITIONED BY (`date` string);
insert overwrite table src_table partition(`date`='20170905') valu
es (3);
select * from src_table where `date` = '20170905';
alter table src_table add columns (bi bigint);
insert overwrite table src_table partition(`date`='20170905') valu
es (3, 5);
select * from src_table where `date` = '20170905';
```
The result will be as follows:
```
3, NULL, '20170905'
```
Obviously, it doesn't meet our expectation. The expected result should be:
```
3, 5, '20170905'
```
> `insert overwrite` should support table schema evolution (e.g. add columns)
> ---------------------------------------------------------------------------
>
> Key: HIVE-17460
> URL: https://issues.apache.org/jira/browse/HIVE-17460
> Project: Hive
> Issue Type: Bug
> Affects Versions: 2.1.0, 2.2.0
> Reporter: Chaozhong Yang
> Assignee: Chaozhong Yang
> Fix For: 3.0.0
>
> Attachments: HIVE-17460.patch
>
>
> In Hive, adding columns into original table is a common use case. However, if
> we insert overwrite older partitions after adding columns, added columns will
> not be accessed.
> ```
> create table src_table(
> i int
> )
> PARTITIONED BY (`date` string);
> insert overwrite table src_table partition(`date`='20170905') valu
> es (3);
> select * from src_table where `date` = '20170905';
> alter table src_table add columns (bi bigint);
> insert overwrite table src_table partition(`date`='20170905') valu
> es (3, 5);
> select * from src_table where `date` = '20170905';
> ```
> The result will be as follows:
> ```
> 3, NULL, '20170905'
> ```
> Obviously, it doesn't meet our expectation. The expected result should be:
> ```
> 3, 5, '20170905'
> ```
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)