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