Jesus Camacho Rodriguez created HIVE-23223:
----------------------------------------------

             Summary: Unnecessary CAST to decimal around CASE statement
                 Key: HIVE-23223
                 URL: https://issues.apache.org/jira/browse/HIVE-23223
             Project: Hive
          Issue Type: Improvement
          Components: CBO
    Affects Versions: 4.0.0
            Reporter: Jesus Camacho Rodriguez
            Assignee: Jesus Camacho Rodriguez


After HIVE-23100 went in, there was a missed opportunity on the simplification 
of a CAST statement on top of a CASE clause, which can be seen in 
ql/src/test/results/clientpositive/vector_case_when_2.q.out .
{code}
               expressions: q548284 (type: int), CASE WHEN ((q548284 = 4)) THEN 
(0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (8) END (type: decimal(2,1))
{code}
was replaced by:
{code}
               expressions: q548284 (type: int), CAST( CASE WHEN ((q548284 = 
4)) THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (8) END AS decimal(11,1)) 
(type: decimal(11,1))
{code}
The type of the CASE expression could be inferred and enforce without the CAST.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to