Question 40
A Python UDF processes millions of values one row at a time, and a Spark UI profile shows excessive serialization overhead. A Pandas UDF emits strings but declares an integer return type; a scheduled batch fails after a new category appears. A scalar UDF silently calls an external paid service once per row, creating duplicate invoices after Spark retries tasks. What is the most appropriate plan for this situation?
Explanation
Correct Answer
Vectorized evaluation can reduce per-row Python crossing overhead when the function and types are supported. Spark must reconcile the declared type with the values emitted across Python execution boundaries. Spark can recompute tasks, so per-row side effects are not guaranteed to run exactly once.
Incorrect Answers
Grouped operations may materialize the full group in Python memory rather than uniform small batches; Requirement 2 requires: align the declared UDF return type and actual output schema, then test representative null and malformed values.
Grouped operations may materialize the full group in Python memory rather than uniform small batches; requirement 1 requires: evaluating a vectorized Pandas UDF with compatible Arrow-backed batches and measure the revised execution cost.
Spark can recompute tasks, so per-row side effects are not guaranteed to run exactly once.






Certified Data Engineer Professional Practice Tests