语法错误,“FLATTEN”处或附近出现意外符号
Posted
技术标签:
【中文标题】语法错误,“FLATTEN”处或附近出现意外符号【英文标题】:Syntax error, unexpected symbol at or near 'FLATTEN' 【发布时间】:2016-04-21 05:23:05 【问题描述】:当我尝试这个时,它起作用了:
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
================================================================================
请告诉我哪里弄错了。
【问题讨论】:
【参考方案1】:您不能在嵌套的 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));
【讨论】:
任何参考文件指定这个?请发帖。以上是关于语法错误,“FLATTEN”处或附近出现意外符号的主要内容,如果未能解决你的问题,请参考以下文章
Postgresql: 在 ""ViewShifts"" 处或附近出现语法错误 为啥我在下面的查询中会出现此错误?
在“PARALLEL”处或附近创建 postgis 扩展语法错误
获取 PSQLException:错误:在带有 Postgres 的 spark jdbc 中使用查询而不是表名时在“SELECT”处或附近出现语法错误
带有 dapper 和 postgresql 的“WHERE x IN y”子句抛出 42601:在 \"$1\" 处或附近出现语法错误