Databricks Data Engineer Associate exam dumps

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

Single answer

You are working with a DataFrame in Databricks that contains a nested JSON column named user_info with the structure: { "name": { "first": "John", "last": "Doe" }, "age": 30 }. How can you extract the first name of the user?

  1. A

    df.select('user_info.name.first')

  2. B

    df.select(col('user_info.name.first'))

  3. C

    df.select('user_info.first.name')

  4. D

    df.select(col('user_info.first.name'))

Show answer and explanation

Correct answer: A

Explanation

In Databricks, to extract a nested field from a column, you can use the dot syntax to specify the full path to the field. The correct field path in this scenario is user_info.name.first, as the first field is nested under name, which is in turn nested under user_info.

  • A. Correct.

    Correct. The dot syntax is used to access nested fields in a column, and the path user_info.name.first correctly points to the first name.

  • B. Incorrect.

    Incorrect. While col() is valid for referencing columns, the syntax in this case is incorrect because it does not properly use the dot syntax for accessing nested fields.

  • C. Incorrect.

    Incorrect. The path user_info.first.name is invalid because it does not match the structure of the JSON data; the first field is nested under name.

  • D. Incorrect.

    Incorrect. Similar to Option 3, the path user_info.first.name is invalid, and wrapping it in col() does not fix the incorrect field reference.

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