title: Datatype conversion error in Hive CASE statement
body: <p>I have a HiveQL query that looks something like:</p>
  
  <pre><code>SELECT  ID, 
          CASE WHEN col_a = 0 THEN 0
          ELSE (col_b / col_a) END AS math_is_fun
  FROM    (/* derived query*/) AS x ;
  </code></pre>
  
  <p>When I execute this in Hive, I recently started getting the error <code>FAILED: Error in semantic analysis: Line X:Y ArgumentTypeMismatch 'col_a': The expression after ELSE should have the same type as those after THEN: "int" is expected but "double" is found.</code></p>
  
  <p>While I understand that there's a data type mismatch between the literal <code>0</code> and the result of <code>(col_a / col_b)</code>, I'm not clear why Hive is choking on this and, more importantly, what the best course of action is to resolve this error. Should I cast the literal <code>0</code> as a <code>double</code> or is there a better approach?</p>
  
  <p>This is Hive 0.8.1 running in Amazon EMR.</p>