【发布时间】:2013-12-06 02:21:46
【问题描述】:
我编写了这个在 0.12.0 版本上完美运行的猪脚本,但我无法让它在 0.11.1 版本上运行 我无法确定真正缺少什么。
data = LOAD '<file_name>' USING PigStorage(',') AS
(Year,Month:int,DayofMonth,DayOfWeek,DepTime,CRSDepTime,ArrTime,CRSArrTime,UniqueCarrier,
FlightNum,TailNum,ActualElapsedTime,CRSElapsedTime,AirTime,ArrDelay:int,DepDelay,Origin,
Dest,Distance,TaxiIn,TaxiOut,Cancelled,CancellationCode,Diverted,CarrierDelay,
WeatherDelay,NASDelay,SecurityDelay,LateAircraftDelay);
A = FILTER data BY (ArrDelay > 0);
X = GROUP A BY (Dest, Year,
(
Case
when Month>2 AND Month<6 THEN 'SPRING'
when Month>5 AND Month<9 THEN 'SUMMER'
when Month>8 AND Month<12 THEN 'FALL'
when Month==12 OR (Month<3 AND Month>0) THEN 'WINTER'
END
)
);
Y = FOREACH X GENERATE group.Dest, group.Year, group.$2, SUM(A.ArrDelay);
STORE Y INTO 'myoutput';
这是运行脚本时给出的异常。
Pig Stack Trace
---------------
ERROR 1200: <file DelayBySeasonPerYear.pig, line 7, column 16> Syntax error, unexpected symbol at or near 'Dest'
org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1000: Error during parsing. <file DelayBySeasonPerYear.pig, line 7, column 16> Syntax error, unexpected symbol at or near 'Dest'
at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1607)
at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1546)
at org.apache.pig.PigServer.registerQuery(PigServer.java:516)
at org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:991)
at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:412)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:194)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:170)
at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:84)
at org.apache.pig.Main.run(Main.java:604)
at org.apache.pig.Main.main(Main.java:157)
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:606)
at org.apache.hadoop.util.RunJar.main(RunJar.java:160)
Caused by: Failed to parse: <file DelayBySeasonPerYear.pig, line 7, column 16> Syntax error, unexpected symbol at or near 'Dest'
at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:235)
at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:177)
at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1599)
... 14 more
【问题讨论】:
-
提示,
Y可以只是Y = FOREACH X GENERATE FLATTEN(group), SUM(A.ArrDelay);。当您在元组上使用FLATTEN时,它与单独生成每个元素的作用相同(就像您所做的那样)。
标签: java hadoop mapreduce apache-pig