Databricks Data Engineer Associate exam dumps

Databricks Data Engineer Associate practice question 88 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 88

Select 2

You are tasked with processing JSON data stored in Databricks. The data resides in a directory containing multiple JSON files, and you need to load all the data into a DataFrame. Which of the following code snippets would correctly load the data from the directory?

  1. A

    spark.read.json('/path/to/directory')

  2. B

    spark.read.json('/path/to/directory/*.json')

  3. C

    spark.read.load('/path/to/directory', format='json')

  4. D

    spark.read.format('json').load('/path/to/directory')

Show answer and explanation

Correct answers: A, D

Explanation

In Databricks, you can load data from a directory of files using either spark.read.json or spark.read.format('json').load. Both methods are commonly used to process JSON data and will automatically combine the contents of all JSON files in the specified directory into a single DataFrame.

  • A. Correct.

    This is correct because spark.read.json can directly load all the JSON files in a directory without specifying individual file names.

  • B. Incorrect.

    This is incorrect because specifying *.json is unnecessary when loading a directory, and it may lead to errors in some cases.

  • C. Incorrect.

    This is incorrect because while spark.read.load is valid, you must explicitly specify that the format is JSON using .format('json'). Without it, this code will fail.

  • D. Correct.

    This is correct because spark.read.format('json').load('/path/to/directory') properly specifies the format and loads all JSON files in the directory.

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