Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Validating Newly Ingested Data
00:00
5 left

Validating Newly Ingested Data

MediumSQL · PostgreSQL

Problem

Write a complex SQL query to validate the completeness and integrity of a newly ingested dataset.

Use the provided batch, account, and event data. Identify every validation failure for the most recently loaded batch.

Output

  1. One row per validation failure, with batch_id, check_name, issue_count, and details
  2. Include only failed checks and sort by validation priority, then check_name

Schema

ingest_batches
ColumnTypeDescription
batch_idPKINTUnique ingestion batch identifier
dataset_nameVARCHAR(100)Name of the ingested dataset
expected_row_countINTExpected number of event rows
expected_min_event_dateDATEEarliest permitted event date
expected_max_event_dateDATELatest permitted event date
loaded_atTIMESTAMPTimestamp when the batch was loaded
source_accounts
ColumnTypeDescription
account_idPKINTReferenced account identifier
account_statusVARCHAR(20)Current account status
ingested_events
ColumnTypeDescription
event_idPKINTUnique warehouse event identifier
batch_idINTIngestion batch identifier
account_idINTSource account identifier
event_dateDATEBusiness date of the event
amountNUMERIC(12,2)Event amount
source_record_keyVARCHAR(80)Source-system record key
ingested_atTIMESTAMPTimestamp when the event was ingested
Tablesingest_batchessource_accountsingested_events
Interviewer

Your question is Validating Newly Ingested Data. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.