Spark interview questions
100 Data Engineering practice questions. Read what a strong answer covers, then practise it out loud against the clock.
Practise Spark questionsBeginner
- AnalysisException on column name
- Analysts want SQL instead of PySpark
- cache vs persist
- Caching made the job slower
- Cluster busy but job uses few cores
- collect() crashed the driver
- countDistinct is slow
- CSV columns loading as wrong types
- Dates shifting by a day after processing
- Driver and executors
- Handling nulls in PySpark DataFrames
- Job runs the same computation twice
- Job writes thousands of tiny files
- Jobs, stages and tasks
- Join with a small lookup table is slow
- Narrow vs wide transformations
- Overwrite deleted the whole table
- Python UDF slowing down the job
- RDD vs DataFrame vs Dataset
- Reading and writing data in Spark
- Reading nested JSON in Spark
- Removing duplicates keeping the latest
- repartition vs coalesce
- Rows missing after a join on nullable keys
- Schema inference vs explicit schema
- Spark SQL and temp views
- SparkSession
- Testing PySpark transformations
- Transformations vs actions
- User-defined functions in PySpark
- What Apache Spark is
- What partitions are
- Why lazy evaluation helps
- Why Parquet works well with Spark
Intermediate
- Adaptive Query Execution
- Aggregates differ between two runs
- Broadcast joins
- Broadcast variables and accumulators
- Bucketing in Spark
- Catalyst optimizer
- Choosing a partition column
- Daily job reprocessing all history
- Dynamic partition overwrite
- Executors killed with container memory errors
- explode blew up the row count
- Job slow after moving to a bigger cluster
- Late events missing from windowed counts
- One task running for hours in a join
- pandas UDFs vs Python UDFs
- partitionBy on write and the small-files problem
- Predicate pushdown and partition pruning
- Reading a large table over JDBC
- Reading explain plans
- Schema changed across Parquet files
- Sort-merge join
- Spark executor memory model
- Stage spilling heavily to disk
- Streaming from Kafka to Delta
- Streaming job too expensive for its value
- Tungsten execution engine
- Tuning shuffle partitions
- Union shifting data into wrong columns
- Upserting daily changes into a large table
- Using the Spark UI
- What a shuffle is and why it's expensive
- Window function very slow
- Window functions in PySpark
Experienced
- Applying CDC from Kafka with Spark
- Bad data silently flowing through
- Broadcast join failing after data growth
- Building daily features for ML from events
- Checkpoints and exactly-once in streaming
- Concurrent writers failing on the same table
- Cost-based optimizer and table statistics
- Driver hangs building a huge plan
- Driver OOM vs executor OOM
- Duplicates in a streaming sink after restart
- Dynamic allocation
- foreachBatch in Structured Streaming
- Handling data skew in Spark
- Job fails randomly about once a week
- Job spends ages before processing starts
- Join strategy hints
- Joining two huge tables repeatedly
- Many teams sharing one Spark cluster
- Migrating Hive tables to Iceberg or Delta
- Reducing Spark cluster costs
- Serialization and Kryo
- Sizing partitions and cluster resources
- Skewed aggregation on a hot key
- Spark Connect
- Speculative execution
- Stateful streaming and the state store
- Streaming job's state growing until crash
- Streaming output modes
- Structured Streaming basics
- Tuning a 6-hour nightly job
- Upgrading jobs to Spark 4
- Watermarks and late data
- What changed in Spark 4