0
votes
REPLACE(ToDate('$current__ts', 'yyyy-MM-dd HH:mm:ss'),'-','') as new_DT,

I am trying to convert the current_ts or timestamp passed with removal of - between YYYY-mm-dd so the output should be yyyyMMdd HH:mm:ss

but i get the error: Could not infer the matching function for org.apache.pig.builtin.REPLACE as multiple or none of them fit. Please use an explicit cast.

I also tried the below same error

REPLACE((datetime)ToDate('$current__ts', 'yyyy-MM-dd HH:mm:ss'),'-','') as new_DT,
1
please add few lines of input data ! try REPLACE(ToDate($current__ts, 'yyyy-MM-dd HH:mm:ss'),'-','') - San

1 Answers

1
votes

ToDate returns a datetime object.REPLACE works on a string. You have to cast the datetime object from the ToDate to a chararray and then use it in the REPLACE function.See ToString

REPLACE(ToString(ToDate('$current__ts', 'yyyy-MM-dd HH:mm:ss')),'-','') as new_DT,