Compile Error

No Type Tag available for

    import sqlContext.createSchemaRDD

    case class Person(name: String, age: Int)

    // Create an RDD of Person objects and register it as a table.
    val people = sc.textFile("src/main/resources/people.txt").map(_.split(",")).map(p => Person(p(0), p(1).trim.toInt))
    people.registerTempTable("people")
[INFO] Compiling 4 source files to /opt/Learning/Spark/target/classes at 1458108623154
[ERROR] /opt/Learning/Spark/src/main/scala/hxm/spark/learning/People.scala:26: error: No TypeTag available for Person
[ERROR]     people.registerTempTable("people")
[ERROR]     ^
[ERROR] one error found

26行错误就是 people.registerTempTable处,这里有一个隐式转换,需要用到people的typetag,这时候似乎是还没有生成people的typetag

参见Overflow

case class移出main方法,编译通过

results matching ""

    No results matching ""