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
Sabra
3 days 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
8 days 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
13 days 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