Coding

What Is a Data Pipeline? Parts, ETL vs ELT, and an Example

A data pipeline is an automated series of steps that moves data from a source, such as a database, file or API, to a destination, such as a data warehouse, and usually changes it on the way. A pipeline runs on a schedule or a trigger, so nobody copies or cleans the data by hand.

The steps are sometimes called tasks or activities, and the tool that runs them in order is often called an orchestrator. The sections below cover the parts, the ETL and ELT patterns, batch versus streaming, and a small working example you can read in a few minutes.

What does a data pipeline do?

Data usually lives in the wrong place or the wrong shape for the job you want it to do. Sales records sit in an application database, web logs sit in files, and a report needs both in one table with consistent column names. A pipeline fetches the data, fixes it up, and stores it where the report or the application can use it. It does this the same way every time it runs.

Microsoft's documentation for Azure Data Factory defines a pipeline as "a logical grouping of activities that together perform a task". Its example is a pipeline that ingests and cleans log data, then starts a data flow to analyze it. The point of grouping is that you "deploy and schedule the pipeline instead of the activities independently".

What are the parts of a data pipeline?

Different products use different names, but nearly every pipeline has the same five parts.

PartWhat it isExamples
SourceWhere the data startsA SQL database, CSV files, a REST API, object storage
StepsThe individual units of workCopy a file, clean a column, join two tables, call an API
DestinationWhere the result is storedA data warehouse, a database table, a file share
OrchestratorRuns the steps in the right order and handles failuresApache Airflow, Azure Data Factory, or a plain scheduler running a script
TriggerWhat starts a runA schedule, a manual start, a new file arriving

Azure Data Factory groups its activities into three kinds: data movement, data transformation and control. Movement activities copy data from a source store to a sink store. Transformation activities change the data, using compute such as Spark clusters, stored procedures or Databricks notebooks. Control activities do not touch data at all. They decide what runs next, with things like If Condition, For Each, Wait and Until. In that product, triggers start pipeline runs, and one trigger can start several pipelines and several triggers can start the same one.

How does a pipeline decide what runs first?

Steps depend on each other. You cannot load a cleaned table before the cleaning step has finished. Orchestrators model this as a graph of steps with dependencies.

Apache Airflow represents a workflow as a Dag, a directed acyclic graph. "Directed" means each dependency has a direction (step A must finish before step B). "Acyclic" means there are no loops, so the graph always has a starting point and an end. Airflow's scheduler triggers scheduled workflows and submits tasks to the executor, which decides how the tasks are run, and workers carry out the tasks they are given. In a basic installation these can all run in one process.

Azure Data Factory expresses the same idea with an activity dependency. Activity B can depend on Activity A with one of four conditions: Succeeded, Failed, Skipped or Completed. A common use of Failed is a notification step that runs only when the main step breaks. If steps are not dependent on each other, the documentation says they might run in parallel.

What is the difference between ETL and ELT?

ETL and ELT are two common patterns for the middle of a pipeline. The letters are the order of the work.

  • ETL (extract, transform, load). AWS describes ETL as the process of combining data from multiple sources. You extract the relevant data from the source, transform it so it suits analytics, then load it into the target database.
  • ELT (extract, load, transform). AWS calls ELT an extension of ETL. The data is loaded into the target system first and processed there, so a separate staging area is not needed. AWS says it suits high-volume, unstructured data and has become common with cloud infrastructure.

Not every pipeline is either one. A pipeline whose only job is to copy a table from one database to another has no transformation step at all. The word "pipeline" covers that case as well.

Batch versus streaming pipelines

A batch pipeline handles a bounded chunk of data per run, for example yesterday's orders, every night at 02:00. A streaming pipeline handles records one at a time or in tiny groups as they arrive. Batch is easier to build, test and re-run, because you can feed it the same input again and compare results. Streaming is the choice when a result is only useful within seconds. If you are unsure which you need, start with batch. The rest of this article describes batch pipelines.

A small data pipeline example in Python

This is an illustrative script, not output from a specific product. It reads a CSV file of orders (extract), drops bad rows and converts the amounts to cents (transform), and writes the rows to a SQLite database (load). It uses only the Python standard library.

import csv
import sqlite3
from pathlib import Path


def extract(path: Path) -> list[dict[str, str]]:
    with path.open(newline="", encoding="utf-8") as handle:
        return list(csv.DictReader(handle))


def transform(rows: list[dict[str, str]]) -> list[tuple[str, int]]:
    cleaned = []
    for row in rows:
        order_id = row["order_id"].strip()
        try:
            cents = round(float(row["amount"]) * 100)
        except ValueError:
            continue  # skip rows whose amount is not a number
        if order_id and cents > 0:
            cleaned.append((order_id, cents))
    return cleaned


def load(rows: list[tuple[str, int]], database: Path) -> None:
    with sqlite3.connect(database) as connection:
        connection.execute(
            "CREATE TABLE IF NOT EXISTS orders "
            "(order_id TEXT PRIMARY KEY, amount_cents INTEGER)"
        )
        connection.executemany(
            "INSERT OR REPLACE INTO orders VALUES (?, ?)", rows
        )


if __name__ == "__main__":
    load(transform(extract(Path("orders.csv"))), Path("warehouse.db"))

With this input file:

order_id,amount
A100,19.99
A101,not-a-number
A102,5.00
,12.00

the table ends up with two rows (example result): A100 with 1999 cents and A102 with 500 cents. The second row is skipped because the amount is not a number, and the last row is skipped because the order ID is empty.

Two design choices here are worth copying. First, each step is a separate function, so you can test it alone and an orchestrator could later run each one as its own task. Second, the load uses INSERT OR REPLACE on a primary key, so running the script twice on the same file gives the same table instead of duplicate rows. That property is called idempotence, and it is what makes retries safe.

What goes wrong in real pipelines?

  • Bad input. Sources change without warning: a column is renamed, a number arrives as text, a file is empty. Decide for each case whether the pipeline should skip the row, quarantine it, or fail the whole run. A loud failure is usually better than loading wrong data quietly.
  • Duplicates after retries. Orchestrators can retry a failed step. Azure Data Factory, for instance, has an activity policy with a retry count that defaults to 0, a retry interval and a timeout. A retry is only safe if the step is idempotent.
  • Silent partial runs. If step two fails and step three still runs on stale data, the destination looks fine but is wrong. Use explicit dependencies so later steps run only when earlier ones succeeded.
  • No monitoring. A pipeline nobody watches fails without anyone noticing. Alert on failures, and also on a run that never started.

Where to go next

If your destination is a SQL database, SQL for beginners covers the queries you will run on the loaded data. If your sources are JSON files or API responses, Python json.load vs json.loads explains how to read them in the extract step. To turn a CSV into JSON or back while you prototype, the JSON and CSV converter runs in your browser.

For a first pipeline, a script like the one above run by your operating system's scheduler is enough. Move to an orchestrator such as Airflow or Azure Data Factory when you have enough steps, dependencies and failure handling that managing them by hand costs more than learning the tool.

Frequently asked questions

What is the difference between a data pipeline and ETL?
A data pipeline is any automated sequence of steps that moves or processes data. ETL (extract, transform, load) is one specific pattern a pipeline can follow, where data is transformed before it reaches the destination. A pipeline can also just copy data unchanged, or load first and transform afterwards (ELT).
Do I need a tool like Airflow to build a data pipeline?
No. A pipeline can be a single script run by a scheduler such as cron or Windows Task Scheduler. An orchestrator such as Apache Airflow or Azure Data Factory becomes useful when you have many steps with dependencies, retries, schedules and monitoring to manage.
What is the difference between batch and streaming pipelines?
A batch pipeline processes a chunk of data on a schedule, for example once an hour or once a day. A streaming pipeline processes records continuously as they arrive. Batch is simpler to build and debug; streaming is used when results are needed within seconds.
What does idempotent mean for a pipeline?
An idempotent pipeline gives the same final result whether a step runs once or several times on the same input. This matters because retries and re-runs are normal, and a pipeline that inserts duplicate rows each time it is retried produces wrong data.

Sources