Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hive >> mail # user >> NULLable STRUCTs


Copy link to this message
-
Re: NULLable STRUCTs
If no one has any objection, I'm going to update HIVE-4022, which I entered a week ago when I thought the behavior was Avro-specific, to indicate it actually affects even native Hive tables.

https://issues.apache.org/jira/browse/HIVE-4022

--- On Fri, 2/15/13, Michael Malak <[EMAIL PROTECTED]> wrote:

> From: Michael Malak <[EMAIL PROTECTED]>
> Subject: NULLable STRUCTs
> To: [EMAIL PROTECTED]
> Date: Friday, February 15, 2013, 5:03 PM
> 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>.
>
>