期待猪脚本中的QUOTED STRING

时间:2013-09-02 10:17:44

标签: hadoop apache-pig

我编写了一个从vsql中选择的脚本:

LOAD 'sql://{select * from sandesh.insights_voice_day
    WHERE Observation_date BETWEEN '2011-11-22' AND '2011-11-23' AND
    Type='total'
    ORDER BY  Observation_date}'

它显示异常为'' Expecting QUOTEDSTRING?。什么问题?

2 个答案:

答案 0 :(得分:1)

Pig期望加载后带引号的字符串包含您要加载的文件的名称。 Pig不是SQL,所以你必须先做一些事情,比如先将你的查询转储到一个文件中,然后:

A = LOAD "your_file" as (column1:datatype, column2:datatype);
B = FITER A by observation date > '2011-11-22' AND observation_date < '2011-11-23' AND
    Type='total';
C = ORDER B by observation_date;
DUMP C;

现在,这会将这些命令为字符串。因此,根据您使用的Pig版本,您需要使用适当的函数处理时间戳。类似的东西:

http://pig.apache.org/docs/r0.8.1/api/org/apache/pig/piggybank/evaluation/datetime/convert/CustomFormatToISO.html

答案 1 :(得分:0)

问题似乎是多次使用单引号。在单行中似乎编译(pig -c test.pig)

A = LOAD 'sql://{select * from sandesh.insights_voice_day WHERE Observation_date BETWEEN "2011-11-22" AND "2011-11-23" AND Type="total" ORDER BY  Observation_date}';