无法处理PIG中的时间序列数据

时间:2018-10-26 11:41:42

标签: hadoop apache-pig

我有时间序列数据,例如:2018-10-12 01:25:37并从时间戳中提取了日期(2018-10-12)和时间(1:25:37)。现在的要求是根据特定条件过滤时间值(例如:用另一个包含时间数据(hh:mm:ss)的袋子的原子过滤时间值)。对于时间(hh:mm:ss)类型的数据,PIG没有'TIME'数据类型。 在PIG中加载“时间”数据值需要什么数据类型?

1 个答案:

答案 0 :(得分:0)

提取日期(年,月,小时,分钟等)。使用了这些功能

年份: GetYear()

每月: GetMonth()

当天: GetDay()

一个小时: GetHour()

分钟: GetMinute()

date.txt
2018-10-12 11:15:43
2018-10-12 12:25:12
A = load 'date.txt' as (in:chararray);
B = foreach A generate ToDate(in,'yyyy-MM-dd HH:mm:ss') as (dt:DateTime);
C = foreach B {
      year = GetYear(dt);
      month = GetMonth(dt);
      day = GetDay(dt);
      hour = GetHour(dt);
      minute = GetMinute(dt);
    //finally you can concatenate year month and day or hour, time using CONCAT function
};
相关问题