score:1

Accepted answer

the most suspicious line is

val reply_time_it = reply_id.all().get(0).getstring("created_at")

since any non-key field could be absent in the cassandra record, it's very likely to be null sometimes. you can wrap it in option like

val reply_time_it = option( reply_id.all().get(0).getstring("created_at"))

then you can use methods like getorelse to get value with default, foreach to execute side-effecting method if value is present, and map to make new values based on that.

also you should probably:

  • create one session for each partition using mappartions or mappartitionswithindex
  • create preparedstatement for each query \ partition for performance reasons

Related Query

More Query from same tag