title: CASE statements in Hive
body: <p>Ok, i have a following code to mark records that have highest month_cd in tabl with binary flag:</p>
  
  <pre><code>Select t1.month_cd, t2.max_month_cd
    ,CASE WHEN t2.max_month_cd != null then 0 else 1 end test_1
    ,CASE WHEN t2.max_month_cd = null then 0 else 1 end test_2
  from source t1
  Left join (
    Select 
      MAX(month_cd) as max_month_cd 
    From source 
  ) t2 
  on t1.month_cd = t2.max_month_cd;
  </code></pre>
  
  <p>It seems straight forward to me, but result it return is:</p>
  
  <pre><code>month_cd  max_month_cd  test_1  test_2
  201610    null          1       1
  201611    201611        1       1
  </code></pre>
  
  <p>Makes zero sense to me, and seems to be way too obvious to be a bug in execution engine. What am i missing?</p>