首页 > Web开发 > 详细

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

时间:2020-04-03 16:02:35      阅读:146      评论:0      收藏:0      [点我收藏+]

错误:

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

   

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

原文:https://www.cnblogs.com/shuai7boy/p/12625658.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!