Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Unable to coerce 'yyyy-MM-dd HH' to a formatted date (long) in cassandra with Apache Nifi

avatar
Contributor

Hey,

I m having some issues with converting a regular timestamp in cassandra with Apache Nifi.

My use case is following:

I have a csv file with a date in it looking like this ('2015010109') and I want to put it in cassandra by converting this string ('2015010109') to an proper format: 2015-01-01 09:00 -> yyyy/MM/dd HH:mm (I dont exactly need the minutes, but I guess it is more useful for later usage)

So far I got this propertie in my UpdateAttribute processor when trying to convert this string to a timestamp:

date : ${csvfiledate:toDate("yyyyMMddHH","GMT"):format("yyyy-MM-dd-HH")}

but then there is an error occuring in my PutCassandraQL processor: Unable to coerce '2015-01-01-09' to a formatted date (long).

By now I didnt try to set the minutes (always mm = 00), because I dont have them in my string out of the csv-file yet. But I guess I need them, because of the certain set of string date formats which can only be coerced: http://docs.datastax.com/en/archived/cql/3.0/cql/cql_reference/timestamp_type_r.html

I didnt manage to do it though, maybe you got some tipps.

Thanks in advance.

2 REPLIES 2

avatar
Master Guru

According to that documentation you linked to, your date has to be in one of the formats they listed. You formatted it with -HH at the end, but none of them have that. The closest one looks like

yyyy-mm-dd HH:mm

So ${csvfiledate:toDate("yyyyMMddHH","GMT"):format("yyyy-MM-dd HH:mm")} would probably work.

avatar
Contributor

Unfortunately the same error is occuring. I tried some more of those formats, but it seems like they have all the same issue.