A bronze table holds quantity as a STRING, because the source files were ingested without type inference. A data engineer runs the code below to replace missing quantities with zero before writing the silver table. The job succeeds, but a query counting the rows where quantity IS NULL in the silver table returns the same figure as before. What explains the result?
bronze = spark.read.table("prod.bronze.line_items")
cleaned = bronze.na.fill(0)
cleaned.write.mode("overwrite").saveAsTable("prod.silver.line_items")- AThe fill reaches only columns carrying a NOT NULL constraint in the bronze table definition, and quantity was declared as accepting nulls when the table was created.
- BThe affected rows hold an empty string rather than a null, and a fill replaces only true nulls, so those values were left in place by the transformation.
- CA fill requires an explicit subset of column names, and a call that omits the subset argument is treated as a no operation across every column in the frame.
- DA numeric fill value is applied only to numeric columns, so a STRING column is skipped; casting quantity to an integer type first, or filling with a string, populates it. Correct
Why A is wrong: Tempting because Delta tables do support column constraints, but a fill on a DataFrame is a transformation over values and pays no attention to the constraints declared on the source table.
Why B is wrong: A realistic bronze problem in general, but the check in the stem counts rows where quantity IS NULL, so the unchanged figure proves the values really are null and not empty text.
Why C is wrong: Tempting by analogy with the drop call, where a subset changes the outcome, but omitting the subset on a fill widens it to all eligible columns rather than disabling it.
Why D is correct: The fill is matched by type, so passing an integer restricts it to numeric columns and a STRING column is left exactly as it was, which is why the null count is unchanged.