【发布时间】:2017-09-06 21:29:18
【问题描述】:
我正在从一个文本文件创建一个 Spark DataFrame。假设包含 String、Int、Char 的 Employee 文件。
创建了一个类:
case class Emp (
Name: String,
eid: Int,
Age: Int,
Sex: Char,
Sal: Int,
City: String)
使用 split 创建 RDD1,然后创建 RDD2:
val textFileRDD2 = textFileRDD1.map(attributes => Emp(
attributes(0),
attributes(1).toInt,
attributes(2).toInt,
attributes(3).charAt(0),
attributes(4).toInt,
attributes(5)))
最终 RDDS 为:
finalRDD = textFileRDD2.toDF
当我创建最终的 RDD 时,它会抛出错误:
java.lang.UnsupportedOperationException: No Encoder found for scala.Char"
谁能帮我解释一下为什么以及如何解决它?
【问题讨论】:
标签: scala apache-spark apache-spark-sql