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
Exactly-Once Streaming Guarantees
00:00
5 left

Exactly-Once Streaming Guarantees

MediumSQL · PostgreSQL

Problem

How do you ensure Exactly-Once processing in a streaming pipeline?

Using stream_events, processing_attempts, and accounts, write a query that treats the latest processing attempt for each event as authoritative. Include only active accounts and attempts whose latest status is COMMITTED.

Output

  1. One row per active account, including accounts with no committed events
  2. Columns: account_id, account_name, exactly_once_event_count, and exactly_once_amount
  3. Sort by account_id ascending

Schema

accounts
ColumnTypeDescription
account_idPKINTUnique account identifier
account_nameVARCHAR(100)Account display name
is_activeBOOLEANWhether the account should appear in reporting
stream_events
ColumnTypeDescription
delivery_idPKINTUnique physical delivery identifier
event_idVARCHAR(50)Logical event identifier, repeated for duplicate deliveries
account_idINTAccount associated with the event
amountNUMERIC(12,2)Signed event amount
event_timeTIMESTAMPTZTime the event entered the stream
processing_attempts
ColumnTypeDescription
attempt_idPKINTUnique processing attempt identifier
delivery_idINTPhysical delivery being processed
statusVARCHAR(20)Processing outcome
attempted_atTIMESTAMPTZTime of the processing attempt
Tablesaccountsstream_eventsprocessing_attempts
Interviewer

Your question is Exactly-Once Streaming Guarantees. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.