You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@impala.apache.org by Jin Chul Kim <ji...@gmail.com> on 2017/11/29 05:33:03 UTC

[IMPALA-3060] Supports IS [NOT] NULL feature for complex types(e.g. STRUCT)

Hi,

I would like to get your advice before taking over the ticket.
https://issues.apache.org/jira/browse/IMPALA-3060

I already know how works IS [NOT] NULL for primitive type, but I don't know
null status for complex types. As far as I know, it is impossible to assign
null to struct column directly(I mean logically). When do we define a
struct column is null? Please see the example below.

I asked the following questions to Hive user mailing list. I haven't got
any response yet, but I would like to hear your opinion also. Thanks.

Best regards,
Jinchul

------------------------------------------------------------------------------------------------------
- The following example is only available on Hive.

May I know the meaning of IS [NOT] NULL for a complex type such as STRUCT?
As far as I know, we cannot assign NULL to struct directly.
So, I expected them:
1) NULL returns if any of the elements in struct has NULL
2) NULL returns if all of the elements in struct have NULL

By the way, my assumption was wrong in my example below. Could you let me
know when struct is null?

For example,
create table t1(a struct<c1:int, c2:string, c3:double>);
insert into t1 select named_struct('c1', 100, 'c2', 'test', 'c3', 1.234);
insert into t1 select named_struct('c1', cast(null as int), 'c2', 'test',
'c3', 1.234);
insert into t1 select named_struct('c1', 100, 'c2', cast(null as string),
'c3', 1.234);
insert into t1 select named_struct('c1', 100, 'c2', 'test', 'c3', cast(null
as double));
insert into t1 select named_struct('c1', cast(null as int), 'c2', cast(null
as string), 'c3', cast(null as double));
select a is null, * from t1;
false   {"c1":100,"c2":"test","c3":1.234}
false   {"c1":null,"c2":"test","c3":1.234}
false   {"c1":100,"c2":null,"c3":1.234}
false   {"c1":100,"c2":"test","c3":null}
false   {"c1":null,"c2":null,"c3":null}