QuestionQ19

VerifiedExecuting queries using Databricks SQL and Databricks SQL Warehouses

A data engineer is working with a nested array column, products, in the transactions table. They need to expand the table so that every unique item in products for each row gets its own row, with the transaction_id column repeated as required.

They are using the following incomplete command:

Question Image

Which of the following lines of code can they use to fill in the blank in the code block above so that it successfully accomplishes the task?

Explanation

explode(products) unnests the array and produces one output row for every array element. The remaining selected column, transaction_id, is consequently repeated for each generated product row.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!