phantom
phantom copied to clipboard
Missing static values
We want to use Cassandra to cache Exchange calendars, so they are available when Exchange is not. The following cql defines a table for storing the results of an availability request. The static last_update column keeps track of the last time our application wrote to the partition, if any.
CREATE TABLE IF NOT EXISTS slots_by_account_and_day
(
account text,
day text,
ews_id text,
start_time timestamp,
end_time timestamp,
status text,
last_update timestamp STATIC,
PRIMARY KEY ((account, day), ews_id)
)
After filling the table with testdata, I noticed that PhantomDSL gives me None when I expected Some, using the following code:
table
.select(_.last_update)
.where(_.account eqs account)
.and(_.day eqs day)
.one
Meanwhile, the following Datastax based solution does give me what I expect using the following code:
session
.execute(QueryBuilder.select("last_update")
.from(table.tableName)
.where(QueryBuilder.eq("account", account))
.and(QueryBuilder.eq("day", day)))
.one()
.getTimestamp("last_update")
This looks like a bug. I assume it is related to the way PhantomDSL handles static columns, because this is the first time I have tried to use this feature of Cassandra.
Hi @woupiestek We'll take a look as soon as possible, thank you for the bug report!
Hi @woupiestek What does your phantom table look like? I don't think this is due to static handling, I think this might be a parse error in the datatype that decodes your timestamp. But I want to be sure, so if you could paste that here that would be helpful.
@alexflav23 last_update is a DateTimeColumn, like the other timestamp columns start_time and end_time.
object account extends StringColumn with PartitionKey
object day extends StringColumn with PartitionKey
object ews_id extends StringColumn with PrimaryKey
object start_time extends DateTimeColumn
object end_time extends DateTimeColumn
object status extends StringColumn
/*
* Added to track the last update for each partition
*/
object last_update extends DateTimeColumn with StaticColumn