Interview conceptData Manipulation (SQL/Python)

SQL/Python Data Manipulation And Joins

Asked of: Software Engineer

Last updated

Top-to-bottom flowchart showing a data-shaping pipeline: Raw input → Parse & normalize → Valid? (diamond) Yes → Hash join → Stable sort → Nested aggregation → Serialize output; No → Collect structured errors. Side card lists common pitfalls.

What's being tested

These exercises test data-shaping code: parsing semi-structured inputs, validating records, joining datasets, aggregating nested values, and producing deterministic output. Stripe interviewers are probing whether you can turn messy business data into correct, maintainable Python/SQL-style transformations with clear edge-case handling.

Patterns & templates

  • Hash join for CSV-style joins — build dict[key] -> list[rows], then emit left rows with all matches; O(n + m + output) time.

  • Stable sorting for deterministic output — use sorted(rows, key=lambda r: (...)); explicitly define tie-breakers instead of relying on incidental input order.

  • Validation pipeline — parse, normalize, validate, compute, serialize; keep errors structured as {field, message, path} and filter None / empty messages.

  • Nested aggregation — flatten recursive lists/dicts with DFS or stack; preserve sequence order when serializing validation failures.

  • Timezone-aware schedule expansion — use datetime, zoneinfo, and locale formatting; distinguish recurring-rule expansion from notification rendering.

  • String/bitmap rendering — preallocate row buffers or collect chars in lists, then ''.join(...); avoid repeated string concatenation in loops.

  • Numeric robustness — use Decimal for money-like costs, validate missing/negative/invalid quantities, and separate rounding policy from computation.

Common pitfalls

Pitfall: Treating joins as one-to-one when keys can have multiple matches; output cardinality may exceed either input size.

Pitfall: Mixing parsing, validation, and business logic in one loop; this makes edge cases hard to test and debug.

Pitfall: Producing nondeterministic output because dict iteration, duplicate keys, or unsorted errors are not explicitly ordered.

Practice these

The practice cards below cover the canonical variants — solve all of them and time yourself.

Featured in interview prep guides

Practice questions

Related concepts

SQL/Python Data Manipulation And Joins — Tech Interview Concept | PracHub