Databricks Data Engineer Associate exam dumps

Databricks Data Engineer Associate practice question 86 of 532

Databricks Certified Data Engineer Associate. Associate level, Databricks. Free question with the correct answer and a full explanation.

Databricks Data Engineer Associate Question 86

Single answer

You are tasked with ingesting JSON files stored in a Databricks workspace. The JSON files are located in a directory, and you need to load all the data into a DataFrame for processing. Which of the following Spark commands should you use to correctly extract data from the directory?

  1. A

    spark.read.json('/mnt/data-directory/')

  2. B

    spark.read.format('json').load('/mnt/data-directory/*.json')

  3. C

    spark.read.format('json').load('/mnt/data-directory/')

  4. D

    spark.read.json('/mnt/data-directory/file.json')

Show answer and explanation

Correct answer: C

Explanation

To extract data from a directory containing multiple JSON files, you should use spark.read.format('json').load('/mnt/data-directory/'). This method explicitly specifies the JSON format and loads all files in the directory. Using a wildcard pattern like *.json is not necessary, as Spark automatically reads all the JSON files in the specified directory.

  • A. Incorrect.

    This is incorrect because while it can read JSON files from a directory, the spark.read.json function automatically uses the directory path without requiring wildcard patterns like *.json. The wildcard is unnecessary when reading from a directory.

  • B. Incorrect.

    This is incorrect because using the *.json wildcard is redundant and not required when reading all files in a directory. Spark can infer the file format and read all JSON files directly from the directory path.

  • C. Correct.

    This is correct because spark.read.format('json').load('/mnt/data-directory/') is the proper way to read all JSON files from a directory using the DataFrame API. It specifies the format explicitly and loads all files from the directory.

  • D. Incorrect.

    This is incorrect because it specifies a single file path, not a directory. If you want to read from a directory, you need to provide the directory path, not the path of an individual file.

Timed practice exam

Take a Databricks Data Engineer Associate practice test under exam conditions

45 questions in 90 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam