Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - 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 59 Discussion

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

The code block displayed below contains an error. The code block should save DataFrame transactionsDf at path path as a parquet file, appending to any existing parquet file. Find the error.

Code block:

Show Suggested Answer Hide Answer
Suggested Answer: C

Correct code block:

transactionsDf.join(broadcast(itemsDf), 'transactionId', 'left_semi')

This Question: is extremely difficult and exceeds the difficulty of questions in the exam by far.

A first indication of what is asked from you here is the remark that 'the query should be executed in an optimized way'. You also have qualitative information about the size of itemsDf and

transactionsDf. Given that itemsDf is 'very small' and that the execution should be optimized, you should consider instructing Spark to perform a broadcast join, broadcasting the 'very small'

DataFrame itemsDf to all executors. You can explicitly suggest this to Spark via wrapping itemsDf into a broadcast() operator. One answer option does not include this operator, so you can disregard

it. Another answer option wraps the broadcast() operator around transactionsDf - the bigger of the two DataFrames. This answer option does not make sense in the optimization context and can

likewise be disregarded.

When thinking about the broadcast() operator, you may also remember that it is a method of pyspark.sql.functions. One answer option, however, resolves to itemsDf.broadcast([...]). The DataFrame

class has no broadcast() method, so this answer option can be eliminated as well.

All two remaining answer options resolve to transactionsDf.join([...]) in the first 2 gaps, so you will have to figure out the details of the join now. You can pick between an outer and a left semi join. An

outer join would include columns from both DataFrames, where a left semi join only includes columns from the 'left' table, here transactionsDf, just as asked for by the question. So, the correct

answer is the one that uses the left_semi join.


Contribute your Thoughts:

Ceola
1 months ago
Option E is a bit of a stretch. The code block doesn't mention anything about partitioning, so the bucketBy command is not necessary here.
upvoted 0 times
...
Ciara
1 months ago
Haha, option D is a classic trap answer. Of course, we don't want to omit the mode option if we want to append to the existing parquet file.
upvoted 0 times
Raymon
3 days ago
C) save() is evaluated lazily and needs to be followed by an action.
upvoted 0 times
...
Novella
17 days ago
A) transactionsDf.format(\'parquet\').option(\'mode\', \'append\').save(path)
upvoted 0 times
...
...
Muriel
2 months ago
I think option C is the right answer. The save() method is evaluated lazily, so an action like write() needs to be called after the options are set.
upvoted 0 times
Percy
24 days ago
B
upvoted 0 times
...
Truman
1 months ago
C
upvoted 0 times
...
Lemuel
1 months ago
A
upvoted 0 times
...
...
Krystina
2 months ago
Option B is correct. The code block is missing a reference to the DataFrameWriter, which is necessary to save the DataFrame as a parquet file.
upvoted 0 times
Fernanda
5 days ago
C
upvoted 0 times
...
Micah
14 days ago
B
upvoted 0 times
...
Whitney
17 days ago
A
upvoted 0 times
...
...
Laticia
2 months ago
The error is in option A. The correct way to save a DataFrame as a parquet file with append mode is transactionsDf.write.mode(\'append\').parquet(path).
upvoted 0 times
...
Avery
2 months ago
I believe option D is the correct one, we should omit the mode option.
upvoted 0 times
...
Marge
2 months ago
I agree with Miss, we need to add a reference to the DataFrameWriter.
upvoted 0 times
...
Miss
3 months ago
I think the error is in option A.
upvoted 0 times
...

Save Cancel