Pig
  1. Pig
  2. PIG-3136

Introduce a syntax making declared aliases optional

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.12.0
    • Component/s: None
    • Labels:
      None
    • Release Note:
      A relation name is no longer required in the left side of a query statement. Instead, a fat arrow (=>) can be used to signify it. To refer the last relation, an arroba (@) can be used.

      Description

      This is something Daniel and I have talked about before, and now that we have the @ syntax, this is easy to implement. The idea is that relation names are no longer required, and you can instead use a fat arrow (obviously that can be changed) to signify this. The benefit is not having to engage in the mental load of having to name everything.

      One other possibility is just making "alias =" optional. I fear that that could be a little TOO magical, but I welcome opinions.

      1. PIG-3136-0.patch
        45 kB
        Jonathan Coveney
      2. PIG-3136-1.patch
        55 kB
        Jonathan Coveney
      3. PIG-3136-2.patch
        57 kB
        Jonathan Coveney
      4. PIG-3136-3.patch
        62 kB
        Jonathan Coveney

        Activity

        Hide
        Jonathan Coveney added a comment -

        This is my implementation. Not terribly complicated, and now you can use the following syntax:

        => load 'thing';
        => foreach (group @ all) generate COUNT_STAR($1);
        dump @;
        

        Pretty neat imho.

        Show
        Jonathan Coveney added a comment - This is my implementation. Not terribly complicated, and now you can use the following syntax: => load 'thing'; => foreach (group @ all) generate COUNT_STAR($1); dump @; Pretty neat imho.
        Hide
        Jonathan Coveney added a comment -

        Updated, add tests, and added RB here: https://reviews.apache.org/r/9496/

        Show
        Jonathan Coveney added a comment - Updated, add tests, and added RB here: https://reviews.apache.org/r/9496/
        Hide
        Doug Daniels added a comment -

        This would be awesome—-I have wanted it many, many times when I don't care about the relation name, but just need a processing step to occur. Also, super helpful for refactoring to add relations in the middle without propagating them all the way down the chain.

        I like the syntax too. It emphasizes continuation from the previous statement well.

        Show
        Doug Daniels added a comment - This would be awesome—-I have wanted it many, many times when I don't care about the relation name, but just need a processing step to occur. Also, super helpful for refactoring to add relations in the middle without propagating them all the way down the chain. I like the syntax too. It emphasizes continuation from the previous statement well.
        Hide
        Cheolsoo Park added a comment -

        Jonathan Coveney, I like your idea a lot. Thank you very much!

        I tested your patch with store, dump, explain, describe and illustrate, and here is the result:

        Command Works Remarks
        store  
        dump  
        explain Shows plans, then throws an error
        describe  
        illustrate Shows tables, then throws an error

        Does it make sense to support all these commands?

        Show
        Cheolsoo Park added a comment - Jonathan Coveney , I like your idea a lot. Thank you very much! I tested your patch with store, dump, explain, describe and illustrate, and here is the result: Command Works Remarks store   dump   explain Shows plans, then throws an error describe   illustrate Shows tables, then throws an error Does it make sense to support all these commands?
        Hide
        Jonathan Coveney added a comment -

        Cheolsoo, thanks for testing it. It absolutely should support those commands, it just skipped my mind to do so. Will add support for that.

        Show
        Jonathan Coveney added a comment - Cheolsoo, thanks for testing it. It absolutely should support those commands, it just skipped my mind to do so. Will add support for that.
        Hide
        Jonathan Coveney added a comment -

        Patch updated to support those commands. Would love a +1, Cheolsoo

        RB updated too: https://reviews.apache.org/r/9496/

        Show
        Jonathan Coveney added a comment - Patch updated to support those commands. Would love a +1, Cheolsoo RB updated too: https://reviews.apache.org/r/9496/
        Hide
        Cheolsoo Park added a comment -

        I tested the new patch. Everything works.

        I made some comment to the RB. I will also run full unit test to ensure we don't break anything.

        Thanks!

        Show
        Cheolsoo Park added a comment - I tested the new patch. Everything works. I made some comment to the RB. I will also run full unit test to ensure we don't break anything. Thanks!
        Hide
        Jonathan Coveney added a comment -

        I've updated the RB and this patch with your comments, Cheolsoo.

        Let me know what you think?

        Show
        Jonathan Coveney added a comment - I've updated the RB and this patch with your comments, Cheolsoo. Let me know what you think?
        Hide
        Cheolsoo Park added a comment -

        +1.

        I noticed that you modified dumpSchema() and dumpSchemaNested() in PigServer. The unit tests fully passed with last patch, but let me run another run of unit test with the new patch. I am almost certain that no test will fail; nevertheless, it's always good to verify.

        Show
        Cheolsoo Park added a comment - +1. I noticed that you modified dumpSchema() and dumpSchemaNested() in PigServer. The unit tests fully passed with last patch, but let me run another run of unit test with the new patch. I am almost certain that no test will fail; nevertheless, it's always good to verify.
        Hide
        Jonathan Coveney added a comment -

        Cheolsoo, can you update this when the tests pass?

        Show
        Jonathan Coveney added a comment - Cheolsoo, can you update this when the tests pass?
        Hide
        Cheolsoo Park added a comment -

        Will do. It's likely that you will find your patch committed tomorrow morning.

        Show
        Cheolsoo Park added a comment - Will do. It's likely that you will find your patch committed tomorrow morning.
        Hide
        Cheolsoo Park added a comment -

        Unit tests pass. I committed to trunk. Thanks Jonathan!

        Show
        Cheolsoo Park added a comment - Unit tests pass. I committed to trunk. Thanks Jonathan!

          People

          • Assignee:
            Jonathan Coveney
            Reporter:
            Jonathan Coveney
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development