
Explanation:
The correct answer uses the UPDATE statement to modify existing records in the products table where the price is strictly greater than 1000. The syntax for updating records in a Delta table is straightforward: UPDATE table_name SET column_name = expr WHERE condition. This approach directly applies the 50% discount to the qualifying products. For more details, refer to the Databricks documentation on Delta UPDATE.
Ultimate access to all questions.
No comments yet.
The data engineering team is working with a Delta table named products that includes product details, such as the net price. Which of the following code blocks correctly applies a 50% discount to all products priced above 1000 and updates the table with the new prices?
A
SELECT price * 0.5 AS new_price FROM products WHERE price > 1000;
B
MERGE INTO products WHERE price > 1000 WHEN MATCHED UPDATE price = price * 0.5;
C
UPDATE products SET price = price * 0.5 WHERE price > 1000;
D
MERGE INTO products WHERE price < 1000 WHEN MATCHED UPDATE price = price * 0.5;
E
UPDATE products SET price = price * 0.5 WHERE price >= 1000;