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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Diff Between Large Datasets with Spark
00:00
5 left

Diff Between Large Datasets with Spark

HardSQL · PostgreSQL

Problem

Explain how you would perform a diff between two large datasets using Spark to ensure scalability and avoid memory overflow.

Use the provided PostgreSQL tables as the comparison inputs. Return every record that is missing, extra, or changed between the datasets.

Output

  1. One row per differing record_id
  2. Columns: record_id, diff_type, source values, and target values
  3. Include MISSING_IN_TARGET, EXTRA_IN_TARGET, and CHANGED records only
  4. Order by record_id ascending

Schema

source_dataset
ColumnTypeDescription
record_idPKBIGINTStable identifier used to match records
account_idVARCHAR(30)Account identifier
statusVARCHAR(20)Current account status
balanceNUMERIC(14,2)Reported account balance
as_of_dateDATEDate associated with the record
target_dataset
ColumnTypeDescription
record_idPKBIGINTStable identifier used to match records
account_idVARCHAR(30)Account identifier
statusVARCHAR(20)Current account status
balanceNUMERIC(14,2)Reported account balance
as_of_dateDATEDate associated with the record
Tablessource_datasettarget_dataset
Interviewer

Your question is Diff Between Large Datasets with Spark. Start with the requirements and the two 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.