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
Handling Schema Evolution
00:00
5 left

Handling Schema Evolution

HardSQL · PostgreSQL

Problem

How do you handle schema evolution within your data pipelines?

Write a SQL query that compares the latest two registered schema versions for each pipeline and identifies columns whose definition changed. Include newly added or removed columns, data type changes, and nullability changes.

Output

  1. One row per detected column change, with pipeline_name, column_name, change_type, previous_data_type, current_data_type, previous_is_nullable, and current_is_nullable.
  2. Include only the latest-versus-previous comparison for each pipeline.
  3. Order by pipeline_name, then column_name.

Schema

schema_versions
ColumnTypeDescription
version_idPKINTUnique schema version identifier
pipeline_nameVARCHAR(100)Name of the data pipeline
version_numberINTIncreasing version number within a pipeline
registered_atDATEDate the schema version was registered
schema_columns
ColumnTypeDescription
column_idPKINTUnique schema column record identifier
version_idINTSchema version containing the column
column_nameVARCHAR(100)Column name
data_typeVARCHAR(50)Declared SQL data type
is_nullableBOOLEANWhether the column accepts NULL values
Tablesschema_versionsschema_columns
Interviewer

Your question is Handling Schema Evolution. 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.