我似乎无法弄清楚我要怎么做。该脚本对PigStorage来说效果很好,但为CSVLoader提供了此ClassCastException。

我检查了文档,但没有帮助。

这是堆栈跟踪:

Pig Stack Trace
---------------
ERROR 1200: Pig script failed to parse:
<file pig_script.pig, line 15, column 0> pig script failed to validate: java.lang.ClassCastException: org.apache.pig.piggybank.storage.CSVLoader cannot be cast to org.apache.pig.StoreFuncInterface
org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1000: Error during parsing. Pig script failed to parse:
<file pig_script.pig, line 15, column 0> pig script failed to validate: java.lang.ClassCastException: org.apache.pig.piggybank.storage.CSVLoader cannot be cast to org.apache.pig.StoreFuncInterface
at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1597)
at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1540)
at org.apache.pig.PigServer.registerQuery(PigServer.java:540)
at org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:970)
at 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.exec(Grunt.java:84)
at org.apache.pig.Main.run(Main.java:555)
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:601)
at org.apache.hadoop.util.RunJar.main(RunJar.java:156)

最佳答案

如果没有您的Pig脚本,这是一个猜测,但是您是否要在STORE语句中使用CSVLoader?

CSVLoader没有实现StoreFuncInterface,这是您要用于存储结果的任何内容所必需的。 CSVLoader用于LOAD语句。

您可能需要CSVExcelStorage,因为它确实实现了该接口(interface)。上一个链接也详细说明了用法:

STORE x INTO '<destFileName>'
USING CSVExcelStorage(['<delimiter>' [,{'YES_MULTILINE' | 'NO_MULTILINE'} [,{'UNIX' | 'WINDOWS' | 'UNCHANGED'}]]]);

关于hadoop - Pig-0.10.0:CSVLoader无法转换为org.apache.pig.StoreFuncInterface,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15132440/

10-10 22:37