Uploaded image for project: 'Pig'
  1. Pig
  2. PIG-3375

CASE does not preserve the order of when branches

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.12.0
    • None
    • None

    Description

      Currently CASE expression builds nested BinCond expressions in the following order: from top to bottom when branches => from in to out bin conds.

      This can be confusing if non-mutually exclusive conditions are used in when branches. For example,

      CASE 
          WHEN x > 100 THEN 'a'
          WHEN x > 50  THEN 'b'
          ELSE 'c'
      END
      

      is converted to

      x > 50 ? 'b' : ( x > 100 ? 'a' : 'c' )
      

      Now if x is 1000, the result is 'b', which is not quite expected.

      Instead, we should construct nested BinCond expressions in the same order as that of when branches, i.e.

      x > 100 ? 'a' : ( x > 50 ? 'b' : 'c' )
      

      Attachments

        1. PIG-3375.patch
          3 kB
          Cheolsoo Park

        Activity

          People

            cheolsoo Cheolsoo Park
            cheolsoo Cheolsoo Park
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: