Error:(30, 15) Unable to find encoder for type String

错误:

Error:(30, 15) Unable to find encoder for type String. An implicit Encoder[String] is needed to store String instances 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.
select.map(attributes => "Name: " + attributes(0)).show()

Error:(30, 15) not enough arguments for method map: (implicit evidence$6: org.apache.spark.sql.Encoder[String])org.apache.spark.sql.Dataset[String].
Unspecified value parameter evidence$6.
select.map(attributes => "Name: " + attributes(0)).show()

报错前代码:

select.map(attributes => "Name: " + attributes(0)).show()

解决方案:

implicit val encoder=org.apache.spark.sql.Encoders.STRING//添加字符串类型编码器

select.map(attributes => "Name: " + attributes(0)).show()

   

猜你喜欢

转载自www.cnblogs.com/shuai7boy/p/12625658.html
今日推荐