Hi
The fields' names are part of the struct definition.
Different names, different types of structs.
Dudu
e.g.
Setup
create table t1 (s struct<c1:int,c2:int>);
create table t2 (s struct<col1:int,col2:int>);
insert into table t1 select named_struct('c1',1,'c2',2);
----------------------------------------------------------------------------------
insert into t2 select * from t1;
FAILED: SemanticException [Error 10044]: Line 1:12 Cannot insert into target
table because column number/types are different 't2': Cannot convert column 0
from struct<c1:int,c2:int> to struct<col1:int,col2:int>.
----------------------------------------------------------------------------------
Solution 1 (per INSERT)
insert into t2 select named_struct('col1',s.c1,'col2',s.c2) from t1;
Solution 2 (one time)
alter table t2 change s s struct<c1:int,c2:int>;
insert into t2 select * from t1;
From: Kuldeep Chitrakar [mailto:[email protected]]
Sent: Tuesday, June 28, 2016 4:03 PM
To: [email protected]
Subject: Hive error : Can not convert struct<> to <struct>
Hi
I have staged table as
hive (revise)> desc employees_se;
OK
name string
salary float
subordinates array<string>
deductions map<string,float>
adr struct<street:string,cty:string,st:string,zip:int>
I am trying to insert the data in partitioned table employees as
hive (revise)> desc employees;
OK
name string
salary float
subordinates array<string>
deductions map<string,float>
address struct<street:string,city:string,state:string,zip:int>
state string
# Partition Information
# col_name data_type comment
state string
Time taken: 0.161 seconds, Fetched: 11 row(s)
Command
FROM employees_se se
INSERT OVERWRITE TABLE employees
PARTITION(state='CA')
SELECT * WHERE se.adr.st='CA'
But I am getting an error as
FAILED: SemanticException [Error 10044]: Line 2:23 Cannot insert into target
table because column number/types are different ''CA'': Cannot convert column 4
from struct<street:string,cty:string,st:string,zip:int> to
struct<street:string,city:string,state:string,zip:int>.
Any idea, as I do not see anything wrong.