Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a macro in pig latin from grunt shell?

I have a macro that counts the number of records after filtering data. But when I run macro in grunt shell, following error occurs:

grunt> DEFINE count_by_group(X) RETURNS Y { 
           A = GROUP $X  ALL;
           $Y = FOR EACH A GENERATE COUNT($X);
  };

The error that comes:

ERROR org.apache.pig.tools.grunt.Grunt - ERROR 2999:
Unexpected internal error. Can not create a Path from a null string

Complete stack-trace at pig log:

================================================================================
Pig Stack Trace
---------------
ERROR 2999: Unexpected internal error. Can not create a Path from a null string

java.lang.IllegalArgumentException: Can not create a Path from a null string
    at org.apache.hadoop.fs.Path.checkPathArg(Path.java:78)
    at org.apache.hadoop.fs.Path.<init>(Path.java:90)
    at org.apache.pig.impl.io.FileLocalizer.fetchFilesInternal(FileLocalizer.java:770)
    at org.apache.pig.impl.io.FileLocalizer.fetchFile(FileLocalizer.java:737)
    at org.apache.pig.parser.QueryParserDriver.getMacroFile(QueryParserDriver.java:350)
    at org.apache.pig.parser.QueryParserDriver.makeMacroDef(QueryParserDriver.java:406)
    at org.apache.pig.parser.QueryParserDriver.expandMacro(QueryParserDriver.java:268)
    at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:169)
    at org.apache.pig.PigServer$Graph.validateQuery(PigServer.java:1565)
    at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1538)
    at org.apache.pig.PigServer.registerQuery(PigServer.java:540)
    at org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:970)
                                                                                                                                                                                              org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:386)
    at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:189)
    at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:165)
    at org.apache.pig.tools.grunt.Grunt.run(Grunt.java:69)
    at org.apache.pig.Main.run(Main.java:490)
    at org.apache.pig.Main.main(Main.java:111)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
 ================================================================================

Kindly help. Thanks in advance.

Regards,

Chandan

like image 328
Chandan Patra Avatar asked Jan 16 '23 14:01

Chandan Patra


1 Answers

You can't; grunt does not support macros.

like image 74
Cihan Keser Avatar answered Mar 18 '23 21:03

Cihan Keser