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()
百闻不如一见,百见不如一做,只有做了,才知道问题出现在哪儿,才能去解决问题。