Skip to content

Cleaning bronze data into silver tables with PySpark and SQL

In the medallion architecture, silver tables clean and conform bronze data by removing nulls, deduplicating, and enforcing correct data types before further transformation. This step typically uses PySpark DataFrame operations or SQL to read from a bronze Delta table, apply cleaning logic, and write the result as a new managed or external Delta table.

1 · Learn the must-know

  • Use dropna()/na.drop() or SQL WHERE col IS NOT NULL to remove nulls, and fillna()/na.fill() or COALESCE to impute default values instead.
  • Use dropDuplicates() or SQL DISTINCT/ROW_NUMBER() window logic to remove duplicate records, since bronze data often contains raw, duplicated ingested events.
  • Use cast() in PySpark or CAST()/:: in SQL to standardize data types (e.g., string to timestamp, string to decimal) since bronze tables often store all fields loosely typed or as strings.
  • Write cleaned output with df.write.format('delta').mode('overwrite'|'append').saveAsTable() or CREATE TABLE ... AS SELECT (CTAS) to persist the silver table.
  • Column pruning and renaming (select, withColumnRenamed, alias) commonly happen at this stage to conform to a clean, documented schema for downstream consumers.
  • Schema enforcement is automatic with Delta Lake, so mismatched types on write will throw an error unless mergeSchema or overwriteSchema options are explicitly set.

2 · Check your understanding

Check this objectiveFree · always available

A data engineer reads a bronze customer table containing 2 million rows into a DataFrame to build a silver table. The email column has 340,000 nulls, and business rules require every row in the silver table to have a non-null, validated email address. Which code accomplishes this?

Your objective map0 tried · 0 answered correctly · 33 untouched

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

Databricks Intelligence Platform6% of the exam0 of 2 tried
Data Ingestion and Loading21% of the exam0 of 7 tried
Data Transformation and Modeling22% of the exam0 of 7 tried
Working with Lakeflow Jobs16% of the exam0 of 4 tried
Implementing CI/CD10% of the exam0 of 4 tried
Troubleshooting, Monitoring, and Optimization10% of the exam0 of 5 tried
Governance and Security15% of the exam0 of 4 tried

3 · Keep going