0
votes

Ever since we upgraded to Scala 2.13 queries that access the Date column in Cassandra fail with an exception: Unable to make unsigned int (for date) from: '1601856000000'

This value is obviously too big to fit in an unsigned int. And according to the Cassandra documentation, date is stored as an unsigned int representing days-since-epoch

But when I look into the phantom-dsl DateSerializer code I see it deliberately taking the millisSinceEpoch value from all the supported Date types, which is the value in the exception

Column: object date extends DateColumn with ClusteringOrder with Descending

Query/method:

    select
      .where(_.userId eqs userId)
      .and(_.date gte startDate)
      .fetch()(implicitly, executionContext)

Phantom-dsl version 2.59.0

Already tried to use LocalDate (same issue) and representing the column as StringColumn, which works for the query if I format the date to YYYY-MM-dd, but then the value from the resultset cannot be parsed into a Date

What am I missing here?

1
FYI, startDate is a java.util.Date object - Frank
According to phantom docs you should stick to java.util.Date. Either you were using DateTime or phantom for some reason is picking wrong implicit conversion. If you are providing own converters, then maybe you accidentally provided something that overrode the default one? - michaJlS
I use java.util.Date and have no own converters. The converters in phantom-dsl seem to use millis, so I would actually consider a custom converter, but that should not be necessary - Frank
According to the phantom documentation DateColumn is mapped to timestamp, same as DateTimeColumn outworkers.github.io/phantom/basics/primitives.html so the behaviour you're describing seems to be correct, but then why it worked before the upgrade. Maybe authors of phantom will explain what's going on github.com/outworkers/phantom/issues . There are some date handling changes listed in the changelog - michaJlS

1 Answers

0
votes

After a while a colleague came up with a solution: if you define the column as com.datastax.driver.core.LocalDate it does work