One Pipeline, Three Clocks: What Each Extra Hour Buys
“How long will it take?”
It’s the most common question in data engineering, and almost nobody answers it honestly. Not because we’re liars (mostly), but because the question should be how long will it take to make it good?
A data pipeline isn’t done or not done. It sits somewhere on a slider between “it ran once on my laptop” and “it survives a bad Tuesday without waking anyone up.” Every hour you spend moves the slider. The trouble is that we rarely look at the slider. We pick a position by habit. Some of us always gold standard. Some of us always ship the hack and promise to come back to it (we don’t come back to it).
So let’s make the slider visible. Take one Snowflake pipeline and build it three times, using the same data to answer the same question, with three different budgets:
- One hour.
- One day. Eight hours.
- One week. Five eight-hour days.
Then throw the same set of rocks at all three and see what breaks.
The point isn’t to crown a winner. Each one is the right answer to some problem. The point is to see exactly what each extra hour buys, so the next time someone asks “how long will it take?” you can answer with a menu instead of a guess.
The rules
A comparison where everything changes at once proves nothing, so most of it stays fixed.
The question never changes: how did yesterday’s weather in each city compare with normal for that date? It’s small enough to build in an hour. It also has enough hidden traps (time zones, revisions, history) to fill a week. It is also data everyone can relate to.
The data never changes. Everything comes from Open-Meteo, a free weather API. It needs no key, no account and no credit card. I want anyone to be able to reproduce this, not just people with an enterprise data licence. Its data is licensed CC BY 4.0, and the free tier covers non-commercial use up to 10,000 calls a day. Long date ranges count as more than one call, so the 30-year history is the expensive download, but even that fits inside a day’s allowance. You can check you have access by pasting a URL into a browser. That’s a lower bar to entry than most internal data sources I’ve worked with.
The cities never change: Melbourne, Sydney, London, Edinburgh and New York. Swap in your own if you’re following along.
The platform never changes: a free Snowflake trial. One gotcha is worth knowing before you start, because it can cost you half an hour. Snowflake trial accounts don’t get external network access. Snowflake can’t call the API itself. Every build fetches data outside Snowflake and pushes files in. That’s how most real ingestion works anyway, so I’m calling it a feature.
The clock is strict. An hour means sixty minutes, not “about an hour”. Hofstadter’s Law says it always takes longer than you expect, even when you take Hofstadter’s Law into account, so each build comes with a note on where it usually runs over.
No AI co-pilot. The budgets assume every line is typed by hand, with docs and search allowed but no Claude Code, no Cortex and no autocomplete agent.
The hour: make it work
Here’s how the hour is spent:
| Minutes | Step |
|---|---|
| 0–5 | Create a database, a stage and a raw table |
| 5–15 | Download two JSON files in a browser: the last 7 days, and 30 years of history for “normal” |
| 15–25 | Upload them to the stage and COPY INTO the raw table |
| 25–40 | Flatten the JSON into rows |
| 40–50 | Write the query that answers the question |
| 50–60 | Write down what’s broken |
The only clever bit is the flatten. Open-Meteo returns parallel arrays: one array of dates, one of max temperatures, one of rainfall, all lined up by position. You flatten the date array and use its index to pluck the matching value out of every other array:
SELECT
ci.name,
d.value::DATE AS weather_date,
c.value:daily:temperature_2m_max[d.index]::FLOAT AS temp_max_c,
c.value:daily:precipitation_sum[d.index]::FLOAT AS precip_mm
FROM
raw_weather r,
LATERAL FLATTEN(input => r.payload) c, -- one element per city
LATERAL FLATTEN(input => c.value:daily:time) d, -- one element per day
cities ci
WHERE
ci.city_idx = c.index; -- city = position in the URL
Then one query joins yesterday onto the 30-year average for the same calendar day. Fifty minutes in, you have an answer: how far each city sat above or below normal yesterday.
It’s a terrible pipeline, but it’s a pipeline.
The outcome
The last ten minutes are the most valuable part of the hour. That’s where you write down what you skipped, while you still remember skipping it:
- “Yesterday” is wrong for most cities. It uses the session’s time zone, not Melbourne’s or New York’s.
- City names depend on the order of coordinates in a URL. Reorder the URL and Sydney becomes London, without an error. (Open-Meteo does send back a
location_id, but it’s just the position in the URL, and it’s left out for the first city.) - Refreshing means repeating every step by hand. You are the scheduler.
- A second download duplicates seven days of data, because the windows overlap.
- No tests, no history, no version control.
If the hour runs over, it’s usually in the flatten. The parallel-array trick rarely works first time, and matching yesterday to the same calendar day across thirty years means deciding what to do with 29 February.
Here’s the thing, though. None of that makes the hour build wrong. If someone asks a one-off question on a Thursday afternoon, the hour build is the correct engineering decision. Spending a week would be the mistake. The hour build is also how you find out whether a data source is worth a day before you commit the day. It only becomes a problem when it quietly turns into something people depend on, and nobody goes back to rebuild it.
The day: make it trustworthy
Eight hours. This build costs eight times as much as the first. So the question for every one of those hours is: what does it buy that the first hour didn’t?
The answer turns out to be neat. Almost every hour of the day build pays off one specific line from the hour build’s outcome.
| Hours | Work | Pays off |
|---|---|---|
| 1 | A service user with key-pair auth; separate raw and analytics schemas | “You are the scheduler” (machines can’t do MFA prompts) |
| 2–3 | A Python ingest script: one request per city, each response wrapped with its location_id | “City names depend on URL order” |
| 4–6 | A dbt project with tests: staging, normals, an incremental fact table and a mart | “Duplicates”, “Yesterday is wrong” and “No tests” |
| 7 | GitHub Actions on a daily cron | “You are the scheduler” |
| 8 | Delete the clone, re-clone, follow only the README | Proving someone else could run it |
Three of those fixes are worth a closer look, because they’re the kind of thing that separates “works” from “works when you’re not watching.”
The location travels with the data. The ingest script doesn’t trust position anymore. It wraps every API response in an envelope that carries the city’s own ID, not its position, before it ever touches Snowflake:
body = {"location_id": c["location_id"], "endpoint": mode,
"requested_at": run_ts, "response": r.json()}
That’s a one-line change. It removes a whole class of silent error, the kind where nothing fails and the numbers are simply wrong.
“Yesterday” is computed in each city’s own time zone. Open-Meteo tells you which time zone each response is in, so the staging model can work out whether a date is still in that city’s future:
d.value::date >= convert_timezone(r.payload:response:timezone::string,
r.loaded_at)::date as is_forecast
Reruns are idempotent at two levels. Snowflake’s COPY INTO keeps load metadata, so a file it has already loaded gets skipped. Then the fact table merges on a key, and the latest load wins:
{{ config(materialized='incremental', unique_key='weather_key',
incremental_strategy='merge') }}
...
qualify row_number() over (partition by location_id, weather_date
order by loaded_at desc) = 1
Run it twice by accident and nothing happens, which is exactly what should happen.
The tests are deliberately boring: unique and not-null keys, and two singular SQL tests. One checks that temperatures are physically plausible. The other checks that every city has recent data. I’d leave test packages out on purpose. Built-in tests and plain SQL files work across dbt versions, and an eight-hour budget has no room for a dependency argument. (If you’ve ever lost an afternoon to a package version clash, you know exactly which hour I’m protecting.)
Scheduling is GitHub Actions on a cron. It’s free, and it lives in the repo next to the code. That said, it has two quirks. Scheduled runs can start late. On public repos, they pause after 60 days without activity.
The outcome
Hour eight is my favourite. You delete everything local, clone the repo fresh, and follow only the README. Whatever you have to work out from memory is a gap in the README. The first clean run nearly always finds something: an environment variable nobody wrote down, a grant that only exists on your own user, a Python version the README never mentions.
Eight hours is tight. When it runs over (and it likely will find problems), it’s usually machine identity: key-pair auth in the first hour, and getting the private key into GitHub Actions in the seventh.
Then the outcome. What the day build still doesn’t do:
- Revisions overwrite history. Last Tuesday’s value is whatever Tuesday looks like now.
- Bad data lands before the tests catch it. dbt will refuse to build the mart on a failed test, but the fact table already holds the bad row.
- If the pipeline doesn’t run at all, nothing tells you. A freshness test can only fail when something runs it.
- There are no cost guardrails.
That third bullet is the one that should make you stressed. The day build fails loudly when it runs and fails. It says nothing at all when it doesn’t run. In my experience, most pipelines in production sit at about this level. That’s fine right up until the morning someone notices the dashboard hasn’t changed in a week.
The week: make it survive
Forty hours. That’s five times the day build, or forty times the hour.
Almost none of the week changes the answer to the question. Friday’s mart says much the same thing as the day build’s mart. Every hour of the week goes into what happens around the answer. What happens when the data changes? When something breaks? When nobody’s watching? When you hand it to someone else?
One change to the source makes the week worth building. The daily call now asks for 7 past days and the maximum 16 forecast days, up from the default 7. That means a value for any given date gets revised every day for more than three weeks, from a 16-day forecast down to the final observation. Suddenly the dataset has history worth keeping, and the pipeline has to decide what to do with it.
Monday: hardened ingestion
Monday adds retries with backoff and failure isolation per city. One city’s 503 no longer takes down the other four. A failed response goes to a dead-letter table. Every response is validated before it loads: the expected keys exist, every requested variable is present, and every array is as long as the date array. A run manifest records every run, including the ones that fail.
It’s dull work. It’s also the difference between “something went wrong” and “Edinburgh returned a 503 at 07:17 and the other four cities loaded fine.”
Tuesday: history you can rebuild
Raw keeps every daily file, so history doesn’t need a snapshot. It can be a model built from raw:
-- one row per change in value, rebuilt from scratch on every full refresh
select
location_id,
weather_date,
temp_max_c,
temp_min_c,
precip_mm,
weather_date - as_of_date as lead_days,
loaded_at as valid_from,
lead(loaded_at) over (partition by location_id, weather_date
order by loaded_at) as valid_to
from
flagged
where
prev_hash is null
or
prev_hash <> row_hash
This is the Healing Tables idea. If you can drop your history table and rebuild it byte-for-byte from raw, history stops being something you protect and becomes something you can regenerate. The proof is two HASH_AGG queries, one either side of a full refresh. They have to match. If they don’t, something in the history logic depends on load order or the clock, and that’s worth finding before anyone relies on it.
It also answers a question the day build can’t touch: what did we think Tuesday would be, as of Monday? That becomes a forecast-accuracy mart, which is a nice bonus for a pipeline that was only meant to say “warmer than normal.”
Wednesday: Write-Audit-Publish
Readers only ever see the ANALYTICS schema. Every run builds into an ANALYTICS_AUDIT schema, which starts as a zero-copy clone of prod. The run gets audited, and only then is it published:
CREATE OR REPLACE SCHEMA ANALYTICS_AUDIT CLONE ANALYTICS; -- write
-- dbt build --target audit; then run the audit queries -- audit
ALTER SCHEMA ANALYTICS SWAP WITH ANALYTICS_AUDIT; -- publish
The audits go beyond dbt tests. Did a city vanish? Is the row count inside the expected band? Did any observed value older than seven days change? Only the revision window is allowed to move. If any check fails, there’s no swap. Readers keep yesterday’s good data, and the bad build sits in the audit schema for you to inspect. I’ve covered the pattern in more depth for general pipelines and for Iceberg tables in Snowflake.
There’s also a bonus you don’t have to plan for. After a swap, the audit schema holds the previous prod, so rolling back a bad publish is one more swap. That takes seconds.
One gotcha, a view that references another model in the swapped schema will point at the wrong schema after the swap. Keep views reading only from raw, or make them tables.
Thursday: Don’t Go Dark
This is the day that answers the day build’s most uncomfortable output line: if it doesn’t run, nothing tells you.
The fix is to monitor from outside the thing being monitored. A Snowflake alert runs on its own schedule, independent of GitHub Actions. Every morning it checks a health view. When was the last publish? Is any city missing? Did any tests fail? If something’s wrong, it sends an email:
CREATE ALERT OPS.PIPELINE_DARK
WAREHOUSE = PIPE_WH
SCHEDULE = 'USING CRON 0 9 * * * Australia/Melbourne'
IF (EXISTS (SELECT 1 FROM OPS.V_PIPELINE_HEALTH
WHERE hours_since_publish > 26 OR cities_missing > 0 OR failed_tests > 0))
THEN CALL SYSTEM$SEND_EMAIL('pipe_email', 'you@example.com',
'Weather pipeline has gone dark', 'See OPS.V_PIPELINE_HEALTH');
A pipeline that reports its own health can only report the failures it survives to see. I’ve written before about engineers going dark, when good work goes silent and nobody knows to ask. Pipelines do exactly the same thing, and the fix is the same: make the silence itself visible.
Thursday afternoon covers cost. A resource monitor notifies at 75% of a monthly credit quota and suspends the warehouse at 100%. A 600-second statement timeout kills runaway queries. Every step carries a query tag so the health view can show where the credits went.
Friday: hand it over
Friday is roles, CI and runbooks. There’s a loader role that can only write raw, a transformer role that owns analytics, and a reader role that can only select. Pull requests build into a throwaway clone. A runbook covers the five things that will eventually go wrong. The best entry is the shortest one: missed a day? Do nothing. The seven-day lookback heals gaps of up to a week on its own.
Friday also runs one deliberate experiment. A while back I argued that most “we need real-time” requests actually need faster batch. Friday tests that, cheaply. A dynamic table reads raw with TARGET_LAG = '1 day'. Then you turn the dial down to '1 minute' and watch what happens. The source changes once a day, so the minute-level lag buys nothing at all. It barely costs anything either, because Snowflake only wakes the warehouse when the source has actually changed. All that runs every minute is a cheap metadata check.
That’s the cheapest lesson in the week. What real-time costs depends on how often your source changes. Point the same dial at a source that changes every few seconds and the warehouse never gets to sleep. Either way, the right setting comes from the business need, not from how much time you happen to have.
The output
Friday is where the week runs over. Roles, CI, a runbook and the dynamic table experiment don’t all fit into one day, so budget for the week to take closer to six days.
Throwing rocks
Building three pipelines proves nothing on its own. Breaking them does. Here are the same six failures thrown at all three builds, and what each build should do:
| Failure | How it’s injected | 1 hour | 1 day | 1 week |
|---|---|---|---|---|
| Duplicate load | Load the same day twice | Fails | Passes | Passes |
| Missed runs | Disable the schedule for two days | Fails, silently | Silent until the next run | Alert at 09:00, self-heals |
| A value of 999°C | Insert a bad row into raw | Reaches the answer | Test fails, but the bad row is already in the fact table | Audit blocks the publish |
| “What did we know on Monday?” | Query a past forecast | Can’t | Overwritten | Answered |
| Source drift | Drop a variable from the request | Silent nulls | Silent nulls | Dead-lettered, alert fires |
| Cost spike | A runaway cross-join | Runs until it’s stopped | Runs until it’s stopped | Killed at 600 s |
Those are the outcomes each design predicts. If you build along and break things for real, the cells where reality disagrees with the table are the interesting ones.
What the time actually bought
Start with the price list:
| Build | Hours | Cost vs the hour | What the extra hours bought |
|---|---|---|---|
| The hour | 1 | 1× | An answer |
| The day | 8 | 8× | An answer you can trust and someone else can run |
| The week | 40 | 40× | An answer that tells you when it’s wrong, keeps its history, and survives you leaving |
The first hour buys almost everything the reader of the mart will ever see. The next seven buy trust. The 32 after that buy things nobody notices until the day they’re missing. That’s a steep curve of diminishing visible returns, and it’s exactly why the week is so hard to justify in a planning meeting.
Now look at the rocks table again, but read it by kind of failure rather than by build.
The step from one hour to one day fixes the visible failures: duplicates, wrong dates, swapped city names. These are errors someone eventually notices, because the numbers look wrong.
The step from one day to one week fixes the silent failures: the run that never happened, the bad value that slipped through, the history that got overwritten, the column that turned to nulls without an error. Nobody notices these until they’ve already made a decision on the bad number.
That’s the real shape of the slider. Extra time doesn’t make a pipeline better in the abstract. It buys protection against failures that haven’t happened yet. Whether that’s worth buying depends on two things: how likely the failure is, and how much it costs when it lands.
So when someone asks how long it’ll take, here are the questions I’d ask back:
- Who depends on it? If the answer is “just me, once,” that’s the hour. If a team checks it every morning, it’s at least the day.
- What does a wrong number cost? Mild embarrassment points one way. A regulatory submission points the other.
- How would you find out it broke? If the honest answer is “someone would tell us eventually,” you’re one silent failure away from finding out the hard way.
- Will anyone ask what it said last month? If yes, history isn’t optional, and history built in later is much harder than history built in from the start.
- How long will it live? One-off pipelines don’t need runbooks. Pipelines that outlive their author do.
None of these questions are about the technology.
The tradeoff
The week build isn’t free after the week, either. It has more moving parts, which means more to maintain, more to explain to the next person, and more to break. An alert that fires on a Saturday is a feature right up until it’s your Saturday.
The hour build isn’t free either. It costs nothing up front, and then one day it costs everything at once.
The thing to watch for is the promotion without a rebuild. That’s the hour build that got scheduled because it was useful, then shared because it was scheduled, then depended on because it was shared. Nobody ever went back and spent the day. The output from that first hour is still true. It’s just that nobody’s reading it anymore.
When the pipeline’s job changes, check whether its budget did too.
Weather data by Open-Meteo.com (CC BY 4.0).
