
Ultimate access to all questions.
In the context of managing a Delta Lake table within a Databricks environment, you are tasked with adding a new column that should automatically compute its values based on other columns in the table. This column must also have a default value for existing rows. Considering the need for efficiency in storage and performance, which of the following approaches correctly implements a generated column with these requirements? Choose the best option.
A
Execute the ALTER TABLE ADD COLUMNS command to add the new column, specifying a default value, and use the GENERATED ALWAYS AS clause to define it as a generated column.
B
Create a new table with the CREATE TABLE command, including the generated column definition in the WITH clause, and then migrate all data from the old table to the new one.
C
First, update all existing rows in the table to set the value of the new column using the UPDATE command, then add the column as a generated column with the ALTER TABLE ADD COLUMNS command.
D
Use the MERGE command to insert or update rows with the new column values, followed by the ALTER TABLE ADD COLUMNS command to add the column as a generated column.