首先,我运行了这段代码,然后就完成了。现在,我想从时间戳中提取日期,其中包括数据和时间。但是,我不知道该怎么做。我使用了GetYear
,GetMonth
,GetDay
,但总是弹出错误。
define Quantile datafu.pig.stats.Quantile('21'); data_raw = LOAD 'California/2016/March-2016.csv' USING PigStorage(',') AS (tmc_code:chararray, measurement_tstamp:chararray, speed:int, average_speed:int, reference_speed:int, travel_time_minutes:int,confidence_score:int, cvalue:int);
filtered_data = FILTER data_raw BY confidence_score == 30;
data_reqd = GROUP filtered_data BY (tmc_code, measurement_tstamp);
quantiles = FOREACH data_reqd GENERATE group.tmc_code, ToDate(group.measurement_tstamp,'YYYY-MM-DD HH:mm:ss') AS date, Quantile(filtered_data.speed);
results = Limit quantiles 10;
DUMP results;
如果有人可以帮助我从measurement_tstamp
中提取日期,我将不胜感激。
答案 0 :(得分:0)
你可以这样做
results_new = FOREACH quantiles GENERATE CONCAT(CONCAT(CONCAT((chararray)GetYear(date),'-')),(CONCAT((chararray)GetMonth(date),'-')),(chararray)GetDay(date)) AS Day;
我已经回答了类似的问题here