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?
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
Currently there are no comments in this discussion, be the first to comment!