Databricks Data Engineer Associate exam dumps

Databricks Data Engineer Associate practice question 168 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 168

Single answer

You are working with a DataFrame in Databricks that contains nested JSON data about customer orders. The schema is as follows:

root |-- order_id: string |-- customer: struct | |-- name: string | |-- contact: struct | |-- email: string | |-- phone: string

How would you extract only the customer's email address using dot syntax while working with this DataFrame?

  1. A

    df.select('customer.contact.email')

  2. B

    df.select('customer.email')

  3. C

    df.select('contact.email')

  4. D

    df.selectExpr('customer.contact.email')

Show answer and explanation

Correct answer: A

Explanation

To extract nested fields in a DataFrame, you use dot syntax to traverse the hierarchy. In this case, 'customer.contact.email' correctly navigates through the nested structure to access the email field. The other options either reference invalid paths or do not adhere to the requirements of the question.

  • A. Correct.

    Correct. This is the proper way to access a nested field (email) using dot syntax in the DataFrame API.

  • B. Incorrect.

    Incorrect. There is no field named 'email' directly under the 'customer' struct. It is nested under 'contact'.

  • C. Incorrect.

    Incorrect. There is no field named 'contact' at the top level of the DataFrame. It is nested under 'customer'.

  • D. Incorrect.

    Incorrect. While selectExpr can be used for SQL-style expressions, the question specifically asks for dot syntax which is used in the DataFrame API.

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