Support Questions
Find answers, ask questions, and share your expertise

How can I insert a date in Cassandra from NiFi?



I have a Cassandra table where one of its fields is "register_date", which is a date type field. I'm facing several problems to insert this date in Cassandra from NiFi. I'm using UpdateAttribute processor to generate the field, with this content:


When the flow file arrives to PutCassandraRecord processor I get the following error: "Expected 4 byte long for date".

What am I doing wrong? Thanks for your help 🙂


Super Guru

You'll want to convert now() into a number for use by PutCassandraRecord, try ${now():toNumber()} instead.


Hi @Matt Burgess. Thanks for your response, but it is still failing :(. My three blocks are: UpdateAttribute, to give to register_date the value you have indicate, AttributestoJSON and, at last, PutCassandraRecord.

Am I doing anything wrong?

Thanks for your attention.

Super Guru

Once the value is in an attribute, it loses its type information as all attribute values are treated as strings. So when you use AttributesToJSON, you'll get a string value of the timestamp, not the long value.

Instead, try UpdateRecord, you can set/generate the field using a ReplacementValueStrategy of "Literal Value", where you can use NiFi Expression Language such as ${now():toNumber()}. Just make sure that the field is in the output schema as a long.


Hi @Matt Burgess, I have deleted the "AttributeToJSON" processor I indicated you and now PutCassandraRecord processor doesn't return any error, so this problem has disappeared. Without it, anyway, and setting only this structure:


In AttributesToJson I take the field register_date (which is null until that date), because this is the only field I want to put in the database. Then, with UpdateAttribute, I configure register_date as ${now():toNumber()} . At last, I use PutCassandraRecord. I'm obtaining in my database the following record: -294294420. What does this number mean? What if I want to obtain the date in a format of "yyyy-MM-dd", which is the format I was expecting to see?

However, I do not understand very well the solution you are proposing (English is not my first language so it will possibly has something to do with that). Which is the structure you are proposing me, and how could I configure the UpdateRecord Processor, to achieve the objective that I have proposed in the previous paragraph?

Many thanks for your help.



The error I'm obtaining now is "Expected 4 byte long for date (13)".

; ;