Skip to content
ML Academy

SQL and Python

Interview question

  • seniorlevel
  • 15 minsuggested time
  • 3Data scientist, ML engineer, Data analyst

You have bookings(booking_id, route, booked_at) and a table of fare snapshots fare_snapshot(route, snap_ts, fare) that is appended whenever the price engine publishes a new fare, a few times per day per route. For a training table you need the fare that was visible at the moment of each booking. Write the query (or the pandas call), and say what can go wrong in production.

Tests: As-of (point-in-time) joins, window functions to pick the latest earlier row, join explosion cost, boundary semantics, and the difference between event time and ingestion time.

Sign in to practise: answers are saved before model answers are shown.