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()

   


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM