<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jlteunissen on Medium]]></title>
        <description><![CDATA[Stories by Jlteunissen on Medium]]></description>
        <link>https://medium.com/@jlteunissen?source=rss-570fb38866f5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rj5Qn_l6LRWN8uPa-n2CaA.jpeg</url>
            <title>Stories by Jlteunissen on Medium</title>
            <link>https://medium.com/@jlteunissen?source=rss-570fb38866f5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:52:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jlteunissen/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Beyond the Cron: Reclaiming Your Data Intervals in Hybrid Scheduling]]></title>
            <link>https://medium.com/datamindedbe/beyond-the-cron-reclaiming-your-data-intervals-in-hybrid-scheduling-84706f6c8407?source=rss-570fb38866f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/84706f6c8407</guid>
            <category><![CDATA[cron]]></category>
            <category><![CDATA[idempotency]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[hybrid-scheduling]]></category>
            <category><![CDATA[backfill]]></category>
            <dc:creator><![CDATA[Jlteunissen]]></dc:creator>
            <pubDate>Tue, 09 Jun 2026 12:21:16 GMT</pubDate>
            <atom:updated>2026-06-09T12:21:16.608Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ngl4BO9bDkLjdd4KwyAv8A.jpeg" /></figure><p>Many data pipelines are either on a time schedule <strong><em>or</em></strong> triggered by events. Events are ideal for maximum data freshness, but are unpredictable. Time-based scheduling is 100% predictable, but between intervals, data might not be the most up-to-date.</p><p>In hybrid scheduling you do run your data pipeline on both a cron schedule and on events. Let us consider situations in which a hybrid schedule might be useful. Events are often the primary driver, say multiple times per hour, and a daily schedule acts as a safety net. In the last example the schedule is the backbone, and events only occasionally accelerate it.</p><h3>Examples</h3><h3>1) Batch and event sources</h3><p>The majority of data is ingested in near real-time via events, but another source with corrections doesn’t emit events. Dashboards update within minutes but data adjustments arrive in batch files. A hybrid approach keeps dashboards current throughout the day, while a nightly scheduled can absorb corrections.</p><h3>2) Silent upstream failures</h3><p>A pipeline ingests external data through file drops. When the export job crashed silently, the event-driven pipeline has nothing to trigger on, so it sits idle and the SLA is missed. Downstream jobs start from outdated data and nobody notices. A scheduled morning run can be the safety net: regardless of whether events fired, ensuring the SLA is met even if the events stopped overnight.</p><h3>3) Cost optimisation</h3><p>Your transformation is expensive. So, events trigger lightweight incremental work like appending to a staging table or refreshing a counter while a nightly scheduled run performs the expensive full recompute: consistency checks, deduplication, model retraining. This hybrid setup gives freshness when it matters, but with controlled compute cost.</p><h3>4) Backfill-friendly by design</h3><p>Your pipeline runs almost entirely on events and works well day-to-day. Then someone discovers a bug in a transformation that has been producing wrong results for the past two weeks. You need to reprocess weeks of data. Replaying weeks of events is painful. Events may no longer be available, or replaying them out of order produces different results. A cron schedule alongside the events gives you clean, non-overlapping time intervals that you can simply clear and rerun. The backfill walks through each interval in order, reprocesses the data that was available at that time, and produces deterministic output.</p><p>The schedule may not add much during normal operations. Its value shows up the moment something goes wrong and you need to go back in time.</p><h3>5) Scheduled backbone with occasional event acceleration</h3><p>Your pipeline joins data from multiple sources that each land on their own rhythm — some hourly, some daily. An hourly schedule is the backbone: it picks up whatever is new across all sources and produces a consistent joined output.</p><p>Once or twice a day, one particular source emits an event that signals high-priority data has landed (a corrected export, a critical upstream refresh). An event trigger kicks off the same pipeline ahead of the next scheduled hour, so the high-priority update is available sooner.</p><p>The schedule guarantees regular, predictable processing. The rare event trigger is an accelerator, not the primary driver.</p><h3>Same DAG, different work</h3><p>If event runs and scheduled runs do different things, why keep them in the same DAG?</p><p>The short answer: because they write to the same output. Two separate DAGs writing to the same table means coordinating write conflicts and duplicating downstream dependencies. A single DAG avoids all of that. The trigger type changes what work is done, not where the result lands.</p><p>In practice the branching is straightforward. An event-triggered run might do a lightweight incremental append. A scheduled run might do a full scan, deduplication, or a MERGE that reconciles the incremental writes from the past interval.</p><p>In dbt, this maps naturally to an incremental model. The event path appends only the changed rows. The scheduled path processes the full cron interval:</p><pre>{{<br>    config(<br>        materialized=&#39;incremental&#39;,<br>        unique_key=&#39;id&#39;<br>    )<br>}}<br><br>SELECT * FROM {{ source(&#39;raw&#39;, &#39;orders&#39;) }}<br><br>{% if is_incremental() %}<br>    {% if var(&quot;run_type&quot;) == &quot;event&quot; %}<br>        WHERE updated_at &gt; &#39;{{ var(&quot;last_event_ts&quot;) }}&#39;<br>    {% else %}<br>        WHERE updated_at &gt;= &#39;{{ var(&quot;data_interval_start&quot;) }}&#39;<br>          AND updated_at &lt;  &#39;{{ var(&quot;data_interval_end&quot;) }}&#39;<br>    {% endif %}<br>{% endif %}</pre><p>Both paths produce the same table, so downstream consumers do not need to know which trigger fired.</p><h3>Intervals</h3><p>With mixed triggers on one DAG, interval semantics gets interesting. Scheduled runs have a natural interval defined by the cron expression. Event-triggered runs do not, they fire whenever something happens, and two events can arrive seconds or days apart.</p><p>Still, event-triggered runs can benefit from a well-defined <em>pseudo-interval:</em> a start and end timestamp you define explicitly.</p><p>Why define a pseudo-interval for event runs?</p><ol><li>Event-driven DAGs might do interval-shaped work (incremental MERGEs, deletes+inserts, partition overwrites). A stable interval boundary makes the work repeatable: retrying the same run produces the same writes.</li><li>Without an interval, processing the last changes can all of a sudden scan everything since forever. A pseudo-interval limits the amount of data an event run is allowed to touch.</li><li><strong>I</strong>t is much easier to reason about correctness when every run only concerns a specific time interval. This also improves metrics (freshness/lag) and incident response.</li><li>No need for runtype-specific logic. All runs process a well-defined interval with set start and end date.</li></ol><p>In a hybrid DAG, you can think of event triggers as “requesting an early recomputation for the <em>current</em> scheduled interval”. The pseudo-interval makes that request explicit.</p><p>Let’s consider how we can consolidate the lack of a well-defined interval for events in hybrid runs.</p><p>Consider a DAG with a 4-hour cron schedule and occasional event triggers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fYJuQZ3tYNqc9NYL6zxfpA.jpeg" /></figure><p>The cron-runs tile cleanly: 00:00–04:00, 04:00–08:00, and so on. The event runs at 06:23 and 06:45 both fall inside the 04:00–08:00 window. I see two options for defining an interval for events. In both cases the event timestamp is treated as the end of the interval, while the start of the interval can either be defined as:</p><ol><li>The interval end of the previous run. This sounds intuitive but can be tricky as you need to do a lookup in your schedulers database to obtain the metadata of the previous run. (Which is noticeably difficult in Airflow 3 with workers not having access to the metadata database anymore)</li><li>Use the timestamp of the most recent <strong>scheduled</strong> run as the start of the interval. This is always well-defined if you know the cron schedule and no knowledge of previous runs is required.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q7wmpCDggf3MtLOJ6sKDSA.jpeg" /><figcaption>option 1. non-overlapping intervals for event-triggered runs.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rttrBLiS0up5ZiOKE4wAzg.jpeg" /><figcaption>option 2. overlapping intervals. Each event based run, uses the previous cron boundary as start of the interval</figcaption></figure><p>In the end, both can work. What is important is that the <strong>scheduled</strong> runs always keep there original interval, irrespective of whether there were events during its interval or not. Why this matters especially is backfills.</p><h3>Backfills</h3><blockquote>At some point, if you work in data, whether you’re an analyst or a data engineer. You’re going to have to do it. You’re going to have to backfill a table.”</blockquote><blockquote><em>SeattleDataGuy on </em><a href="https://seattledataguy.substack.com/p/backfills-the-necessary-evil-of-data"><em>https://seattledataguy.substack.com/p/backfills-the-necessary-evil-of-data</em></a><em>)</em></blockquote><p>Backfilling purely event-based DAGs presents a significant challenge because they lack these fixed temporal anchors. Since event-based triggers are reactive and asynchronous, there is no inherent “window” to look back on; the DAG only knows to run when a signal arrives. Backfilling the whole month at once might be infeasible with current compute and memory settings. Without the rigid structure of a cron schedule, it becomes difficult to guarantee that no events were missed, to prevent duplicate processing of the same event, or to define where one “run” ends and the next begins during the recovery process. This often forces one to enable temporarily one-off solutions or convert the event-based logic into a batch-based process just to handle the backfill.</p><p>Backfilling is fundamentally designed for cron-based runs. In a cron-based system, the timeline is partitioned into fixed, predictable slots (e.g., daily or every four hours). If a pipeline fails or a new logic requirement emerges, you can reliably “re-run” specific historical windows because the boundaries of those windows are predefined and immutable. Backfilling here is simply the act of forcing the scheduler to execute these missed or updated slots in chronological order to ensure data consistency across the entire history. For this reason, when doing a backfill in Airflow, only the cron-triggered runs are rescheduled. The Airflow grid below shows what this looks like in practice. One DAG had scheduled, dataset-triggered, and manual runs side by side. When Initiating a backfill, only the scheduled runs are rescheduled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/194/1*6fIezO2W5mzsNIo5JX8D9w.jpeg" /><figcaption>Representation of an airflow DAG run with 3 tasks. ▶ = manual run, ⛁ = asset triggered run (event). Without symbol = scheduled runs. ⟲ = rescheduled (here by initiating a backfill)</figcaption></figure><p>So to do a proper backfill, scheduled intervals should fully cover the time range. If the schedule only runs daily but you need hourly granularity for a backfill, the schedule is too coarse.</p><h3>how it all looks in airflow</h3><p>In Airflow 3, hybrid scheduling is straightforward to setup.</p><pre>from datetime import datetime<br>from airflow.sdk import DAG<br>from airflow.timetables.assets import AssetOrTimeSchedule<br>from airflow.timetables.interval import CronDataIntervalTimetable<br><br># Assuming &#39;assets&#39; is a list of Asset objects defined elsewhere in your code<br># assets = [Asset(&quot;uri_to_resource&quot;)]<br><br>with DAG(<br>    dag_id=&quot;example_asset_or_time&quot;,<br>    start_date=datetime(2026, 1, 1),<br>    schedule=AssetOrTimeSchedule(<br>        timetable=CronDataIntervalTimetable(&quot;6 0 * * *&quot;, timezone=&quot;UTC&quot;),<br>        assets=assets,<br>    ),<br>) as dag:<br>    ...</pre><p>Side note: in Airflow 3, there was a behavioural change in logical_date compared to Airflow 2. If you rely on classic interval semantics -- where logical_date equals the start of the interval, not the trigger time -- you need to be explicit. What is needed it to wrap your cron expression in a CronDataIntervalTimetable object. See <a href="https://airflow.apache.org/docs/apache-airflow/stable/installation/upgrading_to_airflow3.html">Upgrading to Airflow 3</a></p><p>To set the start interval for event triggered runs to the end of the previous cron interval we can leverage the croniter package.</p><pre>from croniter import croniter<br>import os<br>from datetime import datetime<br><br>data_interval_end = {{ ( dag_run.data_interval_end or dag_run.logical_date or dag_run.run_after ) | ts }}<br>data_interval_start = croniter(cron_expression, data_interval_end).get_prev(datetime)</pre><h3>Final thoughts</h3><p>Hybrid scheduling is a powerful pattern, but it is not a universal solution. Before adopting it, verify:</p><ul><li>Do events provide meaningful freshness gains over the schedule alone?</li><li>Can your transformation logic cleanly branch on trigger type, or would it become unmaintainable?</li><li>Is your schedule coarse enough to support backfills when things go wrong?</li><li>Does Airflow 3’s explicit interval semantics fit your data model?</li></ul><p>If the answer to most of these is yes, hybrid scheduling can provide value.</p><p>Data pipelines come in large variety. <strong>Have you encountered other use cases where hybrid scheduling makes sense?</strong> If you have seen hybrid scheduling solve a problem outside these examples, or hit a wall trying to implement it, we would love to hear about it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84706f6c8407" width="1" height="1" alt=""><hr><p><a href="https://medium.com/datamindedbe/beyond-the-cron-reclaiming-your-data-intervals-in-hybrid-scheduling-84706f6c8407">Beyond the Cron: Reclaiming Your Data Intervals in Hybrid Scheduling</a> was originally published in <a href="https://medium.com/datamindedbe">Dataminded</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>