Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {"name":"Michael"}
- {"name":"Andy", "age":30}
- {"name":"Justin", "age":19}
- import org.apache.spark.sql.SparkSession
- val sparkSession = SparkSession.builder
- .master("local")
- .appName("my-spark-app")
- .config("spark.some.config.option", "config-value")
- .getOrCreate()
- val peopleDF = sparkSession.sparkContext.
- textFile("C:/Users/Desktop/Spark/people.json").
- map(_.split(",")).
- map(attributes => Person(attributes(0),attributes(1).trim.toInt)).
- toDS()
- peopleDF.createOrReplaceTempView("person")
- val teenagersDF = sparkSession.sql("select name, age FROM person")
- teenagersDF.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement