Hajime Osako created IMPALA-8664:
------------------------------------
Summary: Inconsistent result by integer multiply NULL
Key: IMPALA-8664
URL: https://issues.apache.org/jira/browse/IMPALA-8664
Project: IMPALA
Issue Type: Bug
Affects Versions: Impala 2.11.0
Reporter: Hajime Osako
h3. A: "SELECT 1 * (NULL)" and "SELECT 1 * (CASE ...)" returns different result:
Expected result "null":
{code:sql}
0: jdbc:hive2://test> SELECT 1 * (NULL);
null
{code}
The CASE part returns NULL, so expected same as above, but actually Exception:
{code:sql}
0: jdbc:hive2://test> select 1 * (CASE WHEN '1' IS NULL THEN NULL ELSE NULL
END);
Error: AnalysisException: Arithmetic operation requires numeric operands: 1 *
(CASE WHEN '1' IS NULL THEN NULL ELSE NULL END) (state=HY000,code=0)
{code}
h3. B: Using aggregation in CASE or without returns different result:
As per A, below query failing is kind of understandable:
{code:sql}
0: jdbc:hive2://test> SELECT (-1 * CASE WHEN SUM(1) IS NULL THEN NULL WHEN
COALESCE(NULL, 0) = 0 THEN NULL ELSE 0 END) FROM (SELECT 1 as col1, 2 as col2)
dummy_t;
Error: AnalysisException: Arithmetic operation requires numeric operands: (-1 *
CASE WHEN sum(1) IS NULL THEN NULL ELSE NULL END) (state=HY000,code=0)
{code}
But, removing SUM returns different result (no exception...):
{code:sql}
0: jdbc:hive2://test> SELECT (-1 * CASE WHEN COALESCE(NULL, 0) = 0 THEN NULL
ELSE 0 END) FROM (SELECT 1 as col1, 2 as col2) dummy_t;
null
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)