Debug the AIEasy
1. Revenue per customer is higher than the ledger
An AI-written PySpark join between orders and payments inflates revenue because some orders have several payment rows. Find the duplicated rows and fix the query.
Fan-out trap
Debug the AIEasy
An AI-written PySpark join between orders and payments inflates revenue because some orders have several payment rows. Find the duplicated rows and fix the query.
Fan-out trap
SQLEasy
A change feed delivers several versions of each customer, with repeated rows, tied timestamps and missing timestamps. Write the Spark SQL that keeps exactly one current row per customer.
Tie trapNULL trap
PySparkMedium
A nightly incremental load filters on event time and silently skips events that arrive late. Work out with PySpark which run should load each event, exactly once.
Late-data trapBoundary trap
SQLMedium
Turn a table of customer saves into a slowly changing dimension (SCD type 2) with valid_from, valid_to and is_current, ignoring saves that changed nothing and handling NULL cities.
NULL trap
Debug the AIMedium
An AI-written Spark SQL window query computes a running account balance, but transactions on the same date all show the end-of-day balance. Find the window frame bug and fix it.
Tie trap
SQLEasy
Write a Spark SQL data quality report with one row per rule and the number of failing rows. The rules cover NULLs, duplicates, date order and a reference lookup where NOT IN quietly returns nothing.
NULL trapDuplicate trap
PySparkMedium
Group raw page views into user sessions with PySpark window functions. A session ends after more than 30 minutes of inactivity. Covers the exact boundary, long sessions and sessions across midnight.
Boundary trapTie trap
Debug the AIEasy
AI-written PySpark code combines two regional sales tables with union() and reports wrong net revenue. The tables have the same columns in a different order. Find the bug and fix it.
Schema trap
SQLHard
Merge overlapping and adjacent date ranges per user into continuous periods with Spark SQL. The classic gaps-and-islands problem, with nested periods that break the LAG-based solution.
Boundary trap
PySparkHard
A point-in-time (as-of) join in PySpark. Convert foreign-currency transactions to INR using the exchange rate that was valid when each transaction happened, without losing or duplicating rows.
Fan-out trapBoundary trap
SQLEasy
Return the three best-selling products in each category with Spark SQL, keeping every product that ties. Shows where ROW_NUMBER, RANK and DENSE_RANK give three different answers.
Tie trap
SQLEasy
Compute review counts and the average rating per product with Spark SQL when some reviews have no rating. Covers COUNT(*) versus COUNT(column), and why replacing NULL with 0 ruins an average.
NULL trap
SQLEasy
Report every customer with their completed March orders in Spark SQL, including customers with none. A filter on the joined table in WHERE turns the LEFT JOIN into an inner join and the zero rows disappear.
NULL trap
Debug the AIMedium
AI-written PySpark code builds a daily activity report for India from UTC timestamps. The weekly total is right but every day is wrong. Find the time zone bug and fix it.
Boundary trap
SQLMedium
Produce one row per store per day of March with Spark SQL, showing 0 on days without sales. A GROUP BY can only return days that have data; the missing days have to come from a calendar table.
Boundary trap
SQLMedium
Compute month-over-month revenue change per plan with Spark SQL. LAG returns the previous row, not the previous month, so a plan with a missing month gets compared across the gap.
Boundary trap
PySparkMedium
Summarise orders that carry a nested array of items with PySpark. After explode() each order is repeated once per item, so order-level values such as shipping fees get counted several times, and orders with no items vanish.
Fan-out trap
Debug the AIMedium
AI-written PySpark code compares regional sales with targets by joining on country and state. Regions whose state is NULL show zero sales, because NULL never equals NULL in a join. Find the bug and fix it.
NULL trap
SQLMedium
Join orders to a type 2 slowly changing dimension with Spark SQL so that each order gets the customer tier that was valid on the order date. BETWEEN duplicates orders on change days, and forgetting the open-ended current row loses recent ones.
Boundary trap
PySparkHard
Merge a batch of customer changes into a type 2 slowly changing dimension with PySpark. Close old versions, open new ones, skip saves that changed nothing, handle several changes for one customer, and ignore changes that arrive too late.
Late-data trap
SQLEasy
Turn order rows into one row per store with a column per status in Spark SQL. Covers conditional aggregation, 0 versus NULL for empty groups, and statuses that are missing or unexpected.
NULL trap
SQLEasy
Invoice numbers are stored as text, some with leading zeros. Find each customer's latest invoice and count the paid ones in Spark SQL without being fooled by text comparison, where '9' is greater than '1000'.
Schema trap
SQLEasy
Compute click and signup rates per campaign in Spark SQL when some campaigns have zero impressions, zero clicks or missing counts. A rate that cannot be computed must be NULL, not 0 and not an error.
NULL trap
SQLMedium
Compute monthly active users, total logins and peak daily active users per platform in Spark SQL. Distinct counts cannot be added up across days, which is how one user becomes twenty.
Grain trap
SQLMedium
Report revenue per category in Spark SQL when a product can belong to several categories. A plain join counts the same sale once per category, so the category totals add up to more than was sold.
Fan-out trapDuplicate trap
SQLMedium
Forward-fill missing sensor readings per device in Spark SQL, carrying the last known value across gaps of any length. LAG only reaches back one row, so runs of NULLs stay NULL.
NULL trap
SQLMedium
Remove accidental repeat clicks in Spark SQL by comparing each click with the previous one on the same button. Covers the exact 5-second boundary, chains of clicks and clicks recorded at the same instant.
Boundary trapTie trap
SQLHard
Find each user's longest run of consecutive login days in Spark SQL. A gaps-and-islands problem where several logins on one day, ties between streaks and streaks across a year end all break the usual shortcut.
Duplicate trapBoundary trap
SQLHard
Build a view, add-to-cart, purchase funnel in Spark SQL where the steps must happen in order and within 7 days of the first view. Counting each step on its own counts purchases that came before the cart.
Boundary trap
PySparkEasy
Count open support tickets per team that are not low priority, with PySpark. Filtering with != also throws away every ticket whose priority is NULL, which are the ones nobody has looked at yet.
NULL trap
PySparkEasy
Turn payment amounts typed as text ("₹1,299", "Rs. 300.50", "N/A") into decimals with PySpark. A plain cast fails the job in Spark 4 and silently returns NULL in older versions; neither tells you which rows were bad.
Schema trap
PySparkMedium
Extract user, amount and currency from JSON event payloads with PySpark when the producer changed the structure, sends numbers as strings and sometimes sends broken JSON. One fixed schema returns NULL for half the rows.
Schema trapNULL trap
PySparkMedium
Build a daily table of active, new and cumulative unique customers with PySpark. A running sum of daily distinct counts counts every returning customer again, and Spark has no distinct count over a window.
Grain trap
PySparkHard
Compare a loaded customer table with its source using PySpark and report missing, extra, duplicated and mismatched rows. Row counts can match while the content does not, and a plain != never flags a value that turned into NULL.
NULL trapDuplicate trap
PySparkHard
Merge customer records from CRM, billing and support into one row per customer with PySpark, taking each field from the most trusted record that actually has it. Keeping the single best row throws away values the other records had.
NULL trap
Debug the AIEasy
AI-written PySpark code sorts orders into SMALL, MEDIUM and LARGE with a when() chain, and the report shows no large orders at all. Find the branch-order bug and fix it without breaking the boundaries.
Boundary trap
Debug the AIEasy
An AI-written Spark SQL query reports the average order value per city by averaging the per-store averages. The order counts are right and the averages are not. Find the bug and fix it.
Grain trap
Debug the AIMedium
An AI-written Spark SQL query totals March payments per day with BETWEEN on a timestamp column. Every day is right except the last one. Find the date range bug and fix it.
Boundary trap
Debug the AIMedium
AI-written PySpark code computes rolling 7-day revenue per store with rowsBetween(-6, 0). Stores that are closed on some days get a window that reaches back much further than a week. Find the frame bug and fix it.
Boundary trap
Debug the AIMedium
AI-written PySpark code applies a batch of orders to a target table with a left anti join. New orders arrive, the row count is right, and every changed order keeps its old status. Find the bug and write the load properly.
Late-data trapDuplicate trap
Nothing fits this combination of search and filters.