The org.apache.cassandra.transport.DataType.fromType(AbstractType) method has a bug that prevents sending the correct Protocol ID for reversed DateType columns. This results in clients receiving Protocol ID 0, which maps to a CUSTOM type, for timestamp columns that are clustered in reverse order.
Some clients can handle this properly since they recognize the "org.apache.cassandra.db.marshal.DateType" marshaling type, however the native Datastax java-driver does not. It will produce errors like the one below when trying to prepare queries against such tables:
On the Cassandra side, there is a check for DateType columns that is supposed to convert these columns to TimestampType. However, the check is skipped when the column is also reversed. Specifically:
The else if should be changed to just an if, like so:
This bug is preventing us from upgrading our 1.2.11 cluster to 2.0.9 because our clients keep throwing exceptions trying to read or write data to tables with reversed timestamp columns. This issue can be reproduced by creating a CQL table in Cassandra 1.2.11 that clusters on a timestamp in reverse, then upgrading the node to 2.0.9. When querying the metadata for the table, the node will return Protocol ID 0 (CUSTOM) instead of Protocol ID 11 (TIMESTAMP).