我需要保存包含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)
如果您想保存这种类型的二进制值,您只需要将其转换为字节数组,然后将其保存到blob列。
如果您想将其保存为一组值,则需要将其转换为Scala集合。