BlackFriday 2024! 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:

Jerrod
18 days ago
Option D? Really? That's like using a sledgehammer to crack a nut. You gotta go with the classic, Option A, my friend.
upvoted 0 times
...
Julieta
19 days ago
I'm going with Option D. It just looks more intuitive to me. Who needs all those extra steps anyway?
upvoted 0 times
...
Gregoria
22 days ago
I'm pretty sure Option B is the right answer. spark.read.path(filePath, source=\'json\') looks more like the way to do it.
upvoted 0 times
Casie
4 days ago
I believe Option A is the correct one. spark.read.json(filePath) is the standard way to read in a JSON file.
upvoted 0 times
...
Corrie
5 days ago
I think Option D is the correct answer. spark.read().json(filePath) seems like the right syntax.
upvoted 0 times
...
...
Alida
1 months ago
I agree with Lenna. Option A is the way to go. Anything else seems like a weird way to read a JSON file.
upvoted 0 times
Jeannetta
2 days ago
User3: I'm not sure, but I think option D might also work.
upvoted 0 times
...
Pauline
11 days ago
Yeah, I agree. Option A is the way to go.
upvoted 0 times
...
Merri
13 days ago
I think option A is the correct one.
upvoted 0 times
...
...
Lenna
1 months 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 months 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
1 months ago
I'm going with E. It's shorter and looks more efficient.
upvoted 0 times
Callie
5 days ago
User3: I'm going to go with A, it seems like the most straightforward option.
upvoted 0 times
...
Margart
7 days ago
User2: I agree with User1, D is the right choice.
upvoted 0 times
...
Yoko
11 days ago
I think D is the correct option.
upvoted 0 times
...
...
Edmond
1 months ago
Hmm, you might be right. I'll reconsider my answer
upvoted 0 times
...
Edmond
1 months ago
I think the answer is D) spark.read().json(filePath)
upvoted 0 times
...
Lashon
1 months 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
2 months ago
D is the correct answer. The `read().json()` method is the way to go for reading JSON files.
upvoted 0 times
Margot
1 months ago
Thanks for confirming!
upvoted 0 times
...
Catalina
1 months ago
Yes, you are correct. That's the right way to read in a JSON file.
upvoted 0 times
...
Twana
1 months ago
I think the answer is D) spark.read().json(filePath)
upvoted 0 times
...
...
Essie
2 months 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
Kayleigh
1 months ago
I would go with option D as well.
upvoted 0 times
...
Jutta
1 months ago
I think option D is the best choice.
upvoted 0 times
...
Donte
1 months ago
I agree with you, option A is the correct one.
upvoted 0 times
...
Helaine
2 months ago
I prefer option A, it's more straightforward.
upvoted 0 times
...
...
Tyra
2 months 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
2 months ago
Yeah, I agree. Option A is the way to go.
upvoted 0 times
...
Carma
2 months ago
I think option A is the correct one.
upvoted 0 times
...
...

Save Cancel