Support Questions
Find answers, ask questions, and share your expertise

Error in Apache Spark running Scala:

Explorer

scala> case class rowschema(id:Int, record:String) {
| val df = sqlContext.createDataFrame(Seq(rowschema(1,"record1"), rowschema(2,"record2"), rowschema(3,"record3"))) {
| df.registerTempTable("tempTable")
| }
| }
<console>:17: error: recursive value df needs type
df.registerTempTable("tempTable")
^
<console>:17: error: type mismatch;
found : Unit
required: reflect.runtime.universe.TypeTag[rowschema]
df.registerTempTable("tempTable")

1 REPLY 1

Re: Error in Apache Spark running Scala:

Contributor

@RICHARD Hagedorn

you are correct except few '{'

case class rowschema(id:Int, record:String)

val df = sqlContext.createDataFrame(Seq(rowschema(1,"record1"), rowschema(2,"record2"), rowschema(3,"record3"))) df.registerTempTable("tempTable")

sqlContext.sql("select * from tempTable").show()