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.

Nifi - Unable to dump the changed date format column to Cassandra (putcassandrarecord) - InvalidQueryException : Expected 4 byte long for date(10)

Nifi - Unable to dump the changed date format column to Cassandra (putcassandrarecord) - InvalidQueryException : Expected 4 byte long for date(10)

Explorer

Hi,

I have an usecase to dump the data from csv to cassandra.

My source CSV data has one date column which is in the format "d-MMM-yy".

eg (Sample input date):

date,destination_name,destination,maximum,minimum

1-Dec-15,Albuquerque,120,48,24

 

I tried changing the date format to "yyyy-MM-dd" using CSVReader (Record Reader) and CSVWriter (Record Writer) inside updateattribute processor (along with other column data manipulation activity)

 

CSV Reader properties:

screenshot-1.PNG

 

Avro Schema defined inside CSVReader:

screenshot-2.PNG

CSV Writer properties:

screenshot-3.PNG

 

 

Avro Schema defined inside CSVWriter:

screenshot-2.PNG

 

Output of CSVWriter:

date,destination_name,destination,maximum,minimum
2015-12-01,ALBUQUERQUE,120,48,24

 

At the final step I have PutCassandraRecord processor, where I defined CSVReader (as Record Reader) with schemaText property as below.

screenshot-2.PNG

 

But while executing flow, this putcassandrarecord routes to Failure state due to below error.

 

screenshot-4.PNG

 

Cassandra table structure:

CREATE TABLE date_dump.forecast (
destination_name text,date date,destination int,maximum int,minimum int,
PRIMARY KEY (destination_name, date)
)

Could anyone help here to fix this issue, to dump the date column into cassandra table.

 

 

1 REPLY 1
Highlighted

Re: Nifi - Unable to dump the changed date format column to Cassandra (putcassandrarecord) - InvalidQueryException : Expected 4 byte long for date(10)

Expert Contributor

At a glance, the SQL command requires a different input than you give it.

Either a numeric representation (e.g. Unixtimestamp) or a specific string format. Based on the error the first one would be my guess.

 

Here is an example of the ToDate function that might help: https://community.cloudera.com/t5/Support-Questions/How-to-convert-string-to-date-in-NiFi/td-p/19134...

 

The key thing to keep in mind: Just because you have text that looks like a date to human eyes, does not mean this will be understood.


If this answer helped, please mark it as 'solved' and/or if it is valuable for future readers please apply 'kudos'.
Don't have an account?
Coming from Hortonworks? Activate your account here