I'm trying to have a write a query such that
- insert a new row if primary key doesn't match a row
- if match a row, only update value if the provided timestamp is later than lastTimestamp column value
The struggle here (correct me if I'm wrong) is that I cannot use Cassandra's built-in "USE TIMESTAMP" functionality because the provided timestamp from the request is almost certainly lower than the default timestamp when creating a new row, therefore it won't be able to create a new row.
Therefore I can only create a new column to store the timestamp. Then I have a OR condition to fulfill: "if lastTimestamp == null OR lastTimestamp < timestamp", but unfortunately Cassandra doesn't support the "OR" logic in IF clause.
One alternative I can think of is, I'll always create a new row by have "INSERT IF NOT EXIST", and fill the lastTimestamp = 0. Then apply the "update if timestamp is greater" operation. But this essentially is two write than one. Any other possible solution?