我试图使用pig来过滤一个关系,它基于一周中的当前日期,使用三元条件,但它给了我一个错误,我还没有看到。
这就是我要做的:
C = filter B by (DaysBetween(CurrentTime(),ToDate(0L)) % 7) == (long)0 ? B.interval == 'daily' : B.interval == 'weekly';
返回的错误是:
ERROR 1200: Pig script failed to parse: NoViableAltException(84@[])
Failed to parse: Pig script failed to parse: NoViableAltException(84@[])
at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:196)
at org.apache.pig.PigServer$Graph.validateQuery(PigServer.java:1684)
at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1657)
at org.apache.pig.PigServer.registerQuery(PigServer.java:600)
at org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:1069)
at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:501)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:228)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:203)
at org.apache.pig.tools.grunt.Grunt.run(Grunt.java:66)
at org.apache.pig.Main.run(Main.java:542)
at org.apache.pig.Main.main(Main.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
Caused by: NoViableAltException(84@[])
at org.apache.pig.parser.AstValidator.expr(AstValidator.java:8637)
at org.apache.pig.parser.AstValidator.expr(AstValidator.java:9115)
at org.apache.pig.parser.AstValidator.bin_expr(AstValidator.java:10531)
at org.apache.pig.parser.AstValidator.projectable_expr(AstValidator.java:9790)
at org.apache.pig.parser.AstValidator.var_expr(AstValidator.java:9582)
at org.apache.pig.parser.AstValidator.expr(AstValidator.java:8985)
at org.apache.pig.parser.AstValidator.cond(AstValidator.java:7820)
at org.apache.pig.parser.AstValidator.filter_clause(AstValidator.java:7328)
at org.apache.pig.parser.AstValidator.op_clause(AstValidator.java:1683)
at org.apache.pig.parser.AstValidator.general_statement(AstValidator.java:1035)
at org.apache.pig.parser.AstValidator.statement(AstValidator.java:499)
at org.apache.pig.parser.AstValidator.query(AstValidator.java:373)
at org.apache.pig.parser.QueryParserDriver.validateAst(QueryParserDriver.java:255)
at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:183)
... 15 more
有人知道它为什么不起作用吗?我在mac上用的是0.11。
谢谢。
编辑:我试图不使用自定义项,并且在其他关系中使用了三元条件。
1条答案
按热度按时间3zwtqj6y1#
我想出来了。只是结构不好。
这是正确的方法: