Horje
org.apache.spark.sql.avro.IncompatibleSchemaException: Unexpected type org.apache.spark.ml.linalg.VectorUDT Code Example
org.apache.spark.sql.avro.IncompatibleSchemaException: Unexpected type org.apache.spark.ml.linalg.VectorUDT
# To convert any Vector to an Array[Double] you can use the following UDF:

import org.apache.spark.sql.functions.udf
import org.apache.spark.sql.functions.col
import org.apache.spark.ml.linalg.Vector

val vectorToArrayUdf = udf((vector: Vector) => vector.toArray)

// The following will work
val output = dataPredictions
    .withColumn("probabilities", vectorToArrayUdf(col("probability")))
    .select("id", "probabilities", "prediction")

output.write.format("com.databricks.spark.avro").save(path)




Sql

Related
list table columns mysql Code Example list table columns mysql Code Example
sql date and time Code Example sql date and time Code Example
User has exceeded the 'max_questions' resource (current value: 75000) Code Example User has exceeded the 'max_questions' resource (current value: 75000) Code Example
devilbox mysqldump Code Example devilbox mysqldump Code Example
mysql workbench view Code Example mysql workbench view Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6