**Why It Matters (Architectural Logic)**: CSV is ubiquitous but inefficient at scale. Filter early; prefer Parquet for production. Handle nulls and type coercion. Read CSV with schema inference or explicit schema: `df = spark.read.option("header",...
This medium-level Spark/Big Data question appears frequently in data engineering interviews at companies like Freight Tiger. While less common, it tests deeper understanding that distinguishes strong candidates. Mastering the underlying concepts (partition, spark) will help you answer variations of this question confidently.
Break this problem into components. Identify the core trade-offs involved, then walk the interviewer through your reasoning step by step. Demonstrate awareness of edge cases and production considerations - this is what separates good answers from great ones.
Why It Matters (Architectural Logic): CSV is ubiquitous but inefficient at scale. Filter early; prefer Parquet for production. Handle nulls and type coercion.
Read CSV with schema inference or explicit schema: df = spark.read.option("header", "true").csv("s3://bucket/input.csv"). Filter: minors_df = df.filter(F.col("age") < 18). If age may be string: df.filter(F.col("age").cast("int") < 18). Write: minors_df.write.option("header", "true").mode("overwrite").csv("s3://bucket/output.csv"). Best practices: use repartition(1) for a single output file if needed; use coalesce for controlled parallelism; consider Parquet over CSV for performance; set escape/delimiter options for complex CSVs. Handle nulls in age: df.filter(F.col("age").isNotNull() & (F.col("age").cast("int") < 18)).
Scalability Trade-offs: CSV has no predicate pushdown—full scan. Provide schema to skip inference. repartition(1) for single file risks OOM on large data.
Cost Implications: Parquet 2-5x smaller and faster. Use CSV for small, ad-hoc; Parquet for production.
Want feedback on your answer?
Paste your answer to this question and our AI Coach scores it, finds gaps, and shows you the FAANG-level version.
Get the most asked SQL questions with expert answers. Instant download.
No spam. Unsubscribe anytime.
Paste your answer and get instant AI feedback with a FAANG-level improved version.
Analyze My Answer — FreeAccording to DataEngPrep.tech, this is one of the most frequently asked Spark/Big Data interview questions, reported at 1 company. DataEngPrep.tech maintains a curated database of 1,863+ real data engineering interview questions across 7 categories, verified by industry professionals.