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

CASE does not preserve the order of when branches

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.12.0
    • Component/s: None
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: