Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Databricks Exam Databricks-Certified-Associate-Developer-for-Apache-Spark-3.0 Topic 1 Question 67 Discussion

Actual exam question for Databricks's Databricks Certified Associate Developer for Apache Spark 3.0 exam
Question #: 67
Topic #: 1
[All Databricks Certified Associate Developer for Apache Spark 3.0 Questions]

Which of the following code blocks reads in the JSON file stored at filePath as a DataFrame?

Show Suggested Answer Hide Answer
Suggested Answer: A

spark.read.json(filePath)

Correct. spark.read accesses Spark's DataFrameReader. Then, Spark identifies the file type to be read as JSON type by passing filePath into the DataFrameReader.json() method.

spark.read.path(filePath)

Incorrect. Spark's DataFrameReader does not have a path method. A universal way to read in files is provided by the DataFrameReader.load() method (link below).

spark.read.path(filePath, source='json')

Wrong. A DataFrameReader.path() method does not exist (see above).

spark.read().json(filePath)

Incorrect. spark.read is a way to access Spark's DataFrameReader. However, the DataFrameReader is not callable, so calling it via spark.read() will fail.

spark.read().path(filePath)

No, Spark's DataFrameReader is not callable (see above).

More info: pyspark.sql.DataFrameReader.json --- PySpark 3.1.2 documentation, pyspark.sql.DataFrameReader.load --- PySpark 3.1.2 documentation

Static notebook | Dynamic notebook: See test 3, Question: 34 (Databricks import instructions)


Contribute your Thoughts:

Lenna
4 hours ago
Option A is the correct answer. spark.read.json(filePath) is the appropriate way to read a JSON file into a DataFrame in Spark.
upvoted 0 times
...
Glennis
1 days ago
Whoa, hold up! Option E? What is this, a trick question? Come on, that's not even close to the right answer.
upvoted 0 times
...
Katina
3 days ago
I'm going with E. It's shorter and looks more efficient.
upvoted 0 times
...
Edmond
7 days ago
Hmm, you might be right. I'll reconsider my answer
upvoted 0 times
...
Edmond
11 days ago
I think the answer is D) spark.read().json(filePath)
upvoted 0 times
...
Lashon
11 days ago
I disagree, I believe the correct answer is A) spark.read.json(filePath) because that's the standard way to read JSON files
upvoted 0 times
...
Teri
18 days ago
D is the correct answer. The `read().json()` method is the way to go for reading JSON files.
upvoted 0 times
Catalina
4 hours ago
Yes, you are correct. That's the right way to read in a JSON file.
upvoted 0 times
...
Twana
4 days ago
I think the answer is D) spark.read().json(filePath)
upvoted 0 times
...
...
Essie
21 days ago
I think option B is better. It's more explicit about the source being JSON, which makes the code more readable.
upvoted 0 times
Jutta
4 days ago
I think option D is the best choice.
upvoted 0 times
...
Donte
8 days ago
I agree with you, option A is the correct one.
upvoted 0 times
...
Helaine
13 days ago
I prefer option A, it's more straightforward.
upvoted 0 times
...
...
Tyra
27 days ago
Option A looks good to me. It's the most straightforward way to read a JSON file as a DataFrame.
upvoted 0 times
Emiko
18 days ago
User 2: Yeah, I agree. Option A is the way to go.
upvoted 0 times
...
Carma
21 days ago
User 1: I think option A is the correct one.
upvoted 0 times
...
...

Save Cancel