1
votes

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).

I tried something along

date : ${csvfiledate:toDate("yyyyMMddHH","GMT"):format("yyyy-MM-dd HH-mmZ")} aswell, but the same error is occuring.

It seems like you need to have a specific timestamp type for cassandra as you can see here: http://docs.datastax.com/en/archived/cql/3.0/cql/cql_reference/timestamp_type_r.html But it isnt working so far, maybe you got some tipps.

Thanks in advance.

1
check this. I see that you have in format HH-mm and it must be HH:mm. Also try this: ${csvfiledate:toDate("yyyyMMddHH","GMT"):format("yyyy-MM-dd HH:mm")}Z - daggett

1 Answers

0
votes

You've got it backwards..

toDate parameters are used to describe how to parse the date. format function is used to describe how the date output should be. So the expression should be:

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