SpinTheMic
Pro

Interview practice question

Union shifting data into wrong columns

Data Engineering · Spark · Intermediate

After unioning monthly DataFrames, some values appear in the wrong columns. What happened and how do you fix it?

What a strong answer covers

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

  • union matches columns by position, not by name.
  • DataFrames with different column order get misaligned.
  • Use unionByName instead.
  • allowMissingColumns=True handles columns missing in some inputs.
  • Add a schema check after the union.
Practise this topic

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

See all topics