It seems that all Hive columns (at least those of primitive types) are always 
NULLable?  What about columns of type STRUCT?

The following:

echo 1,2 >twovalues.csv
hive
CREATE TABLE tc (x INT, y INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
LOAD DATA LOCAL INPATH 'twovalues.csv' INTO TABLE tc;
CREATE TABLE oc (z STRUCT<a: int, b: int>);
INSERT INTO TABLE oc SELECT null FROM tc;

produces the error

FAILED: SemanticException [Error 10044]: Line 1:18 Cannot insert into target 
table because column number/types are different 'oc': Cannot convert column 0 
from void to struct<a:int,b:int>.

I initially discovered such behavior with Avro-backed tables, and even entered 
a JIRA
https://issues.apache.org/jira/browse/HIVE-4022
but now I realized it happens with CSV-backed tables as well.

Perhaps related, perhaps not, it seems that all members of a STRUCT are always 
non-NULLable.  The following:

INSERT INTO TABLE oc SELECT named_struct('a', null, 'b', null) FROM tc;

produces the error:

FAILED: SemanticException [Error 10044]: Line 1:18 Cannot insert into target 
table because column number/types are different 'oc': Cannot convert column 0 
from struct<a:void,b:void> to struct<a:int,b:int>.

Reply via email to