|
|
-
Re: Diagnostic Operators inside Macros
Alan Gates 2012-05-29, 21:30
It's not an intended feature, but it is a side effect of the way macros are implemented. Pig actually has a couple of parser in it. One parses Pig Latin, the other is used by Grunt, the shell. Grunt does not know Pig Latin, but it knows to pass it on to the Pig Latin parser. Pig Latin knows nothing of Grunt.
Describe, dump, explain, and illustrate are implemented in Grunt, not Pig Latin. Macros are resolved (that is, replaced and written inline) by the Pig Latin parser before Grunt is called. Since the Pig Latin parser doesn't understand Grunt commands, it is complaining when it encounters them inside macros.
Alan.
On May 24, 2012, at 9:43 AM, Daniel Duckworth wrote:
> Hello everyone, > > I have been trying to debug some macros I've written, but I'm finding that every Diagnostic Operator (describe, dump, explain, and illustrate) are all being recognized as illegal inside a macro. I could find no documentation stating that they are disallowed in this context, so I wanted to check that I'm not doing anything silly before opening a JIRA ticket. Any explanations for the issues I'm having would be highly appreciated. Here's some example code, > > -------------------- > DEFINE dumpme(data) RETURNS void { > DUMP $data; > }; > > positions = LOAD '/user/dduckwor/positions' USING AvroStorage(); > dumpme(positions); > -------------------- > > And the output from doing "pig –dryrun test.pig", > > -------------------- > 2012-05-24 09:42:21,737 [main] ERROR org.apache.pig.Main - ERROR 1200: <file src/test.pig.substituted, line 6> Failed to parse macro 'dumpme'. Reason: <file src/test.pig.substituted, line 2, column 2> Syntax error, unexpected symbol at or near 'DUMP' > macro content: > DUMP positions; > -------------------- >
-
Re: Diagnostic Operators inside Macros
Jonathan Coveney 2012-05-29, 22:28
There is a GSOC to move grunt into ANTLR, which may make it possible (if it is desirable) to move more of these commands into macros.
2012/5/29 Alan Gates <[EMAIL PROTECTED]>
> It's not an intended feature, but it is a side effect of the way macros > are implemented. Pig actually has a couple of parser in it. One parses > Pig Latin, the other is used by Grunt, the shell. Grunt does not know Pig > Latin, but it knows to pass it on to the Pig Latin parser. Pig Latin knows > nothing of Grunt. > > Describe, dump, explain, and illustrate are implemented in Grunt, not Pig > Latin. Macros are resolved (that is, replaced and written inline) by the > Pig Latin parser before Grunt is called. Since the Pig Latin parser > doesn't understand Grunt commands, it is complaining when it encounters > them inside macros. > > Alan. > > On May 24, 2012, at 9:43 AM, Daniel Duckworth wrote: > > > Hello everyone, > > > > I have been trying to debug some macros I've written, but I'm finding > that every Diagnostic Operator (describe, dump, explain, and illustrate) > are all being recognized as illegal inside a macro. I could find no > documentation stating that they are disallowed in this context, so I wanted > to check that I'm not doing anything silly before opening a JIRA ticket. > Any explanations for the issues I'm having would be highly appreciated. > Here's some example code, > > > > -------------------- > > DEFINE dumpme(data) RETURNS void { > > DUMP $data; > > }; > > > > positions = LOAD '/user/dduckwor/positions' USING AvroStorage(); > > dumpme(positions); > > -------------------- > > > > And the output from doing "pig –dryrun test.pig", > > > > -------------------- > > 2012-05-24 09:42:21,737 [main] ERROR org.apache.pig.Main - ERROR 1200: > <file src/test.pig.substituted, line 6> Failed to parse macro 'dumpme'. > Reason: <file src/test.pig.substituted, line 2, column 2> Syntax error, > unexpected symbol at or near 'DUMP' > > macro content: > > DUMP positions; > > -------------------- > > > >
|
|