Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

bb.addagada_90355 avatar image
bb.addagada_90355 asked ·

Unexpected error during query org.apache.cassandra.serializers.MarshalException: Expected 8 or 0 byte long for date (4)

While Executing Prepared statements form application, we are observing the above-mentioned error from the driver.


DSE Version:- 5.1.5

DSE Java Driver :- 1.6.7

cassandrajava
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

@bb.addagada_90355 Based on the minimal information you provided, my guess is that your queries don't list the columns (use of wildcards) in this manner:

SELECT * FROM ... WHERE ...

If at some point the schema for the table changes, it no longer matches the schema of the cached prepared statement so the values being returned is not what the driver expected.

The best practice is to explicitly enumerate the columns you want to retrieve from the table so the application gets exactly the columns it expects. For example:

SELECT col1, col2, col3 FROM ... WHERE ...

This should prevent the prepared statements from getting out-of-sync with the schema. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.