Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Clean Missing and Corrupted Data

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Clean Missing and Corrupted Data. Start with the requirements and the three tables on the right.

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.

Problem

How would you identify and handle missing or corrupted data points across a large distributed database using Python?

Translate this requirement into a PostgreSQL query over the provided source, expected measurement, and observation tables. Return every expected measurement that is missing or fails its validity checks.

Output

  1. One row per missing or corrupted expected measurement.
  2. Return expected_id, source_id, source_name, observed_at, observed_value, status, and issue_reason.
  3. Sort by source_id, then expected_id.

Schema

data_sources
ColumnTypeDescription
source_idPKINTIdentifier for a distributed data source
source_nameVARCHAR(100)Human-readable source name
regionVARCHAR(50)Deployment region of the source
expected_measurements
ColumnTypeDescription
expected_idPKINTIdentifier for an expected measurement point
source_idINTExpected source identifier
metric_nameVARCHAR(80)Name of the expected metric
observed_atTIMESTAMPExpected observation timestamp
minimum_valueNUMERIC(10,2)Minimum acceptable metric value
maximum_valueNUMERIC(10,2)Maximum acceptable metric value
observations
ColumnTypeDescription
observation_idPKINTIdentifier for a received observation
expected_idINTExpected measurement associated with the observation
observed_valueNUMERIC(10,2)Received metric value
quality_statusVARCHAR(20)Quality classification supplied by ingestion
Tablesdata_sourcesexpected_measurementsobservations
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results