Data Engineer Associate · Domain 3: Data Transformation and Modeling · 22% of the exam
Task 3.3: Manipulate columns, rows, and table structures by adding, dropping, splitting, renaming column names, applying filters, and exploding arrays.
withColumn, drop, split, withColumnRenamed, filter and where, explode and explode_outer, and ALTER TABLE for column changes.
Study it
Adding, dropping, splitting and renaming columns; filters; explode
Lesson coming
Sample questions
Try each one before opening the answer. Every option is explained, with the Databricks documentation page that proves it.
Question 1 · choose 1
The DataFrame orders has an ARRAY column items. Some orders have an empty array or a NULL value in items. The silver table needs one row per item, and orders without items must still appear once with a NULL item. Which expression should the data engineer use?
A DataFrame has a column full_name with values like 'Ada Lovelace'. The data engineer runs df.withColumn('first_name', <expr>) and needs first_name to hold 'Ada' on the same row. Which expression should replace <expr>?
Before writing a silver table, the columns _rescued_data and ingest_ts must be removed from the DataFrame df, and every row must be kept. Which expression does this?
Each comparison is wrapped in parentheses and combined with &, which is how PySpark expresses AND.
In PySpark, combine Column conditions with &, | and ~, and put each comparison in parentheses. A SQL string such as "status = 'shipped' AND amount > 100" also works.