我写了一个脚本来从 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?
。什么是问题?
我写了一个脚本来从 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?
。什么是问题?
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 版本,您需要使用适当的函数处理时间戳。就像是:
问题似乎是多次使用单引号。在一行中似乎可以编译(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}';