apache pig错误-无法跟踪

nhn9ugyo  于 2021-06-02  发布在  Hadoop
关注(0)|答案(1)|浏览(338)

当我尝试在pig查询下面运行时,使用sort命令时出现错误。如果省略排序转换,则可以执行查询。

grunt> month1 = LOAD 'hdfs://localhost.localdomain:8020/user/cloudera/data/big1/climate_month1.txt' USING PigStorage(',');

grunt> month2 = LOAD 'hdfs://localhost.localdomain:8020/user/cloudera/data/big1/climate_month2.txt' USING PigStorage(',');

grunt> month3 = LOAD 'hdfs://localhost.localdomain:8020/user/cloudera/data/big1/climate_month3.txt' USING PigStorage(',');

grunt> month4 = LOAD 'hdfs://localhost.localdomain:8020/user/cloudera/data/big1/climate_month4.txt' USING PigStorage(',');

grunt> month5 = LOAD 'hdfs://localhost.localdomain:8020/user/cloudera/data/big1/climate_month5.txt' USING PigStorage(',');

grunt> months = UNION month1, month2, month3, month4, month5;

grunt> clearWeather = FILTER months BY skyCondition == 'CLR';

grunt> shapedWeather = FOREACH clearWeather GENERATE date, SUBSTRING(date,0,4) as YEAR, SUBSTRING(date,4,6) as MONTH, SUBSTRING(date,6,8) as DAY, skyCondition, dryTemp;

grunt> groupedByMonthDay = GROUP shapedWeather BY (MONTH, DAY) PARALLEL 10;

grunt> aggedResults = FOREACH groupedByMonthDay GENERATE group as MonthDay, AVG(shapedWeather.dryTemp) AS AVERAGETEMP, MIN(shapedWeather.dryTemp) AS MINIMUMTEMP, MAX(shapedWeather.dryTemp) AS MAXIMUMTEMP, COUNT(shapedWeather.dryTemp) AS COUNTTEMP PARALLEL 10;

grunt> sortedResult = SORT aggedResults BY $1 DESC;

2014-10-31 10:22:44,664 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <line 11, column 0>  Syntax error, unexpected symbol at or near 'sortedResult'
Details at logfile: /home/cloudera/pig_1414775884282.log

错误文件显示:/home/cloudera/pig_.log有人能给我解决这个问题的方法吗。

Pig Stack Trace
    ---------------
    ERROR 1200: <line 11, column 0>  Syntax error, unexpected symbol at or near 'sortedResult'

    Failed to parse: <line 11, column 0>  Syntax error, unexpected symbol at or near 'sortedResult'
        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.validateQuery(PigServer.java:1572)
        at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1545)
        at org.apache.pig.PigServer.registerQuery(PigServer.java:518)
        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.run(Grunt.java:69)
        at org.apache.pig.Main.run(Main.java:538)
        at org.apache.pig.Main.main(Main.java:157)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:208)
py49o6xq

py49o6xq1#

pig中没有排序命令。try order命令

sortedResult = ORDER aggedResults BY $1 DESC;

相关问题