Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vinodnerella/c6d96842f4a92137aceaf0ac80a6dae2 to your computer and use it in GitHub Desktop.
Save vinodnerella/c6d96842f4a92137aceaf0ac80a6dae2 to your computer and use it in GitHub Desktop.
sample scala program to get json file and printschema
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.sql.SQLContext
object discuss {
def main(args: Array[String]) = {
val conf = new SparkConf().setAppName("file format").setMaster("local")
val sc= new SparkContext(conf)
val sqlc = new SQLContext(sc)
val PersonDF=sqlc.read.json("person.json")
PersonDF.printSchema()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment