Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Date format changed into bigint apache-nifi QueryDatabaseTableRecord

Date format changed into bigint apache-nifi QueryDatabaseTableRecord

Explorer

I have QueryDatabaseTableRecord to get data from Oracle table.

In my oracle table, I have following data

id,name,bday
1,sachith,17-SEP-1990
2,nalaka,16-MAR-2020

When I run and get data, its changed into bigint.


1,sachith,653523824000
2,nalaka,1584311083000

In Record Writer : CSV
: Date format : yyyy-mm-dd

But yet its not working. Do I have to use intermediate UpdateRecord processor and update date fields as [described here][1]?

Edit :

After doing some research, I could add `UpdateRecord` processor with


/my_date_colum : ${filed.value:format("yyyy-MM-dd HH:mm:ss.SSS")}

But this fails with negative epoch values.

> Error : Could not implicitly convert input to Date -104697000000

 

How can I handle this?

[1]: https://stackoverflow.com/questions/51675050/how-do-i-parse-a-date-field-and-generate-a-date-in-stri...

4 REPLIES 4
Highlighted

Re: Date format changed into bigint apache-nifi QueryDatabaseTableRecord

Explorer

Hi sachith, try using toDate() before format function. 
something like ${field.value:toDate(‘dd-MMM-yyyy’):format(‘dd-MMM-yyyy’)}

Highlighted

Re: Date format changed into bigint apache-nifi QueryDatabaseTableRecord

Explorer

Nope, this didnt solve the issue. But

${field.value:toDate():format('yyyy-MMM-dd')}

Can someone explain whats the difference between

toDate('yyyy-MMM-dd')

and just

toDate()
Highlighted

Re: Date format changed into bigint apache-nifi QueryDatabaseTableRecord

Explorer

You should do toDate(‘dd-MMM-yyyy’):format(‘yyyy-MMM-dd’)

 

you have to use toDate() with the input format To explicitly convert your date value to date type

 

 

Highlighted

Re: Date format changed into bigint apache-nifi QueryDatabaseTableRecord

Explorer

May be, but in my case, I have tried using

toDate('yyyy-MMM-dd')

but it failed.

Don't have an account?
Coming from Hortonworks? Activate your account here