- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
程序员你好吗?
我正在编程并运行pig命令,在代码中返回了语法错误,无法解决。
下面,我将发布代码和引发的错误。
显然该错误发生在sortedResults的第41行的语法中
码:
--Load files into relations
month1 = LOAD 'hdfs:/data/big/data/weather/201201hourly.txt' USING PigStorage(',');
month2 = LOAD 'hdfs:/data/big/data/weather/201202hourly.txt' USING PigStorage(',');
month3 = LOAD 'hdfs:/data/big/data/weather/201203hourly.txt' USING PigStorage(',');
month4 = LOAD 'hdfs:/data/big/data/weather/201204hourly.txt' USING PigStorage(',');
month5 = LOAD 'hdfs:/data/big/data/weather/201205hourly.txt' USING PigStorage(',');
month6 = LOAD 'hdfs:/data/big/data/weather/201206hourly.txt' USING PigStorage(',');
--Combine relations
months = UNION month1, month2, month3, month4, month5, month6;
/* Splitting relations
SPLIT months INTO
splitMonth1 IF SUBSTRING(date, 4, 6) == '01',
splitMonth2 IF SUBSTRING(date, 4, 6) == '02',
splitMonth3 IF SUBSTRING(date, 4, 6) == '03',
splitRest IF (SUBSTRING(date, 4, 6) == '04' OR SUBSTRING(date, 4, 6) == '04');
*/
/* Joining relations
stations = LOAD 'hdfs:/data/big/data/QCLCD201211/stations.txt' USING PigStorage() AS (id:int, name:chararray)
JOIN months BY wban, stations by id;
*/
--filter out unwanted data
clearWeather = FILTER months BY SkyCondition == 'CLR';
--Transform and shape relation
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;
--Group relation specifying number of reducers
groupedMonthDay = GROUP shapedWeather BY (month, day) PARALLEL 10;
--Aggregate relation
aggedResults = FOREACH groupedByMonthDay GENERATE group as MonthDay, AVG(shapedWeather.dryTemp), MIN(shapedWeather.dryTemp), MAX(shapedWeather.dryTemp), COUNT(shapedWeather.dryTemp) PARALLEL 10;
--Sort relation
sortedResults = SORT aggedResults BY $1 DESC;
--Store results in HDFS
STORE sortedResults INTO 'hdfs:/data/big/data/weather/pigresults' USING PigStorage(':');
14/10/20 22:30:47 WARN pig.Main: Cannot write to log file: //pig_1413851447162.log
2014-10-20 22:30:47,165 [main] INFO org.apache.pig.Main - Apache Pig version 0.12.1 (r1585011) compiled Apr 05 2014, 01:41:34
2014-10-20 22:30:47,486 [main] INFO org.apache.pig.impl.util.Utils - Default bootup file /home/eduardo/.pigbootup not found
2014-10-20 22:30:47,510 [main] WARN org.apache.pig.Main - Cannot write to log file: ///weather.pig1413851447510.log
2014-10-20 22:30:47,629 [main] INFO org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at: hdfs://localhost:54310
2014-10-20 22:30:47,770 [main] INFO org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to map-reduce job tracker at: localhost:54311
2014-10-20 22:30:48,005 [main] ERROR org.apache.pig.PigServer - exception during parsing: Error during parsing. <file home/eduardo/Documentos/pig/weather.pig, line 41, column 0> Syntax error, unexpected symbol at or near 'sortedResults'
Failed to parse: <file home/eduardo/Documentos/pig/weather.pig, line 41, column 0> Syntax error, unexpected symbol at or near 'sortedResults'
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:1678)
at org.apache.pig.PigServer$Graph.access$000(PigServer.java:1411)
at org.apache.pig.PigServer.parseAndBuild(PigServer.java:344)
at org.apache.pig.PigServer.executeBatch(PigServer.java:369)
at org.apache.pig.PigServer.executeBatch(PigServer.java:355)
at org.apache.pig.tools.grunt.GruntParser.executeBatch(GruntParser.java:140)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:202)
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:607)
at org.apache.pig.Main.main(Main.java:156)
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)
2014-10-20 22:30:48,008 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <file home/eduardo/Documentos/pig/weather.pig, line 41, column 0> Syntax error, unexpected symbol at or near 'sortedResults'
2014-10-20 22:30:48,008 [main] WARN org.apache.pig.tools.grunt.Grunt - There is no log file to write to.
2014-10-20 22:30:48,008 [main] ERROR org.apache.pig.tools.grunt.Grunt - org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1000: Error during parsing. <file home/eduardo/Documentos/pig/weather.pig, line 41, column 0> Syntax error, unexpected symbol at or near 'sortedResults'
at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1691)
at org.apache.pig.PigServer$Graph.access$000(PigServer.java:1411)
at org.apache.pig.PigServer.parseAndBuild(PigServer.java:344)
at org.apache.pig.PigServer.executeBatch(PigServer.java:369)
at org.apache.pig.PigServer.executeBatch(PigServer.java:355)
at org.apache.pig.tools.grunt.GruntParser.executeBatch(GruntParser.java:140)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:202)
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:607)
at org.apache.pig.Main.main(Main.java:156)
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 home/eduardo/Documentos/pig/weather.pig, line 41, column 0> Syntax error, unexpected symbol at or near 'sortedResults'
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:1678)
... 15 more
最佳答案
Pig没有SORT命令。您必须尝试使用“ORDER”命令。这样尝试
sortedResults = ORDER aggedResults BY $1 DESC;
关于hadoop - 使用SORT时Apache Pig拉丁语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26477207/
我正在尝试扩展 Codecademy pig 拉丁语转换器,以便它接受句子而不仅仅是单个单词,并转换句子中的每个单词。这是我的代码: pyg = 'ay' pyg_input = raw_input(
我正在处理一些包含日期的拉丁文本,并使用各种正则表达式模式和基于规则的语句来提取日期。我想知道我是否可以使用一种算法来训练来提取这些日期,而不是我目前使用的方法。谢谢 这是我的算法的摘录: def c
我有如下输入数据: Row1|2014-04-04 18:46:18|37.52|-84.34|30870|580.372 ms, 759.065 ms, 695.879 ms Row2|2014-0
所以基本上我对这个问题的问题是我不允许使用 Stringbuilder、数组或 String.split() 来创建这个程序。我完全难以做到这一点,因为如果我能用这些方法来解决这个程序,我就不会在这里
我已将问题分解为几个步骤来翻译成 pig 拉丁语 1.循环定位数组中的空间 - if now(arr) is not space and not null then keep searching(+1
我正在尝试将以辅音开头的用户输入的字符串转换为“ pig 拉丁语”,将所有辅音移动到单词的末尾,直到单词以元音开头,然后在单词的末尾添加“ay” 。我有一个 for 循环应该执行此操作,但由于某种原因
我正在尝试将句子转换为 pig latin,但无法正常工作。 条件:1. 如果它以元音开头,在单词后面加上 way(例如 eagle become eagleway)2.如果是辅音开头的,就查第二个字
我想将塞尔维亚拉丁语、塞尔维亚语添加到我的 Android 应用程序中。但是我无法弄清楚值文件夹的名称应该是什么。我尝试了 values-sr-rRS-Latn 但 Android studio 给出
我有一个日志文件,其中包含来自多个域的日志。现在我想对它们进行一些分析并将输出存储在一个名为域的目录中。我在日志中将域作为字段值: STORE outputlogs INTO 'testpath/DO
我从一段时间以来一直在使用 PIG,想知道如何在加载文件时不考虑第一行。我有一个包含标题的文件。所以我应该忽略第一行并转到下一行对日期列和所有列进行处理。如何解决这个问题? 谢谢 最佳答案 如果你有
我有以下输入记录: 0029029070999991901010106004 + 64333 + 023450FM-12 + 000599999V0202701N015919999999N000000
我使用 PhoneGap 开发应用程序。我使用 Ripple 在浏览器中测试我开发的应用程序,然后在真实设备中测试我的应用程序。 我有很多包含拉丁字符的行,例如 Ñ、Ü 等,当我进行不包含这些字符的查
我有以下场景- pig 版使用0.70 示例 HDFS 目录结构: /user/training/test/20100810/ /user/training/test/20100811/ /user/
我是一名优秀的程序员,十分优秀!