PySpark Null Handling
13 interview problems on coalesce, fillna and three-valued logic, from easy to hard.
Learn Null Handling
- coalesce · 4 min read. Take the first non-null value from several columns, and why it is not the same as fillna.
- fillna / dropna · 4 min read. Fill or drop missing values per column, and why fillna(0) leaves string columns alone.
- eqNullSafe (<=>) · 4 min read. Equality where null matches null: the fix for joins and comparisons that silently drop null keys.
- filter / where · 5 min read. Keep the rows that match a condition, and the null and operator traps that silently drop data.
- Replace Missing Values · Easy · Null Handling
- Label Late Shipments · Easy · Dates, Null Handling, Conditional Logic
- Data Quality: Null Count per Column · Medium · Null Handling, Filtering & Selection
- Joining on Nullable Keys · Medium · Joins, Null Handling, Filtering & Selection
- Unpivot Wide Columns to Rows · Medium · Pivot, Unpivot & Rollup, Null Handling, Filtering & Selection
- Filter Low-Quality Training Text · Medium · Data Prep for AI, Strings, Null Handling
- Price Valid at Order Time (Range Join) · Hard · Joins, Null Handling, Filtering & Selection
- Reconcile Two Sources (Full Outer Join) · Hard · Joins, Null Handling, Conditional Logic, Filtering & Selection
- Fill Missing Dates (Calendar Spine) · Hard · Joins, Arrays, Aggregations, Dates, Null Handling, Filtering & Selection
- Monthly Retention by Cohort · Hard · Joins, Aggregations, Dates, Null Handling, Filtering & Selection
- Sessionize a Clickstream · Hard · Window Functions, Dates, Null Handling, Conditional Logic, Filtering & Selection
- Build an SCD Type 2 History · Hard · Window Functions, Null Handling, Filtering & Selection
- Pivot with Several Aggregations · Hard · Pivot, Unpivot & Rollup, Aggregations, Null Handling
Browse
Topics: Window Functions · Joins · Aggregations · Pivot, Unpivot & Rollup · Arrays · Null Handling · Conditional Logic · Dates · Filtering & Selection · Strings · Data Lake · Lakehouse · Streaming · Data Prep for AI · Spark Performance
Difficulty: Easy · Medium · Hard · Learn · All problems · dbt practice