DATABRICKS-DATA-ENGINEER-ASSOCIATE practice question 18 of 25

A data engineer is attempting to drop a Spark SQL table my_table. The data engineer wants to delete all table metadata and data. They run the following command: DROP TABLE IF EXISTS my_table While the object no longer appears when they run SHOW TABLES, the data files still exist. Which of the following describes why the data files still exist and the metadata files were deleted?

Full set: 177 questions
Answer options
A: The table’s data was larger than 10 GB
B: The table’s data was smaller than 10 GB
C: The table was external Correct answer
D: The table did not have a location
E: The table was managed
Correct Answer:
C. The table was external
Explanation

The behavior described, where dropping a table removes its metadata but leaves the underlying data files intact, is the defining characteristic of an external (or unmanaged) table. Databricks assumes that data in an external location is managed outside of the table definition. Therefore, the DROP TABLE command for an external table only removes the table's metadata from the metastore, preserving the data files in their specified location for other processes or table definitions to use.

Why Incorrect

A. The table’s data was larger than 10 GB: The size of the data does not influence whether the underlying files are deleted when a table is dropped.
B. The table’s data was smaller than 10 GB: Similar to option A, data size is irrelevant to the DROP TABLE command's behavior regarding data file deletion.
D. The table did not have a location: All Spark SQL tables, whether managed or external, must have a location where their data files are stored.
E. The table was managed: If the table were managed, Databricks would manage both its metadata and its data. Consequently, running DROP TABLE would have deleted both the metadata and the underlying data files.

References

1. Databricks SQL Language Reference

DROP TABLE:

Section: DROP TABLE

Content: "For an external table

only the metadata information is removed from the metastore. The data in the external location is not touched." This directly confirms that dropping an external table leaves the data files.

Source: Databricks Documentation > SQL reference > Data definition language > DROP TABLE.

2. Databricks Documentation

"What are tables on Databricks?":

Section: "Managed table" and "External table"

Content: The documentation explicitly contrasts the two types. For managed tables: "When you drop a managed table

you also delete the underlying data." For external tables: "When you drop an external table

you do not delete the underlying data." This clearly explains the difference in behavior described in the question.

Source: Databricks Documentation > Data management > Data objects in the Databricks Lakehouse > What are tables on Databricks?.

Scroll to Top