David Ross created HIVE-21494:
---------------------------------
Summary: Wrong CASE branch chosen seemingly dependent on contents
of branch
Key: HIVE-21494
URL: https://issues.apache.org/jira/browse/HIVE-21494
Project: Hive
Issue Type: Bug
Affects Versions: 3.1.0
Reporter: David Ross
The following query returns {{-100}} which is logically incorrect:
{code:java}
SELECT
CASE
WHEN COALESCE(
CASE
WHEN COALESCE( CAST('Infinity' AS DOUBLE), 0 ) = 0
THEN -1
ELSE ( 5 / (CAST('Infinity' AS DOUBLE) * SIGN(5)) )
END, 0 ) = 0
THEN (
CAST('Infinity' AS DOUBLE)
-- -200
)
ELSE -100
END full_query{code}
The expected behavior is for it to return {{Infinity}}, or the contents of the
{{THEN}} branch.
If the {{THEN}} branch is edited like this, it returns -{{200}} as expected:
{code:java}
SELECT
CASE
WHEN COALESCE(
CASE
WHEN COALESCE( CAST('Infinity' AS DOUBLE), 0 ) = 0
THEN -1
ELSE ( 5 / (CAST('Infinity' AS DOUBLE) * SIGN(5)) )
END, 0 ) = 0
THEN (
-- CAST('Infinity' AS DOUBLE)
-200
)
ELSE -100
END full_query{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)