Tata Consultancy Services (North America)HardPipelines00:00

Welcome to your interview for the Data Engineer role at Tata Consultancy Services (North America).
The question is on your right: Build SCD2 Customer Dimension in Snowflake. Take a moment with it first.
Talk your thinking through with me if you like - when you're confident, submit your answer and I'll grade it like a real screen. You have three graded attempts to score 7/10 or better.
You’re interviewing with the Risk & Growth Analytics team at a large fintech (think “Stripe-scale”) that serves 25M monthly active customers across North America and Europe. The company uses Snowflake as its analytics warehouse and dbt + Airflow for ELT orchestration. Customer attributes (legal name, address, KYC status, risk tier, marketing opt-in, business type) are used by downstream teams for regulatory reporting (KYC/AML), credit decisioning, and lifecycle marketing.
Today, customer attributes are stored in a “latest snapshot” table (customer_current). This causes two major problems:
You need to design and implement a Slowly Changing Dimension (SCD) Type 2 pipeline for a dim_customer table in Snowflake, sourced from multiple upstream systems with late-arriving and out-of-order updates.
Upstream systems (all land into Snowflake RAW schema via existing ingestion):
RAW tables are append-only and partitioned by ingestion time:
raw.crm_customer_updatesraw.kyc_status_eventsraw.risk_tier_eventsA daily Airflow DAG currently builds analytics.customer_current by taking the latest record per customer from each source and joining them.
You will build analytics.dim_customer with these columns (minimum):
| Column | Type | Notes |
|---|---|---|
| customer_sk | NUMBER | Surrogate key (monotonic sequence or hash) |
| customer_id | STRING | Natural key |
| legal_name | STRING | From CRM |
| STRING | From CRM | |
| country | STRING | From CRM |
| kyc_status | STRING | From KYC provider |
| risk_tier | STRING | From risk engine |
| effective_from_ts | TIMESTAMP | Start of validity |
| effective_to_ts | TIMESTAMP | End of validity (open-ended for current) |
| is_current | BOOLEAN | Convenience flag |
| record_hash | STRING | Hash of tracked attributes |
| source_max_event_ts | TIMESTAMP | Latest contributing event time |
| loaded_at | TIMESTAMP | Warehouse load time |
Event tables have:
customer_idevent_ts (when the upstream system says the change happened)ingested_at (when it landed in Snowflake)event_id (not always unique across sources; some sources replay)Known issues:
Design a complete SCD Type 2 implementation for analytics.dim_customer that supports:
legal_name, email, country, kyc_status, risk_tier.event_ts (not ingested_at) as the business-effective time.dim_customer_current) and support point-in-time joins (as-of joins) from fact tables.customer_id and event_ts.In your answer, walk through:
You may assume you can create intermediate staging tables in analytics_staging and that dbt runs daily via Airflow.