Databricks Data Engineer Associate exam dumps

Databricks Data Engineer Associate practice question 317 of 532

Databricks Certified Data Engineer Associate. Associate level, Databricks. Free question with the correct answer and a full explanation.

Databricks Data Engineer Associate Question 317

Single answer

You are working with a Delta table in Databricks and need to add a generated column that calculates the total price as the product of 'quantity' and 'unit_price'. Which of the following commands will correctly create this generated column?

  1. A

    ALTER TABLE sales ADD COLUMN total_price GENERATED ALWAYS AS (quantity * unit_price);

  2. B

    ALTER TABLE sales ADD COLUMN total_price AS (quantity * unit_price);

  3. C

    ALTER TABLE sales ADD COLUMN total_price GENERATED ALWAYS AS (quantity * unit_price) STORED;

  4. D

    ALTER TABLE sales ADD COLUMN total_price COMPUTED AS (quantity * unit_price) STORED;

Show answer and explanation

Correct answer: C

Explanation

Delta tables in Databricks support generated columns using the syntax 'GENERATED ALWAYS AS (...) STORED'. This ensures that the column's value is automatically calculated based on an expression and physically stored in the table. The correct command for adding a generated column must include both the GENERATED ALWAYS AS and STORED keywords.

  • A. Incorrect.

    This option is incorrect because it is missing the STORED keyword, which is required for adding a generated column in Delta tables.

  • B. Incorrect.

    This option is incorrect because it uses an invalid syntax for defining a generated column. The GENERATED ALWAYS AS syntax is required.

  • C. Correct.

    This option is correct because it uses the correct syntax to define a generated column in a Delta table, including the GENERATED ALWAYS AS statement and the STORED keyword.

  • D. Incorrect.

    This option is incorrect because the 'COMPUTED AS' keyword is not valid syntax for defining a generated column in Delta tables.

Timed practice exam

Take a Databricks Data Engineer Associate practice test under exam conditions

45 questions in 90 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam