Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.11
    • Fix Version/s: 0.12.0
    • Component/s: internal-udfs, parser
    • Labels:
      None
    • Release Note:
      Hide
      Pig now supports IN operator, and it can be used in any conditional expressions. For example,
      bar = FILTER foo BY i IN ('a', 'b', 'c');
      Show
      Pig now supports IN operator, and it can be used in any conditional expressions. For example, bar = FILTER foo BY i IN ('a', 'b', 'c');

      Description

      This is another language improvement using the same approach as in PIG-3268.

      Currently, Pig has no support for IN operator. To mimic it, users often have to concatenate several OR operators.

      For example,

      a = LOAD '1.txt' USING PigStorage(',') AS (i:int);
      b = FILTER a BY 
         (i == 1) OR
         (i == 22) OR
         (i == 333) OR
         (i == 4444) OR
         (i == 55555);
      

      But this can be re-rewritten in a more compact manner using IN operator as follows:

      a = LOAD '1.txt' USING PigStorage(',') AS (i:int);
      b = FILTER a BY i IN (1,22,333,4444,55555);
      

      I propose that we implement IN operator in the following manner:

      • Add built-in UDFs that take expressions as args. Take for example the aforementioned IN operator, we can define a UDF such as builtInUdf(i, 1, 22, 333, 4444, 55555).
      • Add syntactical sugar for these built-in UDFs.

        Attachments

        1. PIG-3269.patch
          7 kB
          Cheolsoo Park
        2. PIG-3269-2.patch
          6 kB
          Cheolsoo Park
        3. PIG-3269-3.patch
          17 kB
          Cheolsoo Park
        4. PIG-3269-4.patch
          17 kB
          Cheolsoo Park
        5. PIG-3269-5.patch
          16 kB
          Cheolsoo Park

          Issue Links

            Activity

              People

              • Assignee:
                cheolsoo Cheolsoo Park
                Reporter:
                cheolsoo Cheolsoo Park
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: