Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL and Incremental Loading
00:00
5 left

SQL and Incremental Loading

MediumSQL · PostgreSQL

Problem

Tell me about your experience with SQL, database concepts, and incremental loading for keeping datasets up to date.

Demonstrate the incremental load using the provided PostgreSQL tables. Apply only records newer than the active watermark, insert new records, update existing records, and leave older records unchanged.

Output

  1. Return one row per record applied, with transaction_id, status, amount, and updated_at.
  2. Sort by transaction_id ascending.

Schema

source_transactions
ColumnTypeDescription
transaction_idPKINTSource transaction identifier
statusVARCHAR(20)Current transaction status
amountNUMERIC(12,2)Transaction amount
currencyVARCHAR(3)ISO currency code
updated_atTIMESTAMPTimestamp of the latest source change
phonepe_transactions
ColumnTypeDescription
transaction_idPKINTTarget transaction identifier
statusVARCHAR(20)Stored transaction status
amountNUMERIC(12,2)Stored transaction amount
currencyVARCHAR(3)Stored ISO currency code
updated_atTIMESTAMPTimestamp represented in the target
load_state
ColumnTypeDescription
load_state_idPKINTLoad state identifier
pipeline_nameVARCHAR(100)Name of the incremental pipeline
last_loaded_atTIMESTAMPLatest successfully processed source timestamp
is_activeBOOLEANWhether this watermark is currently active
Tablessource_transactionsphonepe_transactionsload_state
Interviewer

Your question is SQL and Incremental Loading. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.