You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "David Lavati (JIRA)" <ji...@apache.org> on 2019/01/23 14:39:00 UTC

[jira] [Resolved] (HIVE-21066) unexpected SemanticException

     [ https://issues.apache.org/jira/browse/HIVE-21066?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Lavati resolved HIVE-21066.
---------------------------------
    Resolution: Not A Problem
      Assignee: David Lavati

Hi [~rshetye], this doesn't seem an issue to me as after the equals sign the right side of the equation is being evaluated:

The exception is speaking of string and boolean not being the same type.
 Changing the query a little bit in one of the 2 ways works:
{code:sql}
0: jdbc:hive2://localhost:10000> select (c1=c1) in (true) a from (select "a" c1 )t1; -- parenthesis has precedence
+-------+
|   a   |
+-------+
| true  |
+-------+
0: jdbc:hive2://localhost:10000> select c1=c2 in (true) a from (select true c1, false c2 )t1; -- all values are boolean, so c2 in (true) is being compared to c1
+--------+
|   a    |
+--------+
| false  |
+--------+
{code}
This behavior is normal in e.g. PostgreSQL as well:
{code:sql}
postgres=# select 1=1 in (true);
ERROR:  operator does not exist: integer = boolean
LINE 1: select 1=1 in (true);
                   ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
postgres=# select (1=1) in (true);
 ?column?
----------
 t
(1 row)

postgres=# select false=true in (false);
 ?column?
----------
 t
(1 row)
{code}

> unexpected SemanticException
> ----------------------------
>
>                 Key: HIVE-21066
>                 URL: https://issues.apache.org/jira/browse/HIVE-21066
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 2.3.0
>            Reporter: Ravi Shetye
>            Assignee: David Lavati
>            Priority: Major
>
> *WORKS*
> {noformat}
> 0: jdbc:hive2://localhost:10000> select c1=c1  from (select "a" as c1) t1;
> +-------+
> |  _c0  |
> +-------+
> | true  |
> +-------+
> {noformat}
> {noformat}
> 0: jdbc:hive2://localhost:10000> select c1 in ("a","b") a from (select "a" c1 )t1 ;
> +-------+
> |   a   |
> +-------+
> | true  |
> +-------+
> {noformat}
> {noformat}
> 0: jdbc:hive2://localhost:10000> select true in (true) a from (select "a" c1 )t1;
> +-------+
> |   a   |
> +-------+
> | true  |
> +-------+
> {noformat}
> *DOES NOT WORK*
> {noformat}
> 0: jdbc:hive2://localhost:10000> select c1=c1 in (true) a from (select "a" c1 )t1 ;
> Error: Error while compiling statement: FAILED: SemanticException Line 0:-1 Wrong arguments 'true': The arguments for IN should be the same type! Types are: {string IN (boolean)} (state=42000,code=40000)
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)