Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import org.apache.spark.sql.SQLContext
  2. import org.apache.spark.{SparkConf, SparkContext}
  3.  
  4. object MyEnum extends Enumeration {
  5. type MyEnum = Value
  6. val Hello, World = Value
  7. }
  8.  
  9. case class MyData(field: String, other: MyEnum.Value)
  10.  
  11. object EnumTest {
  12.  
  13. def main(args: Array[String]): Unit = {
  14. val sparkConf = new SparkConf().setAppName("test").setMaster("local[*]")
  15. val sc = new SparkContext(sparkConf)
  16. val sqlCtx = new SQLContext(sc)
  17.  
  18. import sqlCtx.implicits._
  19.  
  20. val df = sc.parallelize(Array(MyData("hello", MyEnum.World))).toDF()
  21.  
  22. println(s"df: ${df.collect().mkString(",")}}")
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement