Databricks Data Engineer Associate exam dumps

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

Single answer

You are working with a DataFrame df in Databricks that contains a nested column user with the fields id and name. How can you extract the id field from the user column using dot syntax?

  1. A

    df.select(df.user.id)

  2. B

    df.select('user.id')

  3. C

    df.select(df['user'].id)

  4. D

    df.select(df.user['id'])

Show answer and explanation

Correct answer: A

Explanation

In PySpark, to access nested fields within a column, you can use dot syntax. The correct syntax to extract the id field from the user column is df.user.id. This is the most concise and readable approach to handle nested data fields.

  • A. Correct.

    This is the correct way to extract a nested field using dot syntax in PySpark. The user.id field is accessed using df.user.id.

  • B. Incorrect.

    This syntax is incorrect because when using a string inside select, it does not automatically recognize nested fields. You need to use col('user.id') or dot syntax directly.

  • C. Incorrect.

    This syntax is invalid because df['user'] does not have an attribute .id in PySpark.

  • D. Incorrect.

    This syntax is also incorrect because df.user['id'] is not supported. You would use df.user.id for nested fields.

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