Scala/Phantom ListColumn[Map[String,String]]

299 views Asked by At

I have a database column with the list<map<text, text>> type in Cassandra which I'm trying to read with ListColumn[Map[String,String]] in my CassandraTable class.

I get 2 compilation errors:

Error:(18, 25) could not find implicit value for evidence parameter of type com.websudos.phantom.builder.primitives.Primitive[Map[String,String]]
  object claims extends ListColumn[Map[String,String]](this)

Error:(18, 25) not enough arguments for constructor ListColumn: (implicit evidence$1: com.websudos.phantom.builder.primitives.Primitive[Map[String,String]])com.websudos.phantom.column.ListColumn[ConcreteUsers,User,Map[String,String]].
Unspecified value parameter evidence$1.
  object claims extends ListColumn[Map[String,String]](this)

I've tried using the JsonListColumn instead but that cannot convert the map<text, text> to a String for the toJson/fromJson overrides to work.

Is this conversion possible with Phantom and if so is there any documentation or an example showing this?

Many thanks,

Simon

1

There are 1 answers

0
flavian On

This is impossible in Cassandra itself, it is not a Phantom client side limitation. The usual way to address this is to use user defined types, which are natively supported in phantom-pro.

@Udt case class Address(
  postcode: String,
  address: String
)

@Udt case class Record(
  name: String
  items: List[Map[String, Address]]
)

This is just an example of nesting.