Skip to content

Reshaping columns, rows, and arrays in a table

Spark SQL and DataFrame APIs provide DDL-style and functional operations to reshape tables: adding/dropping columns, renaming, splitting strings into multiple columns, filtering rows, and exploding array columns into multiple rows. These operations are used constantly when cleaning raw or semi-structured data during ETL/ELT transformations in Databricks notebooks.

Must-know

  • ALTER TABLE ... ADD COLUMNS adds new columns; ALTER TABLE ... DROP COLUMN drops one (requires Delta column mapping enabled for DROP COLUMN); withColumn() adds/replaces a column in a DataFrame, while drop() removes one.
  • Renaming uses ALTER TABLE ... RENAME COLUMN in SQL or withColumnRenamed() in DataFrames; renaming does not change underlying data, only metadata.
  • split(col, pattern) splits a string column into an array, and array elements can be pulled into separate columns via indexing (e.g., split(col,',')[0]) or getItem().
  • Filtering uses WHERE in SQL or .filter()/.where() on DataFrames; both accept boolean column expressions and can be chained for multiple conditions.
  • explode(array_col) turns each element of an array (or map) into a separate row, duplicating the other column values across rows; rows with NULL or empty arrays are dropped by explode but kept by explode_outer.
  • Column and row operations can be combined in a single SELECT/DataFrame chain, but exploding before filtering (or vice versa) changes row counts and results, so operation order matters.
Check this objectiveFree · always available

A data engineer has a table orders with a column items containing an array of struct values (product_id, qty) per order. The team needs one row per product per order, preserving the order_id and all other columns, for downstream aggregation. Which function should the engineer use?

Your objective map0 tried · 0 right · 33 untouched

What you have tried across Databricks DEA's objectives, not a readiness score.

Coverage checked against the published exam guide on Jul 26, 2026.

These are independent practice questions, written against this certification's published exam guide. They are not the certification vendor's own questions, and not the real exam.