Databricks Data Engineer Associate Question 414
Select 2You are managing a Delta Live Tables (DLT) pipeline that has failed during execution. The error message indicates a syntax issue in one of the SQL-based notebooks. Upon reviewing the code, you find the following statements:
- CREATE TABLE customers_silver AS SELECT * FROM STREAM(customers_bronze);
- CREATE customers_gold AS SELECT * FROM LIVE.customers_silver WHERE status = 'active';
What corrections should you make to resolve the syntax issues in these statements?
- A
Replace 'STREAM(customers_bronze)' with 'LIVE.customers_bronze' in the first statement.
- B
Add the keyword 'TABLE' after 'CREATE' in the second statement.
- C
Replace 'LIVE.customers_silver' with 'STREAM(customers_silver)' in the second statement.
- D
Add the keyword 'LIVE' before 'customers_silver' in the first statement.
- E
Both statements are correct and no changes are needed.
Show answer and explanation
Correct answers: A, B
Explanation
In Delta Live Tables, the 'LIVE' keyword is used to reference tables or views defined within the pipeline, while 'STREAM' is used in the 'FROM' clause to read from a streaming source. The first statement incorrectly uses 'STREAM(customers_bronze)' instead of 'LIVE.customers_bronze'. Additionally, the 'CREATE' statement in DLT requires the 'TABLE' keyword, which is missing in the second statement. Correcting these issues will resolve the pipeline error.
- A. Correct.
Correct: In DLT, you must use 'LIVE' to refer to upstream tables or views defined within the pipeline. 'STREAM' is not valid here; you should replace 'STREAM(customers_bronze)' with 'LIVE.customers_bronze'.
- B. Correct.
Correct: The 'CREATE' statement in DLT requires the 'TABLE' keyword when defining a new table. The second statement is missing the 'TABLE' keyword after 'CREATE'.
- C. Incorrect.
Incorrect: 'STREAM' should be used in the 'FROM' clause when reading from streaming sources, not for referring to upstream tables within DLT. 'LIVE.customers_silver' is correct and does not need to be replaced.
- D. Incorrect.
Incorrect: Adding 'LIVE' before 'customers_silver' in the first statement is incorrect because the issue lies with the use of 'STREAM(customers_bronze)', not 'customers_silver'.
- E. Incorrect.
Incorrect: Both statements have syntax issues and need corrections as described in the explanations for the correct options.