Interview practice question
CSV columns loading as wrong types
Data Engineering · Spark · Beginner
You read a CSV in Spark and IDs like 00123 show up as 123, and dates show as strings. How do you fix it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Schema inference guessed the ID as a number.
- Define an explicit schema with StringType for IDs.
- Parse dates with to_date and an explicit format.
- Use options like header and dateFormat.
- Explicit schemas also make runs consistent.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.