0

I have one date chararray 2014-11-02 16:57:29. i want to convert this into long how can i do this?

I tried from the link https://pig.apache.org/docs/r0.14.0/api/org/apache/pig/piggybank/evaluation/datetime/convert/ISOToUnix.html

DEFINE ISOToUnix org.apache.pig.piggybank.evaluation.datetime.convert.ISOToUnix();

DEFINE CustomFormatToISO org.apache.pig.piggybank.evaluation.datetime.convert.CustomFormatToISO();

ISOin = LOAD '/user/sample/test.csv' USING PigStorage() AS (dt:chararray, dt2:chararray);

toUnix = FOREACH ISOin GENERATE ISOToUnix(CustomFormatToISO(dt, 'YYYY-MM-DD HH:MM:SS')) AS event_time;

DUMP toUnix;

test.csv contains 2014-11-02 16:57:29 2014-11-02 13:13:05

I am getting

[POUserFunc (Name: POUserFunc(org.apache.pig.piggybank.evaluation.datetime.convert.ISOToUnix)[long] - scope-5 Operator Key: scope-5) children: null at []]: java.lang.NullPointerException.

Could somebody please help me out. Thanks

ArK
  • 20,698
  • 67
  • 109
  • 136
Sam
  • 1,333
  • 5
  • 23
  • 36

1 Answers1

0

ISOToUnix(CONCAT(REPLACE(dt, ' ', 'T'), '.000Z')) looks a good an quick answer. here we convert the string to iso then using ISOToUnix using valid timezone

Sam
  • 1,333
  • 5
  • 23
  • 36