Databricks Certified Machine Learning Professional — Question 32
A data scientist wants to remove the star_rating column from the Delta table at the location path. To do this, they need to load in data and drop the star_rating column.
Which of the following code blocks accomplishes this task?
Answer options
- A. spark.read.format(“delta”).load(path).drop(“star_rating”)
- B. spark.read.format(“delta”).table(path).drop(“star_rating”)
- C. Delta tables cannot be modified
- D. spark.read.table(path).drop(“star_rating”)
- E. spark.sql(“SELECT * EXCEPT star_rating FROM path”)
Correct answer: A
Explanation
Option A is correct because it uses the Delta format to load the data from the specified path and then drops the star_rating column. Option B is incorrect as the table method does not allow for direct column manipulation. Option C is false since Delta tables can be modified. Option D does not use the Delta format, which is needed for this specific operation, and Option E is incorrect because it uses SQL syntax that is not appropriate for the given task.