BetaJobprepping.com is in beta and still under construction. New sign-ups are closed.
Start practising
Analytics Engineer

Analytics Engineer Coding Interview with a Worked Example

What the analytics engineer coding interview tests, how messy the data is, what hidden tests probe, and a worked Python example on deduplicating order events.

Updated

The analytics engineer coding interview asks you to turn messy source records into a correct, well-defined table, usually in SQL and sometimes in Python, while explaining your choices aloud. The interviewer is checking grain, definitions and edge cases far more than clever syntax. This post explains the format, works through an example, and lists the mistakes that cost candidates the most.

For the full loop and the other rounds, start with the Analytics Engineer interview guide.

What the coding round looks like in a real loop#

Across the industry the coding element takes one of three forms:

  • A live SQL round, often 45 to 60 minutes, where you are given a small schema and a business question, then asked follow-ups that change the definition halfway through.
  • A take-home, usually a few hours of modelling against a provided dataset with tests and a short write-up, followed by a call where you walk through your decisions.
  • A practical Python or pandas task, less common but growing, especially where the team owns ingestion or uses Python models alongside SQL.

Whatever the form, the data is deliberately untidy: duplicate rows, a status that changes over time, a null where you expected a value, timestamps in different zones. Candidates who report a bad round often describe the same thing: spending too long on the first part and freezing when asked to talk while typing.

How our practice round works#

In our practice interviews, set at the fictional retailer Saltmarsh Goods, the coding section is Python in the browser: building a daily revenue model that has to deal with refunds and currencies. It runs 13, 18 or 20 minutes depending on whether you take the 30, 45 or 60-minute paper. The AI interviewer listens while you work and may ask why you made a choice. When you submit, hidden tests run against your code, and the scorecard records what you said as evidence. See how the practice interviews work.

The Python is plain: lists of dictionaries, sorting, grouping. No library tricks are needed. What matters is that the modelling thinking you would use in SQL shows up in the code.

What hidden tests tend to probe#

Hidden tests in any data coding round, ours included, tend to target the same places:

  • Duplicates: the same record sent twice, or two records that differ only in a field you should ignore.
  • Ordering: events that arrive out of order, or ties on the timestamp.
  • Boundaries: a record at exactly midnight, a day with no activity, the first and last day of a range.
  • Missing values: a null amount, a missing lookup value, an unknown category.
  • Zero and negative values: free orders, refunds bigger than expected.
  • Empty input: no records at all should return an empty result, not an error.

Hidden tests are rarely about scale in a short round, but stating the complexity of your approach and how it would behave on a much larger table is worth a sentence.

A worked example#

Here is an invented problem of the same genre. You receive order status events. Each has an order_id, a status, an event_id and a UTC timestamp ts. Events can be duplicated and can arrive out of order. Produce the number of orders whose latest status is shipped, per UTC day of that latest event.

Before writing code, say the grain out loud: "The output is one row per day. The intermediate step is one row per order, holding its latest event." Then state the tie-breaker: "If two events share a timestamp, the higher event_id wins."

from collections import defaultdict

def shipped_per_day(events):
    latest = {}
    for e in events:
        if e.get("order_id") is None or e.get("ts") is None:
            continue  # cannot place this event; count it separately in real life
        key = (e["ts"], e["event_id"])
        current = latest.get(e["order_id"])
        if current is None or key > (current["ts"], current["event_id"]):
            latest[e["order_id"]] = e
    counts = defaultdict(int)
    for e in latest.values():
        if e["status"] == "shipped":
            counts[e["ts"][:10]] += 1
    return dict(sorted(counts.items()))

This is one pass to deduplicate and one pass to aggregate, so linear in the number of events plus the sort of the days. The order of operations is the SQL habit translated: fix the grain first, then aggregate.

Test as you go with small cases you can check in your head, including the edges:

events = [
    {"order_id": 1, "status": "paid", "event_id": 10, "ts": "2026-03-01T09:00:00"},
    {"order_id": 1, "status": "shipped", "event_id": 11, "ts": "2026-03-02T08:00:00"},
    {"order_id": 1, "status": "shipped", "event_id": 11, "ts": "2026-03-02T08:00:00"},
    {"order_id": 2, "status": "shipped", "event_id": 20, "ts": "2026-03-02T10:00:00"},
    {"order_id": 2, "status": "cancelled", "event_id": 21, "ts": "2026-03-02T10:00:00"},
    {"order_id": 3, "status": "shipped", "event_id": 30, "ts": None},
]
assert shipped_per_day(events) == {"2026-03-02": 1}
assert shipped_per_day([]) == {}

The exact duplicate for order 1 counts once. Order 2 shows the tie-breaker: same timestamp, higher event_id, so it ends cancelled. Order 3 has no timestamp and is skipped, which you should say aloud as a decision, because a finance user might prefer it reported as unplaced rather than dropped.

Good follow-ups to expect: "What if the business wants the day in the customer's local time?" (you would need a time zone per order and to convert before truncating), and "What if an order is shipped, then returned?" (you would ask whether returned orders should still count as shipped on that day).

Talking while you code#

  • State the grain of every intermediate structure.
  • Name the tie-breaker and any dropped records as decisions, not accidents.
  • Write the happy path first, then add one edge case at a time with a quick check.
  • When a check fails, print the input that broke it before you change logic.
  • Keep a short list of assumptions you would confirm with the stakeholder, and read it out at the end.

Common mistakes#

  • Aggregating before deduplicating, so duplicates inflate counts.
  • Choosing "latest" by arrival order instead of by timestamp.
  • Leaving ties to chance, so results change between runs.
  • Silently dropping bad records without saying so.
  • Truncating timestamps to a day before converting time zones.
  • Running out of time polishing the first part and never testing edges.

For more on the questions that surround this round, see our list of analytics engineer interview questions, and for how the coding evidence is weighed, read how analytics engineer interviews are scored.

The best way to get comfortable is repetition under a clock. Take the Analytics Engineer practice interview and see what the hidden tests and your scorecard say.

Frequently asked questions#

Is the analytics engineer coding interview in SQL or Python?#

Most companies test SQL, either live or in a take-home, because it is the main language of the job. Some add a Python or pandas task, particularly where the team owns ingestion or uses Python models. Our practice exercise is in Python, which forces you to express grain and deduplication in plain code instead of relying on SQL shortcuts.

How hard is the analytics engineer coding round?#

The algorithms are usually simple: grouping, sorting, window-style logic. The difficulty comes from messy data and shifting definitions, plus thinking aloud under time pressure. Candidates who struggle tend to rush into code without defining the output, then lose time to duplicates or ties they did not plan for.

What do hidden tests check in a data coding exercise?#

They usually check duplicates, out-of-order or tied events, missing values, boundary dates, zero or negative amounts and empty input. They compare your output to an expected result, so a solution that works on the obvious case but not on the edges will fail several tests. Testing those cases yourself as you go is the best defence.

Should I optimise my code in an analytics engineer interview?#

Get a correct, readable solution first. Then state its complexity and say how it would behave on a much larger table, for example that it is linear and could be pushed down into SQL. Premature optimisation costs time you need for edge cases, and interviewers score correctness and clarity well above speed.

Read next

GuideAnalytics Engineer

Analytics Engineer Interview Guide with Questions and Prep

How the analytics engineer interview works, the SQL and data modelling skills it scores, 8 practice questions with strong-answer notes and a 7-day prep plan.

QuestionsAnalytics Engineer

Analytics Engineer Interview Questions and Strong Answers

25 analytics engineer interview questions on SQL, data modelling, testing and stakeholders, with why each is asked, what a strong answer does and the follow-up.

ScoringAnalytics Engineer

How Analytics Engineer Interviews Are Scored, Skill by Skill

How analytics engineer interviews are scored across eight weighted skills, the two must-haves, what Hire-ready looks like and how to move up a level.

Practice

Say it out loud.

Reading about an interview isn't the same as doing one. Take a 30, 45 or 60-minute Analytics Engineer interview with an AI interviewer and get scored against a real rubric.

Choose an interview