Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Spark Internals and Scaling
00:00
5 left

Spark Internals and Scaling

MediumSQL · PostgreSQL

Problem

Explain Spark internals and how it scales with the volume of data.

Using the supplied Spark event-log summary tables, write a PostgreSQL query that summarizes successful jobs with input data, stage execution, shuffle activity, and executor utilization.

Output

  1. One row per successful job with positive input volume
  2. Columns: job_id, app_name, input_gb, stage_count, total_stage_seconds, total_shuffle_read_gb, total_shuffle_write_gb, max_cpu_utilization_pct, input_delta_gb
  3. Include jobs without recorded stages or executor metrics
  4. Order by started_at, then job_id

Schema

spark_jobs
ColumnTypeDescription
job_idPKINTSpark job identifier
app_nameVARCHAR(100)Application name
started_atTIMESTAMPJob start timestamp
input_gbDECIMAL(10,2)Input data volume in gigabytes
output_gbDECIMAL(10,2)Output data volume in gigabytes
statusVARCHAR(20)Final job status
stage_metrics
ColumnTypeDescription
stage_idPKINTSpark stage identifier
job_idINTOwning Spark job
stage_nameVARCHAR(100)Stage description
duration_secondsINTStage duration in seconds
shuffle_read_gbDECIMAL(10,2)Shuffle data read in gigabytes
shuffle_write_gbDECIMAL(10,2)Shuffle data written in gigabytes
task_countINTNumber of tasks in the stage
failed_tasksINTNumber of failed tasks
executor_metrics
ColumnTypeDescription
metric_idPKINTExecutor metric record identifier
job_idINTOwning Spark job
executor_idVARCHAR(30)Executor identifier
peak_memory_gbDECIMAL(10,2)Peak executor memory usage
cpu_utilization_pctDECIMAL(5,2)Peak CPU utilization percentage
tasks_completedINTTasks completed by the executor
Tablesspark_jobsstage_metricsexecutor_metrics
Interviewer

Your question is Spark Internals and Scaling. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.