如何从 grunt shell 以猪拉丁语运行宏?
Posted
技术标签:
【中文标题】如何从 grunt shell 以猪拉丁语运行宏?【英文标题】:How to run a macro in pig latin from grunt shell? 【发布时间】:2012-09-10 14:24:47 【问题描述】:我有一个宏,可以在过滤数据后计算记录数。但是当我在 grunt shell 中运行宏时,会出现以下错误:
grunt> DEFINE count_by_group(X) RETURNS Y
A = GROUP $X ALL;
$Y = FOR EACH A GENERATE COUNT($X);
;
出现的错误:
ERROR org.apache.pig.tools.grunt.Grunt - ERROR 2999:
Unexpected internal error. Can not create a Path from a null string
猪日志中的完整堆栈跟踪:
================================================================================
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)
================================================================================
请帮助。提前致谢。
问候,
陈丹
【问题讨论】:
【参考方案1】:你不能; grunt does not support macros.
【讨论】:
【参考方案2】:在 Pig Latin 代码中通过将宏分配给关系来调用宏。宏不能在命令行中传递。
【讨论】:
以上是关于如何从 grunt shell 以猪拉丁语运行宏?的主要内容,如果未能解决你的问题,请参考以下文章
如何在 grunt shell 中抑制信息消息“io.bytes.per.checksum 已弃用”