Data Cleaning Exercises

Task: the rules
Input
  events(id, raw_ts) — text. id is unique.

Rules
  Accept raw_ts when it is YYYY-MM-DD, "T" or one space, HH:MM[:SS[.fraction up to 6 digits]], then an explicit
  offset (Z or ±HH:MM, at most ±14:00); hour 00–23, minute/second 00–59; the date must exist. Convert to UTC.
  2026-11-01T01:30:00-04:00 and 2026-11-01T01:30:00-05:00 are different instants.
  Quarantine with reason:
    missing_offset   a well-formed date and time with no offset (never assume a zone)
    bad_timestamp    anything else, including missing values

Outputs (row order does not matter)
  clean(id text, ts timestamptz [UTC])
  exceptions(id text, reason text)

Tab inserts spaces. Press Escape, then Tab, to move focus out of the editor.

Input: events, rows 1 to 11 of 11
#idstringraw_tsstring
1evsk9z2026-01-15T09:00:00+15:00
2evp3vk2026-11-01T05:30Z
3evs5xu2026-06-30T23:59:59.123456
4eve3p8yesterday
5evl74h2026-06-30T23:59:59.5+05:30
6evff5w2026-11-01T01:30:00
7evdtw22026-11-01T01:30:00
8evfs8g2026-01-01T00:00:00+14:00
9evwupf2026-11-01 01:30
10evbd2o2026-11-01T01:30:00
11ev6p6c2026-11-01 01:30

Run preview · in your browser, not a grade

Loading the preview runtime…

Check answer · graded on an isolated server, including hidden datasets

Your code runs in a locked-down machine with no network, on the visible data and on hidden datasets that follow the same rules.

Learn from this exercise

A worked solution becomes available after your first check or once you've used every hint.

AI tutor · may be wrong; the grader decides

SQL · DuckDB 1.5.1Preview runtime loadingNot saved yet · sign in to save to your account