Build a reconciliation report between a source and a target table. Rows (compared on all columns, distinct) that exist only in src get issue = 'missing_in_target'; rows that exist only in tgt get issue = 'extra_in_target'. A row whose amount changed therefore appears twice (once per side). Rows present in both are not reported. Return id, amount, issue. Row order does not matter.
| id | amount |
|---|---|
| 1 | 100.0 |
| 2 | 200.0 |
| 3 | 300.0 |
| id | amount |
|---|---|
| 1 | 100.0 |
| 2 | 250.0 |
| 4 | 400.0 |
| id | amount | issue |
|---|---|---|
| 2 | 200 | missing_in_target |
| 3 | 300 | missing_in_target |
| 2 | 250 | extra_in_target |
| 4 | 400 | extra_in_target |
| id | amount |
|---|---|
| 5 | 10.0 |
| id | amount |
|---|---|
| 5 | 10.0 |
| id | amount | issue |
|---|
Return exactly id, amount, issue.
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Keep the Latest Record per Customer · Rank Salaries Within Each Department ›
{{ totalCount }} questions · {{ shHardPct }}% Hard. Real PySpark DataFrame and Spark SQL interview questions. Write PySpark in your browser on TechTown’s Spark engine, run sample tests, then submit against hidden tests.
Guests can solve {{ freeLimit }} problems for free. Log in or sign up (free) to unlock everything, keep your streak and appear on the leaderboard. New to a topic? Learn it first in the Spark course.
{{ p.statement }}
{{ p.constraints }}
No submissions yet. Press Submit to judge your code against all tests.
The model solution and step-by-step explanation unlock when you solve this problem or after 3 unsuccessful submissions ({{ shFailsLabel }}). Struggling? Try the hints on the Question tab first.
{{ p.solution }}
Write real PySpark: from pyspark.sql import functions as F, Window, spark.sql(...). It runs in your browser on a lightweight Spark engine, and the same code runs unchanged on Databricks or any Spark cluster. Use df.show() or print() to debug.
Create your free TechTown account to unlock every problem, track your progress, bookmark questions and keep preparing for interviews.