AI interview practice

← All interview guides

Capital One Data Engineer Practice: Building a Canonical Activity History

Capital One’s mobile app surfaces recent transaction activity to customers. This fictional banking pipeline receives separate pending, posted, and reversal events for the same activity. Descriptions and amounts can change between stages, and events may arrive out of order. A warehouse dashboard that counts every event as a purchase overstates spending. Practice designing a canonical activity model and replay process that yields an accurate customer history and reliable analytics. All data and exercises are synthetic; they do not represent Capital One systems, interview questions, or hiring standards.

Practice Capital One Data Engineer →

OfferBox.ai provides independent interview preparation and is not affiliated with Capital One. These are original practice materials, not verified employer questions. Confirm your interview format with your recruiter.

Pending, Posted, and Reversal Events: Canonical Activity History

A fictional banking app receives events for customer transactions. Each activity_id has a lifecycle: pending, then posted, and sometimes a reversal. Events may arrive out of order, and the amount or description can change between pending and posted. Build a canonical view that yields one row per activity with the latest state, and use it to compute accurate posted spend. The dataset is synthetic and illustrative.

Synthetic event log for activity_id lifecycle (6 rows). event_id is unique per event; activity_id groups lifecycle events. event_ts orders events.
event_idactivity_idevent_typeevent_tsamount_centsdescription
101A1pending2026-11-01T10:00:00Z1200Coffee Shop
102A1posted2026-11-02T08:00:00Z1250Coffee Shop Inc
201A2pending2026-11-01T12:00:00Z5000Online Retailer
202A2posted2026-11-02T09:00:00Z5000Online Retailer
203A2reversal2026-11-03T09:00:00Z5000Reversal: Online Retailer
301A3pending2026-11-04T15:00:00Z799Subscription
SQL dataset setup
CREATE TABLE activity_events (event_id INTEGER NOT NULL, activity_id TEXT NOT NULL, event_type TEXT NOT NULL, event_ts TEXT NOT NULL, amount_cents INTEGER, description TEXT);
INSERT INTO activity_events (event_id, activity_id, event_type, event_ts, amount_cents, description) VALUES (101, 'A1', 'pending', '2026-11-01T10:00:00Z', 1200, 'Coffee Shop');
INSERT INTO activity_events (event_id, activity_id, event_type, event_ts, amount_cents, description) VALUES (102, 'A1', 'posted', '2026-11-02T08:00:00Z', 1250, 'Coffee Shop Inc');
INSERT INTO activity_events (event_id, activity_id, event_type, event_ts, amount_cents, description) VALUES (201, 'A2', 'pending', '2026-11-01T12:00:00Z', 5000, 'Online Retailer');
INSERT INTO activity_events (event_id, activity_id, event_type, event_ts, amount_cents, description) VALUES (202, 'A2', 'posted', '2026-11-02T09:00:00Z', 5000, 'Online Retailer');
INSERT INTO activity_events (event_id, activity_id, event_type, event_ts, amount_cents, description) VALUES (203, 'A2', 'reversal', '2026-11-03T09:00:00Z', 5000, 'Reversal: Online Retailer');
INSERT INTO activity_events (event_id, activity_id, event_type, event_ts, amount_cents, description) VALUES (301, 'A3', 'pending', '2026-11-04T15:00:00Z', 799, 'Subscription');

Latest event per activity

Write a read-only query that returns one row per activity_id with the latest event by event_ts. For ties, use the larger event_id. Include activity_id, event_type, amount_cents, description, and event_ts. Order by activity_id.

Show worked solution
WITH ranked AS (SELECT activity_id, event_type, amount_cents, description, event_ts, ROW_NUMBER() OVER (PARTITION BY activity_id ORDER BY event_ts DESC, event_id DESC) AS rn FROM activity_events) SELECT activity_id, event_type, amount_cents, description, event_ts FROM ranked WHERE rn = 1 ORDER BY activity_id

The canonical latest state for A1 is posted at 1250 cents with updated description; A2 is reversal; A3 remains pending. This yields one row per activity and is the basis for spend metrics. Pending and reversal activities are not counted as spend.

Posted spend excluding reversals

Using the latest event per activity, compute total posted spend in cents and the number of posted activities. Exclude activities whose latest state is reversal or pending. Return posted_spend_cents and posted_activity_count.

Show worked solution
WITH ranked AS (SELECT activity_id, event_type, amount_cents, ROW_NUMBER() OVER (PARTITION BY activity_id ORDER BY event_ts DESC, event_id DESC) AS rn FROM activity_events) SELECT COALESCE(SUM(CASE WHEN event_type = 'posted' THEN amount_cents END), 0) AS posted_spend_cents, COUNT(CASE WHEN event_type = 'posted' THEN 1 END) AS posted_activity_count FROM ranked WHERE rn = 1

Only A1 is posted with 1250 cents; A2 is reversed and A3 is pending, so spend is 1250 cents and count is 1. Denominator is posted activities. This avoids the overstatement caused by counting all events as purchases.

Design for replay and out-of-order arrival

Describe how you would make the canonical view replay-safe when the same events are reprocessed and when a reversal arrives before its posted event. Specify idempotency key, ordering rule, and how you would validate key uniqueness as an input assumption.

Show worked solution

Use event_id as the idempotency key and validate that it is unique across events as an input assumption. Order events by event_ts with event_id as deterministic tie-breaker, not arrival time. On replay, recompute canonical rows for affected activity_ids from the full event set for those activities, then overwrite the canonical table. For out-of-order reversal, the latest event_ts still determines final state; if reversal precedes posted in time, the latest state would be posted, so business rules must define precedence. Store a processed-event ledger keyed by event_id to avoid duplicates. Add a data-quality check that each activity's event sequence is non-decreasing in event_ts after sorting.

Practice Capital One Data Engineer Interview Questions

1. How would you define the canonical grain for an activity record, and why is event-level counting wrong?

Use one row per stable activity identifier (e.g., activity_id) with a current-state summarization. Event-level counting treats pending, posted, and reversal events as separate purchases. Discuss that the same purchase can appear as pending then posted then reversed, and that only the final lifecycle state should drive spend metrics.

2. What is the minimal set of event types and fields you need to reconstruct lifecycle state?

Expected types: pending, posted, reversal. Fields: activity_id (stable business key), event_id (idempotency key), event_type, event_ts (ordering), amount_cents, description, and possibly reversal_of_event_id. Emphasize that amount and description may be overwritten by later events and that out-of-order arrival means ordering by event_ts, not ingestion time.

3. How do you make the canonicalization idempotent and replay-safe?

Use event_id as the idempotency key and a deterministic rule (e.g., latest event_ts wins per activity_id, tie-break by event_id). On replay, recompute the canonical row from all events for affected activity_ids. Store processed event_ids to avoid duplicates. Validate that key uniqueness holds as an input assumption.

4. What metrics should the dashboard use so it does not overstate spending?

Count only activities whose latest state is posted, and exclude reversed activities. Report units in cents and define denominator as number of posted activities. Provide a separate pending-count metric for transparency but not in spend totals.

5. How do you surface a transparent customer history?

Show one activity row per purchase with current amount and description, plus a status badge. Optionally allow drill-down to event timeline. Ensure reversals appear as credits or removed from spend, not as duplicate purchases.

Role scope and company context

Synthetic data engineering practice for transaction activity canonicalization, replay safety, and spend metric accuracy.

Capital One publicly describes mobile app features for managing accounts and viewing activity. This case is an original synthetic exercise; it does not infer Capital One's internal architecture, interview process, or standards. Product context is used only to motivate a realistic event-lifecycle problem.

These are original practice questions from OfferBox, not verified questions from Capital One interviews. The examples are illustrative, and the rubric is for self-assessment, not an employer hiring standard. Confirm interview stages with your recruiter.

Self-assessment rubric

For each criterion, mark your answer as missing, explained, or demonstrated with evidence. Rehearse the weakest area again.

Sources and editorial notes

Prepared by OfferBox. Official sources below inform the context and further reading; they do not verify these practice prompts or example answers.

How to prepare

Practice these with an AI interviewer

Start preparation for Capital One Data Engineer. Add your job description and resume to personalize your practice.

Free to start. No credit card.