Open lesson

Mission: should we rent an army of machines?

Command palette

This mission workspace keeps code and notes in this browser tab. Export them before closing it. Running code is practice, not an automatic grade for the mission.

Brief

Choose a tool for a specific job using equal answers, duration, memory, and explicitly estimated cost.

Voss wants a large cluster immediately to announce Hidden Depot. Mara hands you two fictional measurement sheets, while Imani insists T2 and T3 stay linked to the correct D7 version. Recommend a tool for the 2 GB copy and a decision method for full volume before the story's meeting. This exercise has no timer.

Your mission

  1. Compare the four join results from DuckDB and Spark.
  2. Calculate both medians and their ratio, and note peak memory.
  3. Calculate compute cost at the fictional €0.12/minute with a one-minute minimum.
  4. Choose a tool for the copy and give three measurements needed before an optional move to a cluster.

How to check your work

  • Same four time-aware pairs, no false duplicates.
  • 18 s versus 54 s, ratio 3; fictional peaks 1.4 versus 3.2 GB.
  • €0.12 compute under the stated assumption, not a real quote.
  • DuckDB for the copy; decide full volume after time, memory, disk, and cost measurements.

Course example

WITH trips(trip_id, depot_id, event_min) AS (
    VALUES ('T1', 'D7', 1170), ('T2', 'D7', 1285),
           ('T3', 'D7', 1300), ('T4', 'D8', 1310)
), depots(depot_id, name, valid_from, valid_to) AS (
    VALUES ('D7', 'North Yard', 0, 1200),
           ('D7', 'Hidden Depot', 1200, 1440),
           ('D8', 'South Yard', 0, 1440)
)
SELECT t.trip_id, d.name
FROM trips AS t
LEFT JOIN depots AS d
  ON t.depot_id = d.depot_id
 AND t.event_min >= d.valid_from
 AND t.event_min < d.valid_to
ORDER BY t.trip_id;

Code

Use Tab to leave the editor. Ctrl+Enter runs the source. The lines beginning with -- are task reminders. SQL ignores them. Write your query beneath them.

SQL console

Loading laboratory…

Explore Python or SQL here; this is not an operating-system shell.

This is a disposable browser experiment. The code run here is not recorded as a completed mission.

Each command starts a fresh disposable worker: it runs a captured copy of your current source, then your command with the lesson fixtures. Changes are discarded afterward. Commands never save source or award XP. Ctrl+Enter executes the command.

Virtual workspace files

Source and declarative assets are readable here without JavaScript. Python input files are created at runtime; SQL setup initializes the disposable database.

source.sql

Current editor source. Inspection shows your current edits.

-- Compare the four join results from DuckDB and Spark.
-- Calculate both medians and their ratio, and note peak memory.
-- Calculate compute cost at the fictional €0.12/minute with a one-minute minimum.
-- Choose a tool for the copy and give three measurements needed before an optional move to a cluster.

exemple.sql

Declarative lesson asset; this is not a file created in the Python filesystem.

WITH trips(trip_id, depot_id, event_min) AS (
    VALUES ('T1', 'D7', 1170), ('T2', 'D7', 1285),
           ('T3', 'D7', 1300), ('T4', 'D8', 1310)
), depots(depot_id, name, valid_from, valid_to) AS (
    VALUES ('D7', 'North Yard', 0, 1200),
           ('D7', 'Hidden Depot', 1200, 1440),
           ('D8', 'South Yard', 0, 1440)
)
SELECT t.trip_id, d.name
FROM trips AS t
LEFT JOIN depots AS d
  ON t.depot_id = d.depot_id
 AND t.event_min >= d.valid_from
 AND t.event_min < d.valid_to
ORDER BY t.trip_id;