Search code examples
hadoopapache-pig

Exit pig shell command safely


When I enter some erroneous command in a Pig interactive shell environment, it enters into listening mode (>>) like below. How do I safely come out of this command, but still stay in the pig shell environment?

Ctrl + C takes me out of the pig shell and I lose my environment setup till that point.

**grunt> Test_group = group Block2_Prep_filter by (page_visit_id as grp_page_visit_id, page_user_guid as grp_page_user_guid);
>> ;
>>
>>**

Solution

  • I've looked in the pig source code. This is called the secondary_prompt (found in PigScriptParser.jj, a context-free parser grammar file for JavaCC). To my eye it looks like it can't be gotten out of. I tried a lot of combinations of things I saw in that code and nothing worked. Also tried all the exit type words I could think of, to no avail.

    When I did Ctrl + D, it exited and displayed:

    >> 2013-06-19 12:51:43,632 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000:
    Error during parsing. Lexical error at line 83, column 0.  Encountered: <EOF> after : ""
    

    Looking in the Grunt class, at that point, it does:

    parser.setInteractive(false);
    return parser.parseStopOnError();
    

    This suggests to me that interactivity is over at this point.