导入 Pig 脚本时出错
Error while IMPORT Pig Script
要在每个 pig latin 脚本文件中设置的一组宏、jar 和属性。已将所有这些移动到 common.pig。
Objective就是把这个普通的pig文件包含在所有的pig latin文件中。
按照Invoke Pig Latin script from other Pig script
中的建议尝试了以下方法
方法 1:使用 运行,按预期工作。
Usage : RUN common.pig;
方法 2:使用 IMPORT 会导致错误。
Usage : IMPORT 'common.pig';
Error message :
ERROR 1200: <file common.pig, line 1, column 0> Syntax error, unexpected symbol at or near 'SET'
org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1000: Error during parsing. <file common_macro.pig, line 1, column 0> Syntax error, unexpected symbol at or near 'SET'
at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1608)
at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1547)
我想了解第二种方法失败的原因。我对 IMPORT 的理解是直接把导入的文件写入 pig 脚本,而不是 IMPORT 语句,如果是这样的话,理想情况下应该不会抛出上面的错误。
对此有任何意见/想法。
同样从代码模块化/可维护性/执行的角度来看,在上述用例中使用 EXEC 或 运行 命令调用 common.pig 文件更好。
文件:
common.pig
SET job.priority HIGH;
-- SET few others ...;
REGISTER snappy-java-1.0.4.1.jar;
-- REGISTER piggybank, avro and other required jars
test_import.pig
IMPORT 'common.pig';
A = load 'test/part*' USING org.apache.pig.piggybank.storage.avro.AvroStorage();
DUMP A;
SET
在导入文件中不受支持。
阅读 IMPORT Macro show that Grunt Shell command 不受支持 - 见下文
Usage Use the IMPORT command to import a macro defined in a separate file into your Pig script.
IMPORT adds the macro definitions to the Pig Latin namespace; these
macros can then be invoked as if they were defined in the same file.
Macros can only contain Pig Latin statements; Grunt shell commands are
not supported.
要在每个 pig latin 脚本文件中设置的一组宏、jar 和属性。已将所有这些移动到 common.pig。 Objective就是把这个普通的pig文件包含在所有的pig latin文件中。
按照Invoke Pig Latin script from other Pig script
中的建议尝试了以下方法方法 1:使用 运行,按预期工作。
Usage : RUN common.pig;
方法 2:使用 IMPORT 会导致错误。
Usage : IMPORT 'common.pig';
Error message :
ERROR 1200: <file common.pig, line 1, column 0> Syntax error, unexpected symbol at or near 'SET'
org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1000: Error during parsing. <file common_macro.pig, line 1, column 0> Syntax error, unexpected symbol at or near 'SET'
at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1608)
at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1547)
我想了解第二种方法失败的原因。我对 IMPORT 的理解是直接把导入的文件写入 pig 脚本,而不是 IMPORT 语句,如果是这样的话,理想情况下应该不会抛出上面的错误。
对此有任何意见/想法。
同样从代码模块化/可维护性/执行的角度来看,在上述用例中使用 EXEC 或 运行 命令调用 common.pig 文件更好。
文件:
common.pig
SET job.priority HIGH;
-- SET few others ...;
REGISTER snappy-java-1.0.4.1.jar;
-- REGISTER piggybank, avro and other required jars
test_import.pig
IMPORT 'common.pig';
A = load 'test/part*' USING org.apache.pig.piggybank.storage.avro.AvroStorage();
DUMP A;
SET
在导入文件中不受支持。
阅读 IMPORT Macro show that Grunt Shell command 不受支持 - 见下文
Usage Use the IMPORT command to import a macro defined in a separate file into your Pig script.
IMPORT adds the macro definitions to the Pig Latin namespace; these macros can then be invoked as if they were defined in the same file.
Macros can only contain Pig Latin statements; Grunt shell commands are not supported.