当我尝试这样做时,它起作用了:
B = FOREACH A {
X = STRSPLIT(agegroup,'-',0);
}
输出:
((20,30))
((20+))
((20,40))
and so on...
现在,我像这样尝试了
FLATTEN
:B = FOREACH A {
X = FLATTEN(STRSPLIT(agegroup,'-',0));
}
我得到以下错误:
Pig Stack Trace
---------------
ERROR 1200: <file PigScript.pig, line 3, column 5> Syntax error, unexpected symbol at or near 'FLATTEN'
org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1000: Error during parsing. <file PigScript.pig, line 3, column 5> Syntax error, unexpected symbol at or near 'FLATTEN'
at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1701)
at org.apache.pig.PigServer$Graph.access$000(PigServer.java:1421)
at org.apache.pig.PigServer.parseAndBuild(PigServer.java:354)
at org.apache.pig.PigServer.executeBatch(PigServer.java:379)
at org.apache.pig.PigServer.executeBatch(PigServer.java:365)
at org.apache.pig.tools.grunt.GruntParser.executeBatch(GruntParser.java:140)
at org.apache.pig.tools.grunt.GruntParser.processDump(GruntParser.java:769)
at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:372)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:198)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:173)
at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:84)
at org.apache.pig.Main.run(Main.java:613)
at org.apache.pig.Main.main(Main.java:158)
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.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: Failed to parse: <file PigScript.pig, line 3, column 5> Syntax error, unexpected symbol at or near 'FLATTEN'
at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:241)
at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:179)
at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1688)
... 18 more
================================================================================
请让我知道我错了。
最佳答案
您不能在嵌套的FOREACH块中使用FLATTEN,在嵌套的FOREACH块中仅允许使用CROSS,DISTINCT,FILTER,FOREACH,LIMIT和ORDER BY。
更改
B = FOREACH A {
X = FLATTEN(STRSPLIT(agegroup,'-',0));
}
至
B = FOREACH A GENERATE FLATTEN(STRSPLIT(agegroup,'-',0));
关于hadoop - 语法错误,在 'FLATTEN'或附近出现意外符号,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36760331/