How to do it...

  1. Start the Spark shell or Databricks Cloud Scala notebook:
        $ spark-shell
  1. Load business data as a DataFrame:
        scala> val businesses = spark.read.format("json").load          ("s3a://sparkcookbook/yelpdata/            yelp_academic_dataset_business.json")
  1. Print the schema:
         scala> businesses.printSchema          root          |-- address: string (nullable = true)          |-- attributes: array (nullable = true)          | |-- element: string (containsNull = true)          |-- business_id: string (nullable = true)          |-- categories: array (nullable = true)          | |-- element: string (containsNull = true)          |-- city: string (nullable = true)          |-- hours: array (nullable = true)          | |-- element: string (containsNull = true)          |-- is_open: long (nullable = true) |-- latitude: double (nullable = true) ...

Get Apache Spark 2.x Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.