Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Validate Mock Customer Load Conversion

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

Your question is Validate Mock Customer Load Conversion. Start with the requirements and the two 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

Business Context

You’re a data engineer at a fintech payments company that processes ~10M card transactions/day. A legacy customer profile system is being migrated into a new analytics warehouse used for credit risk monitoring and regulatory reporting. Before enabling the production cutover, the team runs a mock load (one-day snapshot) from the legacy system into the new dim_customers table.

Because downstream models and compliance dashboards depend on accurate customer identity and status fields, you must validate that the conversion logic (type casting, normalization, and status mapping) produced correct results. The goal is to produce a single SQL query that can be run after each mock load and reviewed by engineers and QA.

Task

Write a SQL query that compares the legacy snapshot (legacy_customers_snapshot) to the newly loaded warehouse dimension (dim_customers) for a given load_date, and outputs reconciliation metrics and mismatch counts.

Requirements

For load_date = '2026-02-15', your query must return one row with:

  1. load_date
  2. legacy_row_count and dim_row_count
  3. missing_in_dim_count (present in legacy, absent in dim)
  4. extra_in_dim_count (present in dim, absent in legacy)
  5. email_mismatch_count (case-insensitive compare after trimming)
  6. status_mismatch_count (legacy status_code mapped to dim status)
  7. total_credit_limit_legacy and total_credit_limit_dim (sum comparison)

Status mapping rules (conversion spec):

  • legacy status_code = 'A' → dim status = 'active'
  • legacy status_code = 'S' → dim status = 'suspended'
  • legacy status_code = 'C' → dim status = 'closed'

Schema

legacy_customers_snapshot
ColumnTypeDescription
customer_idPKBIGINTStable customer identifier from the legacy system
emailVARCHAR(255)Customer email as stored in legacy (may contain whitespace/mixed case)
status_codeCHAR(1)Legacy status code: A (active), S (suspended), C (closed)
credit_limit_centsBIGINTCredit limit in cents in the legacy system
snapshot_datePKDATEDate of the legacy snapshot (partition key for mock load validation)
dim_customers
ColumnTypeDescription
customer_idPKBIGINTCustomer identifier in the warehouse (should match legacy)
emailVARCHAR(255)Normalized customer email stored in the warehouse
statusVARCHAR(20)Converted status value: active/suspended/closed
credit_limit_usdDECIMAL(12,2)Credit limit in USD in the warehouse
load_datePKDATEDate the record was loaded (partition key for the mock load)
Tableslegacy_customers_snapshotdim_customers
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results