[ 
https://issues.apache.org/jira/browse/HIVE-28926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17947067#comment-17947067
 ] 

Stamatis Zampetakis commented on HIVE-28926:
--------------------------------------------

While I was working to understand the IN to OR transformation of STRUCT/ROW in 
[RexNodeConverter#transformInToOrOperands|https://github.com/apache/hive/blob/28abf17424e97112d75947f1d7a2f043b3961fa4/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java#L522]
 I observed that I was getting different results (in_typecheck_mixed.q) with 
and without the transformation that made me realize that there is actually a 
bug in the comparison of STRUCT.

> Wrong results when comparing STRUCT/ROW with nulls
> --------------------------------------------------
>
>                 Key: HIVE-28926
>                 URL: https://issues.apache.org/jira/browse/HIVE-28926
>             Project: Hive
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 4.0.1
>            Reporter: Stamatis Zampetakis
>            Assignee: Stamatis Zampetakis
>            Priority: Major
>
> {code:sql}
> CREATE TABLE t (id int, cstring STRING);
> INSERT INTO t VALUES(1,'A'), (2,'X'), (3,null);
> SELECT id, (t.cstring, 'B') = ('A', 'B') FROM t;
> SELECT id, STRUCT(t.cstring, 'B') = STRUCT('A', 'B') FROM t;
> {code}
> +Expected+
> |1|true|
> |2|false|
> |3|null|
> +Actual+
> |1|true|
> |2|false|
> |3|false|
> The problem can be seen in row 3 when comparing the following STRUCT/ROW 
> types.
> {noformat}
> (null, 'B') = ('A', 'B')
> {noformat}
> The result is *false* but it should be *null* cause equality between null and 
> 'A' is not defined.
> I checked with Postgres and the SQL standard and it seems that returning null 
> is the correct behavior.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to