Created
January 24, 2016 12:44
-
-
Save conorfennell/8fc55a085d0e0345ee67 to your computer and use it in GitHub Desktop.
inferring schema with dataframes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val sc: SparkContext // An existing SparkContext. | |
val sqlContext = new org.apache.spark.sql.SQLContext(sc) | |
// Create the DataFrame | |
val df = sqlContext.read.json("examples/src/main/resources/people.json") | |
// Show the content of the DataFrame | |
df.show() | |
// age name | |
// null Michael | |
// 30 Andy | |
// 19 Justin | |
// Print the schema in a tree format | |
df.printSchema() | |
// root | |
// |-- age: long (nullable = true)// |-- name: string (nullable = false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment