我需要在其中一列中保存包含org.apache.spark.mllib.linalg.Vector的数据帧。在数据框架中使用cassandra创建表时,会抛出错误。
java.lang.Exception: Cassandra Writer Failed. java.lang.IllegalArgumentException: Unsupported type: org.apache.spark.mllib.linalg.VectorUDT@f71b0bce
at com.datastax.spark.connector.types.ColumnType$.unsupportedType$1(ColumnType.scala:132)
at com.datastax.spark.connector.types.ColumnType$.fromSparkSqlType(ColumnType.scala:155)
at com.datastax.spark.connector.mapper.DataFrameColumnMapper$$anonfun$1.apply(DataFrameColumnMapper.scala:18)
at com.datastax.spark.connector.mapper.DataFrameColumnMapper$$anonfun$1.apply(DataFrameColumnMapper.scala:16)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at com.datastax.spark.connector.mapper.DataFrameColumnMapper.newTable(DataFrameColumnMapper.scala:16)
at com.datastax.spark.connector.cql.TableDef$.fromDataFrame(Schema.scala:206)
答案 0 :(得分:3)
如果要保存此类型的二进制值,则只需将其转换为Byte数组,然后将其保存到blob列。
如果您想将其另存为一组值,则需要对Scala集合进行适当的转换。