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 Certified Associate Developer for Apache Spark 3.5 Exam - Topic 4 Question 16 Discussion

A data engineer wants to write a Spark job that creates a new managed table. If the table already exists, the job should fail and not modify anything.Which save mode and method should be used?
A) saveAsTable with mode ErrorIfExists
B) saveAsTable with mode Overwrite
C) save with mode Ignore
D) save with mode ErrorIfExists

Databricks Certified Associate Developer for Apache Spark 3.5 Exam - Topic 4 Question 16 Discussion

Actual exam question for Databricks's Databricks Certified Associate Developer for Apache Spark 3.5 exam
Question #: 16
Topic #: 4
[All Databricks Certified Associate Developer for Apache Spark 3.5 Questions]

A data engineer wants to write a Spark job that creates a new managed table. If the table already exists, the job should fail and not modify anything.

Which save mode and method should be used?

Show Suggested Answer Hide Answer
Suggested Answer: A

The method saveAsTable() creates a new table and optionally fails if the table exists.

From Spark documentation:

'The mode 'ErrorIfExists' (default) will throw an error if the table already exists.'

Thus:

Option A is correct.

Option B (Overwrite) would overwrite existing data --- not acceptable here.

Option C and D use save(), which doesn't create a managed table with metadata in the metastore.

Final Answer: A


Contribute your Thoughts:

0/2000 characters
Chau
2 days ago
I prefer B. Overwrite can be useful sometimes.
upvoted 0 times
...
Veta
7 days ago
Agreed, A makes sense. No accidental overwrites.
upvoted 0 times
...
Laquanda
12 days ago
I think A is the best choice. It fails if the table exists.
upvoted 0 times
...
Jackie
18 days ago
I thought mode Ignore was an option too, but it doesn't fit this case.
upvoted 0 times
...
Maile
23 days ago
B is definitely wrong, it would overwrite the table!
upvoted 0 times
...
Kenneth
28 days ago
Wait, can you really use save with mode ErrorIfExists?
upvoted 0 times
...
Glory
1 month ago
Totally agree, it prevents accidental overwrites.
upvoted 0 times
...
Eulah
1 month ago
A) saveAsTable with mode ErrorIfExists is the right choice!
upvoted 0 times
...
Levi
1 month ago
I feel like ErrorIfExists is definitely the way to go, but I’m a bit confused about the difference between save and saveAsTable in this context.
upvoted 0 times
...
Sabra
2 months ago
I recall that using mode Ignore would just skip the creation if the table exists, which isn't what we want here.
upvoted 0 times
...
Carey
2 months ago
I'm not entirely sure, but I remember a practice question where we used Overwrite, and it modified the table. That doesn't seem right for this case.
upvoted 0 times
...
Yuette
2 months ago
I think the answer might be A) saveAsTable with mode ErrorIfExists, since it specifically mentions failing if the table exists.
upvoted 0 times
...

Save Cancel