Data Transformation and Processing Logic Questions

Implementing transformation logic: joins, aggregations, deduplication, pivoting/reshaping, and business-rule application over datasets. Covers writing correct and maintainable transformation code, handling edge cases in the transform layer, and preparing data for downstream consumption. Focuses on the logic of turning raw data into analytics-ready outputs.

MediumTechnical
34 practiced

Implement a discount or promotion rule as deterministic, testable logic: for example, a line item qualifies for a discount only when several conditions all hold (a flag on the customer, a threshold on the order total, and a lookback window with no qualifying event). When multiple promotions could apply to the same item, the best discount should win. Provide an implementation (SQL or pseudocode) and describe how you would unit-test the rule set, including its edge cases.

MediumTechnical
31 practiced

Given a table (or DataFrame) of user events with a timestamp, derive session boundaries: a new session starts whenever the gap between consecutive events for the same user exceeds a configured timeout. Implement this both in SQL (using LAG/window functions and a running sum to assign session ids) and in pandas (as a reusable function), and return session id, start, end, and event count per session. Discuss how you handle unsorted input and timezone-aware timestamps.

MediumTechnical
41 practiced

A table stores raw event data as a JSON field containing nested objects and arrays (for example a user object and a products array). Write a SQL query that extracts the nested scalar fields into named columns and un-nests (explodes) the array into one row per array element, producing a flat, analysis-ready table. Discuss the trade-off between flattening at ingestion time (fixed schema, faster queries) versus parsing the JSON at query time (flexible, slower) as new nested fields appear.

HardTechnical
34 practiced

During feature or dataset preparation for a supervised model, a join can accidentally introduce label leakage: for example, joining in a table that contains information only available after the outcome is known, or a join that looks ahead in time. Describe common sources of this kind of leakage, how you would detect it automatically, and how you would design a rollback or re-computation process once leakage is found.

HardTechnical
54 practiced

A join between a very large fact table and a much smaller dimension or lookup table is suffering from severe key skew: a handful of hot keys account for a large share of the rows, causing straggler tasks and out-of-memory failures in a distributed engine like Spark. Explain and compare the standard mitigation techniques: broadcasting the small side, salting the skewed keys, pre-aggregating the hot keys before the join, and letting the engine's adaptive query execution handle it automatically. Discuss when each is the right choice and what can go wrong with a broadcast join if your assumption about which side is 'small' turns out to be wrong.

Unlock Full Question Bank

Get access to all 48 Data Transformation and Processing Logic interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.