[
https://issues.apache.org/jira/browse/HIVE-16486?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dudu Markovitz updated HIVE-16486:
----------------------------------
Description:
h2. Use case 1: adding a column in the middle of a table
{code}
create table mytable (i1 int,i3 int) partitioned by (ver int) stored as
textfile;
insert into mytable partition(ver=1) values (1,2),(3,4);
select * from mytable;
{code}
||i1||i3||ver||
|1|2|1|
|3|4|1|
{code}
alter table mytable replace columns (i1 int,i2 int,i3 int);
insert into mytable partition(ver=2) values (5,6,7),(8,9,10);
select * from mytable;
{code}
I would expect values 2 and 4 to appear under column i3 , In accordance with
the columns definition of partition ver=1, but they appear under column i2.
||i1||i2||i3||ver||
|1|2|(null)|1|
|3|4|(null)|1|
|5|6|7|2|
|8|9|10|2|
h2. Use case 2: dropping a column
{code}
create table mytable (i1 int,i2 int) partitioned by (ver int) stored as
textfile;
insert into mytable partition(ver=1) values (1,2),(3,4);
select * from mytable;
{code}
||i1||i2||ver||
|1|2|1|
|3|4|1|
{code}
alter table mytable replace columns (i1 int);
insert into mytable partition(ver=2) values (5),(6);
select * from mytable;
{code}
||i1||ver||
|1|1|
|3|1|
|5|2|
|6|2|
I would expect column i2 to be part of the columns list when asterisk is being
used or at least that is would be available for explicit use
{code}
select i1,i2 from mytable;
{code}
{quote}
{color:red}
Error while compiling statement: FAILED: SemanticException [Error 10004]: Line
1:10 Invalid table alias or column reference 'i2': (possible column names are:
i1, ver)
{color}
{quote}
h2. Use case 3: Insert to a specific partition after adding a column at the end
{code}
create table t (i int) partitioned by (ver int);
alter table t add partition (ver=1);
alter table t add columns (j int);
alter table t add partition (ver=2);
I would expect that insert into partition ver=1 will require a single value
(for column i)
{code}
insert into t partition (ver=1) values (1);
{code}
{quote}
{color:red}
Error while compiling statement: FAILED: SemanticException [Error 10044]: Line
1:12 Cannot insert into target table because column number/types are different
'1': Table insclause-0 has 2 columns, but query has 1 columns.
{color}
{quote}
Apparently the number of columns id derived from the current table definition
and not from the partition definition
{code}
insert into t partition (ver=1) values (1,2);
insert into t partition (ver=2) values (3,4);
>From the other end, although we are forced to supply values for all columns
>the columns (including column j which is not defined for partition ver=1) the
>values are not displayed
{code}
select * from t;
{code}
||i||j||ver||
|1|(null)|1|
|3|4|2|
(The data does exist in the files)
was:
h4. Use case 1: adding a column in the middle of a table
{code}
create table mytable (i1 int,i3 int) partitioned by (ver int) stored as
textfile;
insert into mytable partition(ver=1) values (1,2),(3,4);
select * from mytable;
{code}
||i1||i3||ver||
|1|2|1|
|3|4|1|
{code}
alter table mytable replace columns (i1 int,i2 int,i3 int);
insert into mytable partition(ver=2) values (5,6,7),(8,9,10);
select * from mytable;
{code}
I would expect values 2 and 4 to appear under column i3 , In accordance with
the columns definition of partition ver=1, but they appear under column i2.
||i1||i2||i3||ver||
|1|2|(null)|1|
|3|4|(null)|1|
|5|6|7|2|
|8|9|10|2|
h4. Use case 2: dropping a column
{code}
create table mytable (i1 int,i2 int) partitioned by (ver int) stored as
textfile;
insert into mytable partition(ver=1) values (1,2),(3,4);
select * from mytable;
{code}
||i1||i2||ver||
|1|2|1|
|3|4|1|
{code}
alter table mytable replace columns (i1 int);
insert into mytable partition(ver=2) values (5),(6);
select * from mytable;
{code}
||i1||ver||
|1|1|
|3|1|
|5|2|
|6|2|
I would expect column i2 to be part of the columns list when asterisk is being
used or at least that is would be available for explicit use
{code}
select i1,i2 from mytable;
{code}
{quote}
{color:red}
Error while compiling statement: FAILED: SemanticException [Error 10004]: Line
1:10 Invalid table alias or column reference 'i2': (possible column names are:
i1, ver)
{color}
{quote}
h4. Use case 1: Insert to a specific partition after adding a column at the end
{code}
create table t (i int) partitioned by (ver int);
alter table t add partition (ver=1);
alter table t add columns (j int);
alter table t add partition (ver=2);
I would expect that insert into partition ver=1 will require a single value
(for column i)
{code}
insert into t partition (ver=1) values (1);
{code}
{quote}
{color:red}
Error while compiling statement: FAILED: SemanticException [Error 10044]: Line
1:12 Cannot insert into target table because column number/types are different
'1': Table insclause-0 has 2 columns, but query has 1 columns.
{color}
{quote}
Apperantly the number of columns id derived from the current table definition
and not from the partition definition
{code}
insert into t partition (ver=1) values (1,2);
insert into t partition (ver=2) values (3,4);
>From the other end, although we are forced to supply values for all columns
>the columns (including column j which is not defined for partition ver=1) the
>values are not displayed
{code}
select * from t;
{code}
||i||j||ver||
|1|(null)|1|
|3|4|2|
(The data does exist in the files)
> schema changes for partitioned tables (RESTRICT, not CASCADE) seems to lead
> to unreasonable behaviour
> -----------------------------------------------------------------------------------------------------
>
> Key: HIVE-16486
> URL: https://issues.apache.org/jira/browse/HIVE-16486
> Project: Hive
> Issue Type: Bug
> Components: Serializers/Deserializers
> Affects Versions: 1.1.0
> Reporter: Dudu Markovitz
>
> h2. Use case 1: adding a column in the middle of a table
> {code}
> create table mytable (i1 int,i3 int) partitioned by (ver int) stored as
> textfile;
> insert into mytable partition(ver=1) values (1,2),(3,4);
> select * from mytable;
> {code}
> ||i1||i3||ver||
> |1|2|1|
> |3|4|1|
> {code}
> alter table mytable replace columns (i1 int,i2 int,i3 int);
> insert into mytable partition(ver=2) values (5,6,7),(8,9,10);
> select * from mytable;
> {code}
> I would expect values 2 and 4 to appear under column i3 , In accordance with
> the columns definition of partition ver=1, but they appear under column i2.
> ||i1||i2||i3||ver||
> |1|2|(null)|1|
> |3|4|(null)|1|
> |5|6|7|2|
> |8|9|10|2|
> h2. Use case 2: dropping a column
> {code}
> create table mytable (i1 int,i2 int) partitioned by (ver int) stored as
> textfile;
> insert into mytable partition(ver=1) values (1,2),(3,4);
> select * from mytable;
> {code}
> ||i1||i2||ver||
> |1|2|1|
> |3|4|1|
> {code}
> alter table mytable replace columns (i1 int);
> insert into mytable partition(ver=2) values (5),(6);
> select * from mytable;
> {code}
> ||i1||ver||
> |1|1|
> |3|1|
> |5|2|
> |6|2|
> I would expect column i2 to be part of the columns list when asterisk is
> being used or at least that is would be available for explicit use
> {code}
> select i1,i2 from mytable;
> {code}
> {quote}
> {color:red}
> Error while compiling statement: FAILED: SemanticException [Error 10004]:
> Line 1:10 Invalid table alias or column reference 'i2': (possible column
> names are: i1, ver)
> {color}
> {quote}
> h2. Use case 3: Insert to a specific partition after adding a column at the
> end
> {code}
> create table t (i int) partitioned by (ver int);
> alter table t add partition (ver=1);
> alter table t add columns (j int);
> alter table t add partition (ver=2);
> I would expect that insert into partition ver=1 will require a single value
> (for column i)
> {code}
> insert into t partition (ver=1) values (1);
> {code}
> {quote}
> {color:red}
> Error while compiling statement: FAILED: SemanticException [Error 10044]:
> Line 1:12 Cannot insert into target table because column number/types are
> different '1': Table insclause-0 has 2 columns, but query has 1 columns.
> {color}
> {quote}
> Apparently the number of columns id derived from the current table definition
> and not from the partition definition
> {code}
> insert into t partition (ver=1) values (1,2);
> insert into t partition (ver=2) values (3,4);
> From the other end, although we are forced to supply values for all columns
> the columns (including column j which is not defined for partition ver=1) the
> values are not displayed
> {code}
> select * from t;
> {code}
> ||i||j||ver||
> |1|(null)|1|
> |3|4|2|
> (The data does exist in the files)
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)