<?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 Maurizio Mammuccini on Medium]]></title>
        <description><![CDATA[Stories by Maurizio Mammuccini on Medium]]></description>
        <link>https://medium.com/@mauriziomammuccini?source=rss-d9f897922c0d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*w6L6wXFVenfnd11I</url>
            <title>Stories by Maurizio Mammuccini on Medium</title>
            <link>https://medium.com/@mauriziomammuccini?source=rss-d9f897922c0d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:01:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mauriziomammuccini/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[From Hive to Azure SQL with Azure Data Factory]]></title>
            <link>https://medium.com/@mauriziomammuccini/from-hive-to-azure-sql-with-azure-data-factory-81d1a505fec7?source=rss-d9f897922c0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/81d1a505fec7</guid>
            <category><![CDATA[hive-connector]]></category>
            <category><![CDATA[apache-hive]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[azure-data-factory]]></category>
            <category><![CDATA[azure-hdinsight]]></category>
            <dc:creator><![CDATA[Maurizio Mammuccini]]></dc:creator>
            <pubDate>Sat, 28 Nov 2026 11:02:05 GMT</pubDate>
            <atom:updated>2026-11-28T11:12:28.053Z</atom:updated>
            <content:encoded><![CDATA[<p>A Copy Data pipeline to transfer a Hive table to Azure SQL Database</p><p>This guide presents a simple transfer from one Hive table on Azure HDInsight 5.1 to an Azure SQL Database table. The pipeline uses a single Copy Activity: it reads data from the source and writes it to the sink, without launching a Hive job to transform it. The Copy Activity can read a table or use a Hive query as its source.</p><blockquote><strong>The pipeline pattern described in this article assumes that a Hive source table has already been created and registered in the Hive metastore, with its data accessible to the HDInsight cluster.</strong></blockquote><p><strong>Solution architecture</strong></p><p>The Azure Data Factory Hive connector supports Hive tables on Azure HDInsight 4.0 or later. Support for HDInsight 4.0 ended on March 31, 2025; for a new example, HDInsight 5.1 is the reference version, and Microsoft lists it as supported. The scope of this article is therefore the ADF connector to Hive on HDInsight, not every Hive installation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*7q4DNLm2QBuQjwQYALRw4A.png" /><figcaption>Figure 1. Data movement architecture</figcaption></figure><p><strong>Configuring connectivity and linked services</strong></p><p>A linked service defines connection parameters. Create one for Hive and one for Azure SQL Database. For Hive, configure the host, port, server type, and authentication. Store credentials securely, for example, in Azure Key Vault. Before building the pipeline, test the connection and verify that the account has permission to access the source table. The Integration Runtime choice depends on the network. Use the Azure Integration Runtime when the service is reachable over a public network. For a private source, such as one in a virtual network or on-premises, configure a Self-hosted Integration Runtime (SHIR) that can reach it. With Hive connector version 2.0, SHIR must be version 5.54 or later. For Azure SQL, allow Azure services in the firewall rules when using Azure IR; when using SHIR, authorize the IP address of the machine hosting the IR.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*gkP5IHUE367uwxUT1qRdVA.png" /></figure><p><strong>Structuring the pipeline</strong></p><p>In ADF Studio, create a pipeline and add a Copy Activity. In the Hive dataset, select the table to read; in the Azure SQL dataset, specify the destination. On the Mapping tab, check column names and data types. Automatic mapping may be sufficient when the schemas match; otherwise, define the column mappings explicitly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*avKAzHLmeUW_-y8ucpYp5Q.png" /><figcaption>Figure 2. Copy pipeline at a glance</figcaption></figure><p>For the initial load, create the Azure SQL table first and define columns with compatible data types. The sink inserts records by default, so subsequent runs append rows to the table. To reload the entire table, configure a pre-copy script, such as TRUNCATE TABLE or DELETE. The script runs once before each Copy Activity run; use it only after assessing its effect on existing data.</p><p><strong>Running and monitoring the transfer</strong></p><p>Run Debug to validate the configuration, then use Monitor to check the activity status, rows read and written, duration, and any errors. If problems occur, check network connectivity and firewall rules, credentials, the Hive port, and permissions on the source and destination. To keep the example focused, use scalar columns. The Hive connector does not support reading complex types such as arrays, maps, structs, and unions. Before loading, also check that Hive data types are compatible with the SQL column types.</p><p><strong>Microsoft references</strong></p><p>Copy data from Hive: <a href="https://learn.microsoft.com/azure/data-factory/connector-hive">https://learn.microsoft.com/azure/data-factory/connector-hive</a></p><p>Copy and transform data in Azure SQL Database: <a href="https://learn.microsoft.com/azure/data-factory/connector-azure-sql-database">https://learn.microsoft.com/azure/data-factory/connector-azure-sql-database</a></p><p>Azure HDInsight component retirements and action required: <a href="https://learn.microsoft.com/azure/hdinsight/hdinsight-component-retirements-and-action-required">https://learn.microsoft.com/azure/hdinsight/hdinsight-component-retirements-and-action-required</a></p><p><strong>About the Author</strong></p><p>I am an experienced Data Science Software Developer and AI Consultant with a strong background in designing, developing, and implementing Machine Learning, Deep Learning, and Artificial Intelligence solutions. Throughout my career, I have combined advanced software engineering expertise with a solid understanding of mathematical and statistical foundations to design intelligent, scalable, and effective data-driven systems. My professional activities span technical consulting, solution architecture, software development, and the practical application of AI technologies to complex business and technological challenges. Alongside my consulting work, I am deeply committed to technical education and professional development, helping individuals and organizations build expertise in Data Science, Machine Learning, Deep Learning, and Artificial Intelligence. I am also passionate about technical writing, knowledge sharing, and making complex scientific and technological concepts accessible without compromising their mathematical rigor or technical depth. My professional philosophy is grounded in three principles: scientific rigor, engineering excellence, and the effective communication of knowledge. You can read my LinkedIn profile here: <a href="https://www.linkedin.com/in/maurizio-mammuccini-a2313438/">https://www.linkedin.com/in/maurizio-mammuccini-a2313438/</a></p><p>Here you can find my latest published book (Italian Edition): <a href="https://www.amazon.com/Teoria-dellInformazione-Machine-Learning-Decisionali/dp/B0HP876ZH3/ref=sr_1_1">https://www.amazon.com/Teoria-dellInformazione-Machine-Learning-Decisionali/dp/B0HP876ZH3/ref=sr_1_1</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81d1a505fec7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ETL, ELT, and Airflow: Essential Data Pipeline Patterns]]></title>
            <link>https://medium.com/@mauriziomammuccini/etl-elt-and-airflow-essential-patterns-for-reliable-data-pipelines-f17d457eb469?source=rss-d9f897922c0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f17d457eb469</guid>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[apache-airflow]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Maurizio Mammuccini]]></dc:creator>
            <pubDate>Sun, 22 Nov 2026 05:15:53 GMT</pubDate>
            <atom:updated>2026-11-22T05:51:46.220Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>ETL, ELT, and Airflow: Essential Patterns for Reliable Data Pipelines</strong></h3><blockquote>A practical blueprint for modern data ingestion, transformation trade-offs, and reliable orchestration.</blockquote><p>Data pipelines turn information from operational systems — applications, databases, APIs, files, or streams — into datasets that can be used by analysts, data scientists, and business applications. ETL and ELT remain two core models in this process. The distinction is not limited to the order of the letters. It determines where transformations are performed, how data quality is governed, and the respective responsibilities of data warehouses, data lakes, and orchestration platforms such as Apache Airflow.</p><p><strong>ETL and ELT: The Operational Difference</strong></p><p>In an <strong>ETL</strong> (<em>Extract, Transform, Load</em>) flow, data is extracted from a source, transformed in a processing environment, and finally loaded into the analytical destination. In an <strong>ELT</strong> (<em>Extract, Load, Transform</em>) flow, data is first acquired and loaded into the destination platform — typically a cloud data warehouse or lakehouse — and is transformed afterward by using that platform’s computing capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lgFwIOE5vq6Sb77lvHE_ew.png" /><figcaption><strong>Figure 1. ETL and ELT operational comparison.</strong> The figure contrasts the two approaches by transformation timing, target platform, raw-data retention, and computing location.</figcaption></figure><p>ETL is common when transformations or filters must be applied before data reaches the target system, for example because of privacy requirements, format constraints, or destination database limitations. ELT is common when a warehouse provides elastic computing capacity and powerful SQL capabilities, while raw source data must remain available for future processing.</p><p><strong>Data Warehouses and Data Lakes: Two Destinations, Not Isolated Worlds</strong></p><p>A <strong>data warehouse</strong> stores structured and modeled data for analytics, reporting, and business intelligence. Its tables are generally cleaned, documented, and designed for known use cases such as monthly revenue, sales performance, customer churn, or inventory analysis.</p><p>A <strong>data lake</strong> stores data in more heterogeneous forms: CSV and JSON files, application logs, events, and semi-structured data. It is commonly organized into layers:</p><ul><li><strong>Raw or Bronze</strong>: data acquired with minimal transformation and kept close to the source.</li><li><strong>Clean or Silver</strong>: validated, normalized, and deduplicated data.</li><li><strong>Business or Gold</strong>: datasets and metrics ready for analytical consumption.</li></ul><p>In modern architectures, the boundary is less rigid. A lakehouse combines the flexibility of a data lake with warehouse-style capabilities such as transactions, schema management, and efficient SQL querying. The key separation remains the distinction between ingestion, transformation, and publication.</p><p><strong>Airflow: Orchestration Rather Than Large-Scale Transformation</strong></p><p>Apache Airflow is an orchestrator. It defines dependencies between activities, schedules executions, manages retries, and exposes pipeline status through DAGs (<em>Directed Acyclic Graphs</em>). A DAG can coordinate a Spark job, a SQL query in a warehouse, a transfer to object storage, and a quality validation. Airflow workers are not generally intended to process large data volumes directly. Compute-intensive work is delegated to platforms designed for that purpose.</p><p>A typical flow is:</p><pre>extract → land_raw → validate → transform → publish → quality_check</pre><p>The following simplified DAG makes these dependencies explicit. The functions represent calls to external systems such as APIs, storage services, warehouses, or transformation engines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mml14P3uQ3yGfWc_uCRSog.png" /><figcaption><strong>Figure 2. Airflow DAG for an orders pipeline.</strong> The simplified DAG coordinates extraction, validation, transformation, publication, and data-quality checks.</figcaption></figure><p>In an ETL model, transform runs before loading into the final analytical destination. In an ELT model, ingestion loads data into the lake or warehouse first, while transform runs afterward.</p><p><strong>Pattern 1: Incremental Ingestion and Idempotency</strong></p><p>Pipelines rarely need to reload their complete history during every execution. The standard pattern consists of an initial load followed by incremental updates.</p><p>A basic approach uses a <strong>watermark</strong>, such as the timestamp of the latest successfully processed record. Each run retrieves only records changed after that point. More advanced scenarios use CDC (<em>Change Data Capture</em>) or transaction logs.</p><p>The most important requirement is <strong>idempotency</strong>: rerunning a task must produce the same outcome without duplicates or data corruption. Common techniques include:</p><ul><li>writing to a temporary table or directory followed by atomic publication;</li><li>MERGE statements or upserts based on business keys;</li><li>partitioning by processing date;</li><li>explicit tracking of completed executions.</li></ul><p>In Airflow, idempotency makes retries and backfills reliable. Both capabilities are valuable, but they can produce incorrect results when tasks are not designed to be safely repeated.</p><p><strong>Pattern 2: Separating Ingestion, Transformation, and Consumption</strong></p><p>Combining extraction, cleansing, and aggregation within one task leads to DAGs that are difficult to maintain. Clear separation of responsibilities improves reliability and traceability.</p><p>Ingestion moves data into the raw layer. Transformation handles schemas, quality checks, and deduplication. Publication produces datasets for specific uses: a daily sales table, a customer dimension, or a dashboard-ready view.</p><p>This separation allows a transformation to be corrected without querying the source again. It also preserves a raw data trail for audit, troubleshooting, and future reinterpretation of business rules.</p><p><strong>Pattern 3: Data Quality as Part of the Pipeline</strong></p><p>A technically completed pipeline is not necessarily a successful pipeline. A load may finish without errors while producing incomplete, out-of-schema, or duplicated data. Updated dashboards can therefore still result in incorrect decisions.</p><p>The most common quality controls verify:</p><ul><li>presence and type of expected columns;</li><li>uniqueness of keys;</li><li>absence of null values in critical fields;</li><li>volumes consistent with previous executions;</li><li>data freshness.</li></ul><p>Blocking checks prevent data from being published. Non-blocking checks generate alerts. In Airflow, these controls are explicit DAG tasks rather than manual activities performed after an incident.</p><p><strong>Pattern 4: Observability and Error Handling</strong></p><p>Every production pipeline must make three questions easy to answer: what failed, which data is affected, and how can execution resume safely?</p><p>Airflow provides logs, task states, retries, and notifications. Observability also includes domain metrics: number of records ingested, rejected records, delay relative to the source, and transformation duration.</p><p>Temporary errors, such as network timeouts, unavailable APIs, or temporarily saturated resources, can justify retries with backoff. Structural errors, such as incompatible schema changes, require a controlled failure and an alert. Repeating the task automatically does not resolve the underlying issue.</p><p><strong>Conclusion</strong></p><p>ETL and ELT are not mutually exclusive. They can coexist within the same architecture. The appropriate model depends on the target system, data volume, data sensitivity, and available computing capacity.</p><p>With Airflow, the value lies in making the flow explicit: ingesting data incrementally, retaining a raw version, transforming it through suitable engines, validating quality, and managing failures and reruns reliably.</p><p>The result is a pipeline that is not only functional, but also repeatable, observable, and ready to evolve with analytical requirements.</p><p><strong>References</strong></p><p>Apache Software Foundation. <em>Apache Airflow Documentation</em>, version 3.4.0. Official documentation on DAGs, scheduling, tasks, and pipeline monitoring. <a href="https://airflow.apache.org/docs/apache-airflow/stable/"><strong>airflow.apache.org</strong></a></p><p>Kleppmann, Martin, and Chris Riccomini. <em>Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems</em>. 2nd ed., O’Reilly Media, 2026. Useful for reliability, distributed systems, data architectures, and design trade-offs. <a href="https://www.oreilly.com/library/view/designing-data-intensive-applications/9781098119058/"><strong>O’Reilly</strong></a></p><h3>About the Author</h3><p>I am an experienced Data Science Software Developer and AI Consultant with a strong background in designing, developing, and implementing Machine Learning, Deep Learning, and Artificial Intelligence solutions. Throughout my career, I have combined advanced software engineering expertise with a solid understanding of mathematical and statistical foundations to design intelligent, scalable, and effective data-driven systems. My professional activities span technical consulting, solution architecture, software development, and the practical application of AI technologies to complex business and technological challenges. Alongside my consulting work, I am deeply committed to technical education and professional development, helping individuals and organizations build expertise in Data Science, Machine Learning, Deep Learning, and Artificial Intelligence. I am also passionate about technical writing, knowledge sharing, and making complex scientific and technological concepts accessible without compromising their mathematical rigor or technical depth. My professional philosophy is grounded in three principles: scientific rigor, engineering excellence, and the effective communication of knowledge. You can read my LinkedIn profile here: <a href="https://www.linkedin.com/in/maurizio-mammuccini-a2313438/">https://www.linkedin.com/in/maurizio-mammuccini-a2313438/</a></p><p>Here you can find my latest published book (Italian Edition): <a href="https://www.amazon.com/Teoria-dellInformazione-Machine-Learning-Decisionali/dp/B0HP876ZH3/ref=sr_1_1">https://www.amazon.com/Teoria-dellInformazione-Machine-Learning-Decisionali/dp/B0HP876ZH3/ref=sr_1_1</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f17d457eb469" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Airflow Lab: Orchestrating Sequential Pipelines]]></title>
            <link>https://medium.com/@mauriziomammuccini/laboratory-orchestrating-sequential-pipelines-in-apache-airflow-and-reliably-passing-data-between-b3ef0d9cc739?source=rss-d9f897922c0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3ef0d9cc739</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[big-data-pipeline]]></category>
            <category><![CDATA[apache-airflow]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Maurizio Mammuccini]]></dc:creator>
            <pubDate>Wed, 11 Nov 2026 17:30:06 GMT</pubDate>
            <atom:updated>2026-11-22T05:53:14.009Z</atom:updated>
            <content:encoded><![CDATA[<h3>Laboratory: Orchestrating Sequential Pipelines in Apache Airflow and Reliably Passing Data Between DAGs</h3><blockquote>A hands-on guide to chaining tasks and safely sharing data across steps using XComs and TaskFlow.</blockquote><p>The example in this article runs in a local <strong>Docker </strong>environment. Airflow, MinIO, and PostgreSQL run as separate containers that share the same Docker network.</p><p>This configuration allows containers to communicate by using their service names as hostnames. For this reason, the Airflow connections in the laboratory use minio and postgres as hosts rather than localhost: from the Airflow container, both services are reachable through the shared network.</p><p>MinIO is used as S3-compatible object storage, while PostgreSQL is the target relational database. Airflow acts as the orchestrator: it acquires the data, coordinates its transfer to PostgreSQL, and starts quality checks after loading completes.</p><p>The local architecture makes the example easy to reproduce, while the underlying principles also apply in the cloud. MinIO can be replaced directly by Amazon S3, and PostgreSQL can be hosted by a managed service such as Amazon RDS for PostgreSQL, Cloud SQL for PostgreSQL, or Azure Database for PostgreSQL.</p><p>Google Cloud Storage and Azure Blob Storage follow equivalent object-storage models, but normally require dedicated Airflow hooks, providers, and connection settings. The architectural principle remains the same: DAGs should not embed connection details and should exchange reliable references to produced objects, such as a storage path or execution identifier.</p><p><strong>Introduction When one pipeline is not enough</strong></p><p>Many data-engineering projects are not made of one operation but of a sequence of phases with distinct responsibilities. A workflow can start by acquiring data from an external source, continue by loading it into a persistence system, and end with quality checks or publication of a result.</p><p>Apache Airflow models these activities with DAGs, or Directed Acyclic Graphs, which define the order in which operations run. When the entire process is contained in one DAG, task dependencies are straightforward. In more complex scenarios, it can be useful to split the process into independent DAGs to promote reuse, separate responsibilities, or assign different phases to different teams.</p><p>This choice raises a fundamental question: how can one DAG automatically start the next and communicate the information it needs to continue?</p><p>This article builds a pipeline made of three sequential DAGs:</p><pre>01_ingest_to_minio -&gt; 02_minio_to_postgres -&gt; 03_postgres_quality_checks</pre><p>The first DAG downloads a JSON dataset and saves it in MinIO. The second receives the reference to the file just created and loads it into PostgreSQL. The third performs quality checks on records associated with that specific load. The goal is not only to automate execution order, but also to make data handoff explicit and reliable.</p><p><strong>Configuring Airflow connections for MinIO and PostgreSQL</strong></p><p>Before defining the DAGs, Airflow must be able to communicate with the external services used by the pipeline: MinIO, which stores the acquired JSON file, and PostgreSQL, which receives the transformed and loaded data.</p><p>Rather than placing hosts, users, and passwords directly in Python code, Airflow centralizes these values in Connections. DAGs reference a connection by its identifier, while the actual details remain configured in the Airflow interface. From the main menu, select Admin and then Connections.</p><p><strong>MinIO connection</strong></p><p>To connect Airflow to the local MinIO instance, create an Amazon Web Services connection. This is possible because MinIO exposes an API compatible with Amazon S3. The Extra field contains an endpoint and region, including endpoint_url: <a href="http://minio:9000/">http://minio:9000</a> and region_name: <strong>us-east-1</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SO960a2Yn-y69uANzrsBew.png" /><figcaption>Figure 1 — MinIO connection form in Airflow<br><em>Airflow form used to configure the connection to the local MinIO instance.</em></figcaption></figure><p>The <strong>Extra </strong>field contains JSON configuration that tells the Airflow AWS provider which endpoint to use:</p><pre><br>{<br>  &quot;endpoint_url&quot;: &quot;http://minio:9000&quot;,<br>  &quot;region_name&quot;: &quot;us-east-1&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*v9vMiyI26LDT0vxilssE3w.png" /><figcaption>Figure 2 — MinIO connection parameters<br><em>Summary of the values required for the MinIO Airflow connection.</em></figcaption></figure><p>The minio hostname is resolvable from the laboratory’s Docker network. In an installation outside of Docker, this value must be replaced with the hostname or address reachable by the MinIO instance.</p><p><strong>PostgreSQL connection</strong></p><p>The second connection lets the DAGs write to and query PostgreSQL. It uses the native Postgres connection type. The hostname postgres identifies the database service within the Docker network. The DAGs use the identifier postgres_local and do not need to know the host, credentials, or port directly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s7_KCCxHHjP7rkNHQ2Jdlw.png" /><figcaption>Figure 3 — PostgreSQL connection form in Airflow<br><em>Airflow form used to configure the connection to the local PostgreSQL database.</em></figcaption></figure><p>In this case, too, the hostname postgres identifies the PostgreSQL service within the lab’s Docker network. The DAGs will use the identifier postgres_local, without needing to have direct knowledge of the database host, credentials, or port.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*oMWULGMyFTWTww3bGcxV5Q.png" /><figcaption>Figure 4 — PostgreSQL connection parameters<br><em>Summary of the values required for the PostgreSQL Airflow connection.</em></figcaption></figure><p>Once these connections have been saved, the DAGs can retrieve them using their respective identifiers: minio_s3 for MinIO and postgres_local for PostgreSQL. These two names must match exactly those used in the Python code.</p><p><strong>The problem Dependencies and data between DAGs</strong></p><p>Consider three separate DAGs: 01_ingest_to_minio, which acquires the dataset and saves it in MinIO; 02_minio_to_postgres, which reads the file from MinIO and loads it into PostgreSQL; and 03_postgres_quality_checks, which verifies the quality of the loaded data.</p><p>If each DAG is started manually, an operator must respect the correct order: ingestion first, loading second, and checks last. This may be acceptable in a test environment, but it quickly becomes fragile in an operational process. The second DAG could start before a file exists, or it could read an earlier file rather than the output of the latest run.</p><p>The issue is not only execution order. The context of each run must also be preserved: DAG 02 must know which file DAG 01 created, and DAG 03 must validate the records originating from that same file.</p><p>- The downstream DAG must start automatically after the previous phase completes.</p><p>- It must receive an exact reference to the output produced upstream.</p><p>- It must fail explicitly when the required information is unavailable.</p><p>In this laboratory, the value being transferred is not the JSON content but its MinIO key, for example</p><pre>raw/todos/todos_20261110T103000Z_a1b2c3d4.json</pre><p>This lightweight and identifiable reference lets downstream DAGs work on the intended dataset without moving or duplicating the payload.</p><p><strong>The laboratory DAGs Starting point</strong></p><p>The laboratory contains three separate DAGs, each responsible for one phase of the pipeline. The split makes the process easier to read and isolates data acquisition, database loading, and final validation. The following figures show the complete Python files; later sections examine how they are connected and how the file reference is transferred.</p><p><strong>DAG 01: Ingesting the dataset into MinIO</strong></p><p>The first DAG downloads the public JSON dataset, verifies the lakehouse bucket, stores the content in MinIO, and returns the resulting object key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yB2-E5AdBLYpq6gDFGUbcw.png" /></figure><p>In Figure 5, lines 38–42 generate object keys such as:</p><pre>raw/todos/todos_20261110T103000Z_a1b2c3d4.json</pre><p>The eight-character hexadecimal suffix makes collisions extremely unlikely, even when multiple runs occur within the same second. Although it does not guarantee absolute uniqueness, it provides sufficient protection against key collisions for this laboratory.</p><p>The first DAG downloads a public JSON dataset, stores it in MinIO, and triggers the loading workflow.</p><p><strong>DAG 02: Loading from MinIO into PostgreSQL</strong></p><p>The second DAG receives the MinIO object key, retrieves the selected file, deserializes the JSON content, and loads records into public.todo_items. It uses an upsert so that rerunning the same input does not add duplicate records.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b2Q9csUSB-absCdR8QC9xA.png" /><figcaption>Figure 6— DAG 02 loading MinIO data into PostgreSQL</figcaption></figure><p>The second DAG receives the object key, loads the selected file into PostgreSQL, and triggers the quality checks.</p><p><strong>DAG 03: Quality checks in PostgreSQL</strong></p><p>The third DAG receives the source-file reference and validates records associated with that specific load. Restricting checks to the current source file is important: it makes it possible to validate one pipeline run precisely, without confusing newly loaded data with data produced by earlier runs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ne7qUOUbPBwaFw0uVIpR0A.png" /><figcaption>Figure 7 — DAG 03 validating the PostgreSQL load</figcaption></figure><p>The third DAG validates the records associated with the file processed by the pipeline run.</p><p>The three DAGs therefore form a complete pipeline, but their separation requires an explicit mechanism to start runs in the correct order and transfer the reference to the produced file. This is the subject of the following sections.</p><p><strong>DAGs, tasks, and XComs: A necessary distinction</strong></p><p>Before defining the communication mechanism between the three DAGs, it is useful to distinguish some fundamental Airflow concepts.</p><p>A DAG represents a workflow: it defines which activities must run and in which order. In the <em>laboratory, 01_ingest_to_minio</em>, <em>02_minio_to_postgres</em>, and <em>03_postgres_quality_checks</em> are three distinct workflows.</p><p>A task, on the other hand, is a single unit of work inside a DAG. For example, in the first DAG one task downloads the JSON dataset and saves it in MinIO. In the second DAG, one task reads the specified file and a subsequent task loads it into PostgreSQL.</p><p>XComs, short for cross-communications, allow tasks in the same DAG run to exchange small values. When a task returns a value, Airflow can save it as an XCom and make it available to downstream tasks in that same run.</p><p>In this example, the ingestion task returns the MinIO key of the newly created file. This small, descriptive value is suitable for an XCom. The JSON file itself must not be copied into an XCom: it remains in MinIO, where the next DAG can read it.</p><p>It is important to emphasize that XCom is not a dataset store and is not intended to directly share large data between independent DAGs. Storing large payloads in XComs can unnecessarily increase the load on Airflow’s metadata database, reduce the readability of the interface, and make run management more complex.</p><p>To coordinate separate DAGs, we will therefore use two complementary concepts:</p><p>- a trigger, which starts the downstream DAG;</p><p>- a runtime parameter, passed in the <em>conf </em>field of the new DAG run, that contains the previously produced MinIO key.</p><p>This separation is essential: Airflow orchestrates the flow and transfers small references, while MinIO stores the actual data. The result is a more reliable pipeline, easier to observe and readily adaptable to managed cloud object storage.</p><p>For this reason, this laboratory uses XComs only inside the calling DAG. download_and_store returns the MinIO key, Airflow stores it as an XCom, and TriggerDagRunOperator retrieves it through ti.xcom_pull before placing it in the new DAG run’s conf. The value is not shared as an XCom between DAGs: the receiving DAG obtains source_key from its execution configuration.</p><p><strong>Strategies for passing data between DAGs</strong></p><p>Separate DAGs can be coordinated in several ways. The right choice depends on the type of dependency, the amount of data to make available, and the desired level of coupling between workflows.</p><p>In this laboratory, the requirement is precise: DAG 02 must start after DAG 01 and must process exactly the file produced by that specific run. The same applies to the relationship between DAG 02 and DAG 03.</p><p>The main strategies are the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJ7R7SNLuYj4KWIn2Q2C6w.png" /><figcaption>Figure 8 — Data transfer strategies between Airflow DAGs</figcaption></figure><p>Comparison of the main approaches for coordinating DAG executions and sharing data references.</p><p><strong>TriggerDagRunOperator and runtime parameters</strong></p><p><em>TriggerDagRunOperator </em>allows a task to create a new run of another DAG. During the trigger, the calling DAG can provide a configuration dictionary in the <em>conf </em>field. The started DAG receives this configuration in its own <em>dag_run</em>. In this case, the <em>source_key </em>parameter contains the key of the JSON object in MinIO. DAG 02 therefore does not need to look for the latest file in the bucket: it directly receives the exact reference to the file to process.</p><p>This approach combines two fundamental aspects:</p><p>- it explicitly defines the execution sequence;</p><p>- it transfers the minimum context required by the next phase.</p><p>It is the solution adopted in the laboratory because it makes the relationship between the three runs clear and makes it possible to follow the same MinIO key from initial acquisition through quality checks.</p><p><strong>ExternalTaskSensor</strong></p><p><em>ExternalTaskSensor </em>suspends a task until a task or an external DAG reaches the expected state. It is useful, for example, when two DAGs have independent schedules and one must wait for the other to complete.</p><p>However, the sensor handles waiting, not the transfer of a parameter. To pass the reference to the correct file, an additional mechanism would be needed, such as a control table, a manifest file, or a convention based on execution dates.</p><p>For a linear chain such as the one in this laboratory, the explicit trigger is more direct and easier to understand.</p><p><strong>Asset-aware scheduling</strong></p><p>In more recent Airflow versions, a DAG can be scheduled based on the update of an asset. This model is particularly useful when data produced by one pipeline must be consumed by multiple DAGs, without the producing DAG needing to know all its consumers.</p><p>In a cloud platform, an asset can represent, for example, a file in an S3 bucket, a PostgreSQL table, or a dataset in a data lake. This approach reduces coupling between producer and consumer, but requires more structured modelling of assets and their lifecycle.</p><p><strong>External storage for data, lightweight parameters for coordination</strong></p><p>Regardless of the mechanism chosen to coordinate DAGs, significant amounts of data must remain in a system designed to store them: object storage, a database, a data lake, or a shared file system.</p><p>Airflow should transfer only lightweight metadata, such as:</p><p>- an object key;</p><p>- a file path;</p><p>- a batch identifier;</p><p>- a reference date;</p><p>- a table name or dataset version.</p><p>In this example, the JSON file remains in MinIO, while <em>source_key </em>is passed through <em>dag_run.conf</em>. This separation keeps the pipeline efficient and makes it easier to rerun a single phase with the same input.</p><p><strong>Why not use XCom across DAGs</strong></p><p>XComs are suited to the exchange of small values between tasks belonging to the same DAG run. Using them as a generic communication channel between separate DAGs creates opaque dependencies and makes it harder to associate a value with the correct workflow run.</p><p><strong>Solution architecture</strong></p><p>The solution combines explicit orchestration and external storage. Airflow coordinates execution order, while MinIO and PostgreSQL store the pipeline data.</p><p>The flow starts with 01_ingest_to_minio. After downloading the JSON dataset, the DAG saves the file in the MinIO <em>lakehouse</em> bucket and returns the object key, named <em>source_key</em>.</p><p>A TriggerDagRunOperator task then starts 02_minio_to_postgres. The <em>source_key</em> value is placed in the <em>conf </em>field so that the new DAG run has the exact reference to the file to process.</p><p>The second DAG reads the specified file, loads the data into the PostgreSQL table <em>public.todo_items</em>, and stores the source key in the <em>source_file</em> column. When loading completes, it uses the same mechanism to start 03_postgres_quality_checks, again transferring <em>source_key</em>.</p><p>The third DAG receives the reference and limits checks to records associated with the file processed by the current chain. In this way, every run remains traceable from the MinIO object through the final checks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Z2-ziaaBfkyJaMfaHzBFQ.png" /><figcaption>Figure 9 — Sequential Airflow DAG architecture</figcaption></figure><p>Airflow triggers each downstream DAG and transfers only the source_key reference, while data remains in MinIO and PostgreSQL.</p><p>The most important aspect of the architecture is the separation between the data plane and the control plane:</p><p>- MinIO and PostgreSQL form the data plane: they host the JSON file and the loaded records, respectively;</p><p>- Airflow forms the control plane: it orchestrates runs and transfers only the lightweight <em>source_key</em> reference.</p><p>This separation prevents Airflow from having to store or transfer the dataset content directly. It also makes it easier to rerun a DAG on a specific file: simply provide the same MinIO key as a runtime parameter.</p><p><strong>DAG 01: Acquire the data and publish its reference</strong></p><p>DAG 01 is the pipeline entry point. It acquires the dataset, stores it in MinIO, and makes a precise reference to the produced file available.</p><p>As shown in Figure 5, download_and_store downloads the JSON dataset from the public endpoint and keeps its content in payload. The file is not written to the Airflow container’s local file system; it is sent directly to the lakehouse bucket.</p><p>Before uploading, the DAG checks whether the bucket exists. It creates the bucket only when it is actually missing. Network, credential, and authorization failures are not masked by this check: they stop the run and remain visible in Airflow logs.</p><p>The object key combines a UTC timestamp with a unique suffix and has a form similar to the following:</p><pre>raw/todos/todos_20261110T103000Z_a1b2c3d4.json</pre><p>The timestamp makes the key readable and sortable, while the unique suffix prevents collisions between runs started within the same second. Each acquisition can therefore be reliably identified and traced in storage.</p><p>After upload, <em>download_and_store</em> returns the MinIO key. Since it is a small string, Airflow makes it available as an XCom from the task. This value is then used by the <em>start_dag_02</em> task.</p><p><em>start_dag_02 </em>uses <em>TriggerDagRunOperator </em>to create a new run of <em>02_minio_to_postgres</em>. The trigger’s <em>conf </em>field contains <em>source_key</em>, whose value is retrieved from the XCom produced by <em>download_and_store</em>.</p><p>The first DAG therefore does not transfer the dataset to the downstream DAG. It transfers only the reference to the object saved in MinIO. DAG 02 receives a configuration equivalent to:</p><pre>source_key = raw/todos/todos_20261110T103000Z_a1b2c3d4.json</pre><p>This step is the first element of the automatic chain: the DAG 02 run is created only after the task that produced the file completes, and it is associated with the specific input that was just generated.</p><p><strong>Automatically starting the downstream DAG</strong></p><p>TriggerDagRunOperator creates a new run of the DAG named in trigger_dag_id. In DAG 01, start_dag_02 runs only after download_and_store, ensuring that the file has already been written to MinIO before DAG 02 is triggered.</p><p>The trigger defines two essential pieces of information:</p><p>- the DAG to start, identified by 02_minio_to_postgres;</p><p>- the <em>source_key</em> parameter, placed in the configuration of the started run.</p><p>The source_key value is obtained from the download_and_store task XCom through the templated ti.xcom_pull expression. Airflow resolves this expression when it executes the trigger task, replacing it with the actual key of the MinIO object created moments earlier. DAG 02 therefore receives a new DAG run with a configuration that contains the reference to the source file. Inside the receiving DAG, the value is available as</p><pre>dag_run.conf[&quot;source_key&quot;]</pre><p>Passing an explicit key is safer than generically finding the most recent file in the bucket, which can be unreliable with concurrent runs, delays, or retries. In the current configuration, the trigger starts the downstream DAG without waiting for it to finish. DAG 01 therefore succeeds after creating DAG 02’s run, not after the whole chain completes. Waiting for the called DAG can be enabled when the operational requirement is to propagate downstream completion or failure.</p><p><strong>DAG 02: Load the selected file into PostgreSQL</strong></p><p>DAG 02 turns the received reference into a concrete loading operation. It reads the JSON file identified by source_key, converts its content into records, and writes them to public.todo_items.</p><p>get_source_key retrieves the parameter from the DAG run configuration and fails explicitly when it is missing. This prevents ambiguous behavior such as selecting the latest file in a bucket. load_into_postgres uses minio_s3 to read the object and deserializes the JSON payload.</p><p>The task creates the public.todo_items table if it does not already exist. Each row stores:</p><p>- the todo identifier;</p><p>- the user identifier;</p><p>- the title;</p><p>- the completion status;</p><p>- the <em>source_file</em> field, which contains the MinIO key of the source file;</p><p>- the load timestamp.</p><p>The source_file field identifies the MinIO file associated with the latest loaded version of each record. This information allows DAG 03 to validate the data processed by the current pipeline run.</p><p>The insert uses an upsert. When a row with the same id already exists, its values are updated rather than creating a duplicate. This makes the load idempotent. The laboratory model therefore retains the latest state of every record. Preserving a complete batch history would require an audit table or a composite key that includes the batch identifier.</p><p>The laboratory uses cursor.executemany() to load the 200 records retrieved from JSONPlaceholder. This approach is appropriate for small datasets and keeps the implementation straightforward. For larger data volumes, PostgreSQL bulk-loading techniques, such as psycopg2.extras.execute_values() or the COPY command, may provide better performance.</p><p>After loading, load_into_postgres returns the key it received. The value is then passed to the start_dag_03 task, which creates a new run of 03_postgres_quality_checks.</p><p>Consequently, the second DAG plays a dual role: it loads the dataset into PostgreSQL and preserves the context needed for the downstream DAG to validate exactly that load.</p><p><strong>DAG 03: Quality checks on the correct load</strong></p><p>DAG 03, 03_postgres_quality_checks, closes the pipeline by verifying the result of the PostgreSQL load.</p><p>Like DAG 02, this workflow receives <em>source_key </em>in the run configuration. The parameter identifies the MinIO file that originated the load and makes it possible to select only the relevant records.</p><p>The <em>verify_data</em> task executes a query against the <em>public.todo_items</em> table, filtering the <em>source_file </em>field by the <em>source_key</em> value. In this way, checks are not applied indiscriminately to the whole table, which may contain data from earlier runs.</p><p>The checks implemented in the laboratory are deliberately simple:</p><p>- they verify that the load produced at least one record;</p><p>- they count the records whose <em>completed </em>field is true.</p><p>If the total number of records is zero, the DAG ends with an error. Airflow records the task failure and makes it visible in the DAG page and in the run logs.</p><p>The <em>completed_rows </em>value is not used as an error condition, but it is a useful metric for understanding the content of the loaded dataset. In a real context, this type of check can be extended with thresholds, comparisons with previous runs, or business-rule validation.</p><p>The key point is that the DAG does not generically verify the PostgreSQL table: it verifies data associated with one specific source file. This makes the check repeatable, traceable, and consistent with the individual pipeline run.</p><p><strong>Execution, observability, and error handling</strong></p><p>Only 01_ingest_to_minio is started manually. DAG 02 and DAG 03 runs are created by their respective triggers. Each run remains visible as an independent execution in Airflow, so operators can inspect status, logs, and tasks for each phase.</p><p>The chain behaves as follows:</p><p>1. The operator starts 01_ingest_to_minio.</p><p>2. DAG 01 downloads the dataset, saves it in MinIO, and creates a DAG run for 02_minio_to_postgres.</p><p>3. DAG 02 reads the specified file, loads records into PostgreSQL, and creates a DAG run for 03_postgres_quality_checks.</p><p>4. DAG 03 performs checks on the load associated with that file.</p><p>If the ingestion task fails, DAG 02 is not started. Similarly, if loading into PostgreSQL fails, DAG 03 is not created. Task dependencies within each DAG prevent the next trigger from running after a failure in the previous phase.</p><p>It is important to distinguish this behavior from complete status propagation between DAGs. In the laboratory configuration, TriggerDagRunOperator creates the next DAG run without waiting for it to complete. Consequently:</p><p>- DAG 01 can be marked successful even if DAG 02 fails later;</p><p>- DAG 02 can be marked successful even if DAG 03 fails.</p><p>This choice favors the independence and observability of individual phases. If the entire chain must be considered a single logical run, the trigger can be configured to wait for the called DAG to complete and to propagate a failure status.</p><p>All three DAGs must be present in Airflow’s DAG folder and must not be paused. Only DAG 01 is started manually, but DAG 02 and DAG 03 must remain available to the scheduler. schedule=None means that a DAG has no autonomous time schedule; it does not disable manual or triggered runs.</p><p>For diagnosis, it is useful to follow the source_key reference in the logs of the three runs. The key identifies the MinIO file, appears in the configuration of the triggered DAG runs, and is recorded in the source_file column of the PostgreSQL table. This makes it possible to reconstruct the dataset path from ingestion through final verification.</p><p>In an operational environment, it is also advisable to configure retries, timeouts, notifications, and alerts explicitly. These elements do not change the data-transfer mechanism, but they make the pipeline more robust in the presence of transient errors, network outages, or issues in external services.</p><p><strong>Best practices and limitations of the approach</strong></p><p>The solution based on TriggerDagRunOperator, <em>dag_run.conf</em>, and external storage is simple and effective for a linear chain of DAGs. To keep it reliable with more complex pipelines as well, it is useful to follow some best practices.</p><p><strong>Pass references not payloads</strong></p><p>source_key contains only the object path in MinIO. The JSON file remains in the storage system designed for data and files. The same principle applies to table names, S3 URIs, batch identifiers, or reference dates. Do not use XCom or dag_run.conf to transfer DataFrames, binary files, or large JSON structures.</p><p><strong>Use immutable and identifiable references</strong></p><p>Every run should produce a unique reference to its input. In this laboratory, the MinIO key combines a UTC timestamp with a unique suffix, making it readable, sortable, and safe under concurrent execution.</p><p>Whenever possible, a reference should identify a specific version of the data. This choice makes it possible to rerun a single pipeline phase using exactly the same input.</p><p><strong>Make tasks idempotent</strong></p><p>An idempotent task can run more than once without undesired changes to the final result. The PostgreSQL load uses an *upsert*, so a new run updates existing records instead of introducing duplicates.</p><p>Idempotency is essential in Airflow because a task can be retried automatically, rerun manually, or restored after an operational error.</p><p><strong>Validate received parameters explicitly</strong></p><p>DAG 02 and DAG 03 verify that <em>source_key </em>exists before continuing. This validation turns a possible implicit error into a clear message and makes it easier to diagnose runs started with an incomplete configuration.</p><p>The ingestion DAG also checks whether the MinIO bucket exists. The bucket is created only when it is actually absent; credential, network, or authorization errors must instead stop the run and remain visible in the logs.</p><p>In a more elaborate pipeline, it is advisable to also validate the parameter format, the existence of the object in storage, and consistency between the source file and the batch to process.</p><p><strong>Keep receiving DAGs active</strong></p><p>All three DAGs must be present in Airflow’s monitored folder and unpaused. DAG 02 and DAG 03 have schedule=None, yet they must be available to the scheduler for runs created by triggers.</p><p><strong>Consider concurrency and reruns</strong></p><p>Concurrent runs of DAG 01 produce separate source_key values and can independently activate downstream stages. Environments with limited capacity or shared tables may also need concurrency limits, pools, or batch-ordering strategies.</p><p><strong>When to choose a single DAG, separate DAGs, or an asset-oriented solution</strong></p><p>Splitting a process into multiple DAGs is not always the best choice. Airflow allows the same process to be modelled in different ways, and the most appropriate solution depends on the level of reuse, operational complexity, and dependencies between phases.</p><p><strong>A single DAG</strong></p><p>One DAG is often the simplest solution when all activities belong to one process and share the same lifecycle.</p><p>In this case, acquisition, loading, and quality checks can be modelled as successive tasks in the same workflow. Airflow shows the entire run in one graph, and error propagation is immediate: if a task fails, downstream activities are not executed.</p><p>A single DAG is particularly appropriate when:</p><p>- phases always run together;<br>- there are no independent reuse cases;<br>- the same person or team manages the whole pipeline;<br>- a single operational view of the run is desired.</p><p><strong>Separate DAGs with explicit triggers</strong></p><p>The approach used in the laboratory is useful when phases have separate responsibilities but must still run in a controlled sequence.</p><p>The ingestion DAG can be maintained and reused as an independent workflow. The loading DAG can receive a MinIO key from other pipelines as well. Finally, quality checks can evolve separately from acquisition and loading activities.</p><p>This solution is appropriate when:</p><p>- phases have clear functional boundaries;<br>- some DAGs must be reusable;<br>- different teams manage different parts of the process;<br>- explicit context, such as a batch identifier or a file path, must be transferred;<br>- it is useful to observe runs as distinct workflows.</p><p>The cost of this flexibility is greater attention to correlating DAG runs, handling errors, and ensuring the availability of receiving DAGs.</p><p><strong>Asset-aware scheduling</strong></p><p>In recent Airflow versions, asset-aware scheduling makes it possible to start a DAG when a declared asset is updated. In previous versions, this model was commonly referred to as Dataset-based scheduling.</p><p>This approach is appropriate when the producer of data does not need to know all consumers. A DAG can publish an asset, such as a table or a file, and several downstream DAGs can react to its availability.</p><p>It is a valid choice when:</p><p>- one item of data is consumed by multiple pipelines;<br>- producers and consumers must remain decoupled;<br>- the primary requirement is the availability of an asset, not the start of a specific linear chain;<br>- the platform has clear governance for asset names, versions, and quality.</p><p>In the laboratory, an explicit trigger remains more immediate: DAG 01 knows DAG 02 and must pass it a precise <em>source_key</em>. In a platform with many producers and consumers, an asset-oriented model can instead provide greater organizational scalability.</p><p><strong>Event-driven architectures</strong></p><p>For pipelines that react to external events — such as the arrival of a message, a file, or an application notification — it can be useful to integrate Airflow with queues, webhooks, or event-streaming systems.</p><p>This model is appropriate for near-real-time scenarios and distributed architectures, but requires more careful design of idempotency, deduplication, observability, and failure handling.</p><p>The solution to choose therefore does not depend only on the available technology. It depends above all on the relationship between activities: a unified flow often requires one DAG; a chain with separate responsibilities can benefit from explicit triggers; and a platform with many consumers can benefit from asset-aware scheduling.</p><p><strong>Conclusion</strong></p><p>Coordinating multiple Apache Airflow DAGs does not mean moving large amounts of data through the orchestrator. It means clearly defining execution order and sharing the minimum context required for each stage to operate on the correct data.</p><p>In this laboratory, DAG 01 downloads the dataset and stores it in MinIO. Its object key is passed to DAG 02 through TriggerDagRunOperator and dag_run.conf. DAG 02 loads the file into PostgreSQL, maintains the source reference, and activates DAG 03. DAG 03 validates only records associated with that specific run.</p><p>The result is an automated pipeline:</p><pre>01_ingest_to_minio -&gt; 02_minio_to_postgres -&gt; 03_postgres_quality_checks</pre><p>The operator starts only the first DAG manually. However, all three DAGs must remain active in Airflow, even though DAGs 02 and 03 do not have an autonomous time schedule.</p><p>The architectural principle remains valid beyond the local laboratory: data must reside in systems suitable for its persistence, such as object storage and databases, while Airflow must orchestrate activities and transfer lightweight, traceable, and repeatable references.</p><p>This separation makes it possible to build pipelines that are more reliable, easier to observe, and ready to evolve from a local Docker environment toward cloud infrastructure and multi-consumer scenarios.</p><p><strong>References</strong></p><p>Apache Airflow. DAG Dependencies and TriggerDagRunOperator. <a href="https://airflow.apache.org/docs/apache-airflow/stable/concepts/dags.html">https://airflow.apache.org/docs/apache-airflow/stable/concepts/dags.html</a></p><p>Apache Airflow. XComs. <a href="https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/xcoms.html">https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/xcoms.html</a></p><p>MinIO. S3 API Compatibility. <a href="https://docs.min.io/aistor/developers/s3-api-compatibility/">https://docs.min.io/aistor/developers/s3-api-compatibility/</a></p><p>PostgreSQL. INSERT and ON CONFLICT. <a href="https://www.postgresql.org/docs/current/sql-insert.html">https://www.postgresql.org/docs/current/sql-insert.html</a></p><p>Apache Airflow. Asset-Aware Scheduling. <a href="https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/asset-scheduling.html">https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/asset-scheduling.html</a></p><h3>About the Author</h3><p>I am an experienced Data Science Software Developer and AI Consultant with a strong background in designing, developing, and implementing Machine Learning, Deep Learning, and Artificial Intelligence solutions. Throughout my career, I have combined advanced software engineering expertise with a solid understanding of mathematical and statistical foundations to design intelligent, scalable, and effective data-driven systems. My professional activities span technical consulting, solution architecture, software development, and the practical application of AI technologies to complex business and technological challenges. Alongside my consulting work, I am deeply committed to technical education and professional development, helping individuals and organizations build expertise in Data Science, Machine Learning, Deep Learning, and Artificial Intelligence. I am also passionate about technical writing, knowledge sharing, and making complex scientific and technological concepts accessible without compromising their mathematical rigor or technical depth. My professional philosophy is grounded in three principles: scientific rigor, engineering excellence, and the effective communication of knowledge. You can read my LinkedIn profile here: <a href="https://www.linkedin.com/in/maurizio-mammuccini-a2313438/">https://www.linkedin.com/in/maurizio-mammuccini-a2313438/</a></p><p>Here you can find my latest published book (Italian Edition): <a href="https://www.amazon.com/Teoria-dellInformazione-Machine-Learning-Decisionali/dp/B0HP876ZH3/ref=sr_1_1">https://www.amazon.com/Teoria-dellInformazione-Machine-Learning-Decisionali/dp/B0HP876ZH3/ref=sr_1_1</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3ef0d9cc739" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Airflow PythonOperator vs TaskFlow API: Best Practices]]></title>
            <link>https://medium.com/@mauriziomammuccini/pythonoperator-and-the-taskflow-api-in-apache-airflow-differences-when-to-use-them-and-best-faffc076d59d?source=rss-d9f897922c0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/faffc076d59d</guid>
            <category><![CDATA[apache-airflow]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Maurizio Mammuccini]]></dc:creator>
            <pubDate>Mon, 09 Nov 2026 21:14:50 GMT</pubDate>
            <atom:updated>2026-11-22T05:54:48.134Z</atom:updated>
            <content:encoded><![CDATA[<h3>PythonOperator and the TaskFlow API in Apache Airflow: differences, when to use them, and best practices</h3><blockquote>A practical comparison of traditional operators and modern decorators to write cleaner, more maintainable DAGs.</blockquote><p>Apache Airflow is an open-source platform, managed by the Apache Software Foundation, for designing, scheduling, and running automated workflows. A workflow can include several activities:</p><p>• downloading data from an API;<br>• transforming it;<br>• saving it to a database or a data lake;<br>• generating a report and sending a notification.</p><p>Airflow lets you define these activities and their execution order using Python code.</p><p>The central element that makes this possible is the DAG (Directed Acyclic Graph): a graph of tasks (the graph nodes) with defined dependencies (the graph arrows), and no cycles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qKEDKfrWmb095fPgBjTOkg.png" /><figcaption>A general DAG</figcaption></figure><p>Airflow uses the DAG to understand which tasks can start, which ones must wait, and how to handle failures, retries, and schedules.</p><p>Airflow is not designed to process large volumes of data directly. Its main role is that of an orchestrator: it coordinates operations and can delegate the actual work to external services, databases, APIs, cloud systems, or data-processing tools.</p><p>To connect to these systems, Airflow manages connections. A connection contains the information needed to reach a service, such as a host, port, credentials, or extra parameters, and is identified by a conn_id. In DAG code, you usually refer only to this identifier — for example, minio_s3 or postgres_local — without placing credentials directly in the Python file.</p><p>The figures below show the two connections used in this article. In my case, they are configured as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kebcrwOUGPRKP3Jaq9JgMg.png" /><figcaption>The minio_s3 connection configuration in the Airflow interface</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-UdUReR3gce4qY60tsxNRg.png" /><figcaption>The postgres_local connection configuration in the Airflow interface</figcaption></figure><p>In short, Airflow lets you turn a repeatable process into a controlled, observable, automatable, and maintainable workflow.</p><p><strong>What are DAGs in Airflow?</strong></p><p>In Apache Airflow, a DAG (Directed Acyclic Graph) represents the workflow to be run.</p><p>A DAG consists of:</p><p>• tasks, the individual activities to perform;<br>• dependencies, the rules that define the execution order.</p><p>A task can start only after the tasks it depends on have completed successfully. The word acyclic means that the flow cannot loop back: cycles such as A → B → A are not allowed.</p><p>In the following example, Airflow runs the greeting phase first, then processing, and finally completion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9n66NvhSbFJjwR4iU5fbWg.png" /><figcaption>Execution order: greeting → processing → completion</figcaption></figure><p><strong>Passing data between tasks</strong></p><p>A DAG can define not only the task execution order, but also the transfer of data from one task to the next.</p><p>In real-world, more complex workflows, passing data is very common: a task can produce an identifier, a file path, a processing result, or other small values needed by downstream tasks.</p><p>In the example, the first task returns the list [1, 2, 3]. The second task receives this value in the data parameter and transforms it into [10, 20, 30]. Finally, the third task receives the result in the result parameter.</p><p>The data produced by one task therefore becomes the input of the next task. Airflow manages this exchange and, at the same time, understands that the task receiving the data must run after the task producing it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TV1qhwJ3wW-fRjeUjxGsqw.png" /><figcaption>Data passed between tasks</figcaption></figure><p><strong>Why develop and use DAGs?</strong></p><p>DAGs let you turn an operational process into a declared, repeatable, and controllable workflow.</p><p>Instead of manually running different scripts in the correct order, you describe the flow once. Airflow can then run it whenever needed, while respecting the dependencies between activities.</p><p>The main benefits are:</p><p>• Automation: the workflow can be triggered manually or scheduled at regular intervals.<br>• Controlled order: every task starts only when the dependencies defined in the DAG are satisfied.<br>• Error handling: a task can be retried without manually rerunning the entire process.<br>• Observability: the Airflow interface shows the status, logs, duration, and results of individual runs.<br>• Maintainability: the workflow is Python code, so it can be read, modified, and versioned together with the project.</p><p>A DAG is especially useful when a process involves multiple systems, requires recurring runs, or needs to be easy to monitor and reproduce.</p><p><strong>A workflow involving multiple systems</strong></p><p>The three example DAGs show a concrete workflow distributed across different systems.</p><p>The first DAG, 01_ingest_to_minio, downloads JSON data from the external JSONPlaceholder API and saves it to the lakehouse bucket in MinIO. The second, 02_minio_to_postgres, finds the most recent file in the bucket, reads it, and loads the data into the PostgreSQL table public.todo_items. The third, 03_postgres_quality_checks, checks that the table contains rows and that there are no duplicate IDs.</p><p>Airflow acts as the orchestrator: each DAG uses configured connections to communicate with APIs, object storage, and databases, while the Airflow interface lets you inspect outcomes and logs.</p><p>In this example, the three DAGs are independent and are started in the correct order: first ingestion, then loading, and finally quality checks. In a production workflow, this sequence can also be automated across separate DAGs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*082n0ujrKtPAgP-PLj4G6g.png" /><figcaption>Multi-system Airflow workflow: ingestion from an external API, storage in MinIO, loading into PostgreSQL, and quality checks</figcaption></figure><p><strong>General structure of a DAG in Python</strong></p><p>A typical Python DAG file normally contains four elements: imports, Python functions, the DAG definition, and tasks with their dependencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BkXsIytDywq5UMhS9gqwuA.png" /><figcaption>Classic structure with PythonOperator</figcaption></figure><p>The Python code in the previous figure is intended to illustrate the general structure of a typical DAG. The functions contain only pass, so they do not perform any activity yet. However, the structure shown in the figure lets Airflow recognize the DAG, register the three tasks, and display the sequence extract → transform → load.</p><p>The same structure can be defined with the TaskFlow API:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NdtzBvRHxxPKimYKbh5NfA.png" /><figcaption>Structure with the dag and task decorators.</figcaption></figure><p>The two versions describe the same workflow. The differences between PythonOperator and @task are explained later.</p><p><strong>Tasks and dependencies in a DAG</strong></p><p>A task is a single unit of work that Airflow can schedule, run, monitor, and retry.</p><p>A Python function on its own is not yet an Airflow task:</p><pre>def greet():<br>    print(&quot;Hello! I am starting the DAG study.&quot;)</pre><p>It becomes a task when it is associated with an operator. In the following example, PythonOperator builds three tasks from three Python functions:</p><pre>task_greeting = PythonOperator(<br>    task_id=&quot;greeting_phase&quot;,<br>    python_callable=greet,<br>)<br><br>task_processing = PythonOperator(<br>    task_id=&quot;processing_phase&quot;,<br>    python_callable=process,<br>)<br><br>task_completion = PythonOperator(<br>    task_id=&quot;completion_phase&quot;,<br>    python_callable=complete,<br>)</pre><p>The PythonOperator parameters are:</p><p>• task_id is the unique name of the task within the DAG. It appears in the Airflow interface, logs, and error messages.<br>• python_callable is the Python function that Airflow must run.</p><p>Dependencies define the order of the tasks:</p><pre>task_greeting &gt;&gt; task_processing &gt;&gt; task_completion</pre><p>This statement creates the following flow:</p><pre>greeting_phase → processing_phase → completion_phase</pre><p>The &gt;&gt; symbol does not run the functions. It tells Airflow that task_processing must wait for task_greeting to complete, and that task_completion must wait for task_processing to complete.</p><p><strong>PythonOperator: the classic model</strong></p><p>PythonOperator is the classic Airflow operator for running a Python function as a task. Its basic syntax is:</p><pre>PythonOperator(<br>    task_id=&quot;task_name&quot;,<br>    python_callable=function_name,<br>)</pre><p>As mentioned above, task_id identifies the task in the DAG. python_callable receives a reference to the function that Airflow must run.</p><pre>def greet():<br>    print(&quot;Hello from the Airflow task!&quot;)<br><br><br>task_greeting = PythonOperator(<br>    task_id=&quot;greeting&quot;,<br>    python_callable=greet,<br>)</pre><p>It is important not to add parentheses after the function name:</p><pre>python_callable=greet     # correct<br>python_callable=greet()   # incorrect  </pre><p>In the first case, Airflow receives the function and runs it during the DAG run. In the second case, Python would run the function immediately while loading the DAG file.</p><p>You can pass arguments to the function through op_args and op_kwargs:</p><pre>def greet(name, language=&quot;en&quot;):<br>    print(f&quot;Hello, {name}! Language: {language}&quot;)<br><br><br>task_greeting = PythonOperator(<br>    task_id=&quot;greeting&quot;,<br>    python_callable=greet,<br>    op_args=[&quot;Maurizio&quot;],<br>    op_kwargs={&quot;language&quot;: &quot;en&quot;},<br>)</pre><p>When it runs the task, Airflow conceptually calls:</p><pre>greet(&quot;Maurizio&quot;, language=&quot;en&quot;)</pre><p>PythonOperator is useful when you want to define tasks, arguments, and dependencies explicitly. It is also the most common style in existing DAGs and in projects that use traditional operators.</p><p><strong>The task decorator and the TaskFlow API</strong></p><p>The TaskFlow API is the more recent Airflow style for defining tasks from regular Python functions. The task decorator turns a Python function into a task that Airflow can schedule and run:</p><pre>from airflow.decorators import dag, task<br><br><br>@dag(<br>    dag_id=&quot;taskflow_example&quot;,<br>    schedule_interval=None,<br>    start_date=datetime(2026, 1, 1),<br>    catchup=False,<br>)<br>def example_pipeline():<br><br>    @task<br>    def greet():<br>        print(&quot;Hello from the first task!&quot;)<br><br>    @task<br>    def process():<br>        print(&quot;Processing the data.&quot;)<br><br>    @task<br>    def complete():<br>        print(&quot;Workflow completed.&quot;)<br><br>    task_greet = greet()<br>    task_process = process()<br>    task_complete = complete()<br><br>    # Explicit dependencies between tasks<br>    task_greet &gt;&gt; task_process &gt;&gt; task_complete<br><br><br>example_pipeline()</pre><p>The outer function example_pipeline() defines the DAG structure. The inner functions, preceded by the task decorator, define the tasks.</p><p>Within the DAG definition, a call such as:</p><pre>task_greet = greet()</pre><p>does not run greet() immediately. Instead, it creates the Airflow task and assigns it to the task_greet variable. The task runs only when Airflow starts a DAG run.</p><p>Even with the task decorator, you can define explicit dependencies using &gt;&gt;:</p><pre>task_greet &gt;&gt; task_process &gt;&gt; task_complete</pre><p>The final call:</p><pre>example_pipeline()</pre><p>builds and registers the DAG in Airflow.</p><p>When a task passes its result to another task as an argument, Airflow can also automatically infer both the data transfer and the dependency.</p><p><strong>PythonOperator or the TaskFlow API? Key differences</strong></p><p>PythonOperator and the TaskFlow API both let you run Python functions in Airflow. The main difference is how tasks, dependencies, and data transfers are defined.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gg0Z0KuXLPOGwsgzqyibLw.png" /></figure><p>With PythonOperator, passing data is more explicit:</p><pre>def transform(**context):<br>    data = context[&quot;ti&quot;].xcom_pull(task_ids=&quot;extract&quot;)<br>    return [x * 10 for x in data]</pre><p>With the task decorator, the data simply becomes a function parameter:</p><pre>@task<br>def transform(data):<br>    return [x * 10 for x in data]<br><br><br>extracted_data = extract()<br>transform(extracted_data)</pre><p>In both cases, Airflow uses XCom to transfer small values between tasks. The TaskFlow API hides much of the technical management, making the DAG more compact and readable.</p><p>The task decorator is often a natural choice for new DAGs made mostly of Python functions. PythonOperator remains very useful in existing projects, in workflows that benefit from an explicit structure, and when many traditional operators are combined.</p><p><strong>What is XCom?</strong></p><p>XCom (cross-communication) is the mechanism Airflow uses to exchange small values between tasks in the same DAG run. With PythonOperator, the value is usually retrieved explicitly through xcom_pull(). With the task decorator, Airflow uses XCom automatically when the result of one function is passed as an argument to another.</p><p>XCom is not designed to transfer files, DataFrames, or large amounts of data. In those cases, it is better to store the content in an external system, such as MinIO, Azurite, or a database, and pass only a lightweight reference through XCom, such as a file path or identifier.</p><p>In the 02_minio_to_postgres DAG, the find_latest_file() task returns only the key of the file stored in MinIO, for example:</p><pre>raw/todos/todos_20261108T100000Z.json</pre><p>This string is passed through XCom to the load_into_postgres() task:</p><pre>load_into_postgres(find_latest_file())</pre><p>The JSON file is therefore not copied into the Airflow database. The loading task uses the received key to read the file directly from MinIO and insert the rows into the PostgreSQL table public.todo_items.</p><p>The 01_ingest_to_minio DAG also returns the key of the file it has just created. In an extended workflow, this value could be passed to a downstream task in the same DAG. In our example, the next DAG independently finds the most recent file in MinIO: XComs are not used to transfer data between separate DAGs.</p><p><strong>What is the TaskFlow API?</strong></p><p>It is the more modern Airflow approach for building tasks directly from Python functions by using the task decorator.</p><pre>from airflow.decorators import task<br><br><br>@task<br>def extract():<br>    return [1, 2, 3]</pre><p>Instead of explicitly creating a PythonOperator object, you write a regular function and Airflow turns it into a task. In addition, when you pass the result of one task to another as an argument, Airflow automatically manages both the data transfer through XCom and the dependency between tasks.</p><p>With the TaskFlow API:</p><pre>data = extract()<br>transform(data)</pre><p>the programmer can reason as if writing normal Python. Behind the scenes, Airflow:</p><p>• creates the two tasks;<br>• establishes the extract → transform dependency;<br>• stores the result of extract in XCom;<br>• retrieves it and delivers it as a parameter to transform at runtime.</p><p>This hidden management is one of the main benefits of the task decorator. It is still useful to know that XCom exists, especially to understand DAG limits, errors, and behavior.</p><p><strong>Best practices for choosing and designing</strong></p><p>There is no single syntax that works best for every DAG. The choice between PythonOperator and the TaskFlow API depends on the workflow type, the existing code, and the desired level of explicitness.</p><p>• For new workflows based mainly on Python, prefer the task decorator. Its syntax is closer to regular Python and makes passing small results between tasks natural.</p><p>• Use PythonOperator in existing DAGs or when you need an explicit structure. It is a fully valid choice, especially in projects that use many traditional operators.</p><p>• Design small tasks with a single responsibility. A task should perform one recognizable operation: extract data, transform it, load it, or validate it.</p><p>• Use clear and stable names. dag_id and task_id should describe what happens, because they appear in the interface, logs, and error handling.</p><p>• Declare dependencies in a readable way. Use &gt;&gt; when you only need to establish an order. Pass the result as an argument when a task needs to receive a small value produced by the previous task.</p><p>• Do not use XCom for large data. Files, DataFrames, and datasets should live in MinIO, Azurite, PostgreSQL, or other external systems. XCom should contain only keys, paths, IDs, and small dictionaries.</p><p>• Make tasks idempotent. If a task is rerun after an error, it should produce a consistent result without duplicating data or creating unwanted side effects.</p><p>• Manage retries and timeouts. Network operations, such as API calls and database connections, can fail temporarily; configuring retries and timeouts makes the workflow more robust.</p><p>• Use Airflow connections. Endpoints and credentials should be configured through a conn_id, not placed directly in Python code.</p><p>• Write useful logs. Clear log messages make it easier to understand what happened during a DAG run and to act when an error occurs.</p><p>In short, the best syntax is the one that makes the DAG readable, reliable, and easy to maintain.</p><p><strong>Airflow and Azure Data Factory</strong></p><p>Apache Airflow and Azure Data Factory have a common goal: orchestrating workflows made up of activities, dependencies, schedules, and execution controls.</p><p>The concepts partially overlap:</p><p>• an Airflow DAG is similar to a Data Factory pipeline;<br>• an Airflow task is similar to an activity;<br>• an Airflow connection is similar to a Data Factory linked service.</p><p>The main difference is their approach. Airflow is an open-source, code-first platform: workflows are described in Python through DAGs, tasks, and operators. Azure Data Factory, on the other hand, is a managed Azure service strongly focused on data integration, with a visual interface, built-in activities, and an Integration Runtime for connecting and running operations across different environments.</p><p>The two tools are not necessarily alternatives: the choice depends on the technology context, the degree of customization required, and the systems involved.</p><p>A more in-depth comparison of Apache Airflow and Azure Data Factory will be the subject of a future article.</p><p><strong>Conclusion</strong></p><p>Apache Airflow lets you describe automated workflows as DAGs made up of tasks and dependencies.</p><p>PythonOperator represents the classic model: explicit, flexible, and still widely used. The task decorator introduces a style closer to regular Python programming and simplifies the transfer of small pieces of data between tasks.</p><p>Both approaches use the same orchestration engine and can coexist in the same project. The choice mainly depends on the nature of the workflow:</p><p>• PythonOperator is suitable for existing DAGs, explicit flows, and integrations with traditional operators;<br>• the task decorator is often the most natural choice for new workflows built mainly from Python functions.</p><p>Whichever syntax you choose, an effective DAG starts with small tasks, clear dependencies, properly configured connections, and data stored in the systems best suited to its volume and use.</p><p>In future articles, we can cover coordination between separate DAGs, automatic scheduling, and integration with storage systems and databases.</p><p><strong>References</strong></p><p>Laboratory: Orchestrating Sequential Pipelines in Apache Airflow and Reliably Passing Data Between DAGs<br><a href="https://medium.com/@mauriziomammuccini/laboratory-orchestrating-sequential-pipelines-in-apache-airflow-and-reliably-passing-data-between-b3ef0d9cc739">https://medium.com/@mauriziomammuccini/laboratory-orchestrating-sequential-pipelines-in-apache-airflow-and-reliably-passing-data-between-b3ef0d9cc739</a></p><h3>About the Author</h3><p>I am an experienced Data Science Software Developer and AI Consultant with a strong background in designing, developing, and implementing Machine Learning, Deep Learning, and Artificial Intelligence solutions. Throughout my career, I have combined advanced software engineering expertise with a solid understanding of mathematical and statistical foundations to design intelligent, scalable, and effective data-driven systems. My professional activities span technical consulting, solution architecture, software development, and the practical application of AI technologies to complex business and technological challenges. Alongside my consulting work, I am deeply committed to technical education and professional development, helping individuals and organizations build expertise in Data Science, Machine Learning, Deep Learning, and Artificial Intelligence. I am also passionate about technical writing, knowledge sharing, and making complex scientific and technological concepts accessible without compromising their mathematical rigor or technical depth. My professional philosophy is grounded in three principles: scientific rigor, engineering excellence, and the effective communication of knowledge. You can read my LinkedIn profile here: <a href="https://www.linkedin.com/in/maurizio-mammuccini-a2313438/">https://www.linkedin.com/in/maurizio-mammuccini-a2313438/</a></p><p>Here you can find my latest published book (Italian Edition): <a href="https://www.amazon.com/Teoria-dellInformazione-Machine-Learning-Decisionali/dp/B0HP876ZH3/ref=sr_1_1">https://www.amazon.com/Teoria-dellInformazione-Machine-Learning-Decisionali/dp/B0HP876ZH3/ref=sr_1_1</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=faffc076d59d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>