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
Real-Time Data Quality Monitoring
00:00
5 left

Real-Time Data Quality Monitoring

HardSQL · PostgreSQL

Problem

How do you enforce data quality rules and monitoring in real-time streaming architectures?

Write a PostgreSQL query using ingestion_batches and streaming_events to evaluate each ingestion batch against the stated validation rules. Identify batches with invalid records or an event-count mismatch.

Output

  1. One row per ingestion batch, including batches with no events
  2. Columns: batch_id, source_name, received_event_count, expected_event_count, violating_event_count, and quality_status
  3. Sort by received_at ascending, then batch_id ascending

Schema

ingestion_batches
ColumnTypeDescription
batch_idPKINTUnique ingestion batch identifier
source_nameVARCHAR(50)Streaming source name
received_atTIMESTAMPTime the batch was received
expected_event_countINTExpected number of events in the batch
streaming_events
ColumnTypeDescription
record_idPKINTUnique stored event record identifier
batch_idINTAssociated ingestion batch
event_idVARCHAR(50)Source event identifier
event_typeVARCHAR(40)Type of streaming event
event_tsTIMESTAMPTimestamp supplied by the event producer
amountNUMERIC(12,2)Event monetary amount
Tablesingestion_batchesstreaming_events
Interviewer

Your question is Real-Time Data Quality Monitoring. 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.