You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Michael Malak <mi...@yahoo.com> on 2013/02/16 01:03:36 UTC
NULLable STRUCTs
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>.
Re: NULLable STRUCTs
Posted by Michael Malak <mi...@yahoo.com>.
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 <mi...@yahoo.com> wrote:
> From: Michael Malak <mi...@yahoo.com>
> Subject: NULLable STRUCTs
> To: user@hive.apache.org
> 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>.
>
>