sparkStruce消费kafak里的数据输出到mysql 出现的异常
Error:(31, 126) Unable to find encoder for type stored in a Dataset. Primitive types (Int, String, etc) and Product types (case classes) are supported by importing spark.implicits._ Support for serializing other types will be added in future releases.
val kafkaDatasString: Dataset[(String, String)] = kafkaDatas.selectExpr("CAST(key AS STRING)","CAST(value AS STRING)").as[(String,String)]
————————————————
解决措施
尽量把隐式转换往前些,因为下面的代码需要用到这个没有的方法
import spark.implicits._
报错
Error:(35, 10) Unable to find encoder for type stored in a Dataset. Primitive types (Int, String, etc) and Product types (case classes) are supported by importing spark.implicits._ Support for serializing other types will be added in future releases.
.as[(String,String)]
Error:(35, 10) not enough arguments for method as: (implicit evidence$2: org.apache.spark.sql.Encoder[(String, String)])org.apache.spark.sql.Dataset[(String, String)].
Unspecified value parameter evidence$2.
.as[(String,String)]