SpinTheMic
Pro

Interview practice question

Job runs the same computation twice

Data Engineering · Spark · Beginner

A PySpark job calls df.count() to log rows and then writes df to a table. You notice the heavy transformation runs twice. Why?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Spark is lazy and recomputes the lineage for each action.
  • count and write are two actions.
  • Cache or persist the DataFrame if it's reused.
  • Or get the count from the write metrics or the target table.
  • Unpersist after use.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics