---
title: "Apache Flink"
description: "Apache Flink is an open-source distributed engine for stateful stream processing, treating data as continuous streams with low-latency, event-at-a-time computation."
canonical: "https://motherduck.com/glossary/apache-flink/"
related:
  - title: "DuckLake Architecture Deep Dive"
    url: "https://motherduck.com/blog/ducklake-architecture-deep-dive/"
  - title: "Streamkap + MotherDuck Integration | DuckDB Analytics"
    url: "https://motherduck.com/ecosystem/streamkap/"
  - title: "Build a Data Pipeline With an AI Agent | MotherDuck | MotherDuck"
    url: "https://motherduck.com/videos/build-data-pipeline-ai-agent-flights/"
gated_asset:
  title: "DuckLake on MotherDuck"
  url: "https://motherduck.com/product/ducklake/"
---

# Apache Flink

> Apache Flink is an open-source distributed engine for stateful stream processing, treating data as continuous streams with low-latency, event-at-a-time computation.

## Overview

Apache Flink is an open-source framework and distributed engine for stateful computations over data streams. It originated from the Stratosphere research project (led out of TU Berlin), was renamed Flink and donated to the Apache Software Foundation, and became a top-level Apache project in 2014. Flink is built for stream processing first: it processes events as they arrive, one at a time, rather than as scheduled micro-batches, which enables low-latency, continuous computation.

## Streaming model

Flink treats bounded (batch) data as a special case of unbounded (streaming) data, so the same engine handles both. Key capabilities include:

- **Event-time processing** — computing results based on when events actually occurred, with watermarks to handle out-of-order and late data.
- **Stateful operators** — maintaining large, fault-tolerant state, with consistency provided by periodic checkpoints.
- **Windowing** — grouping events into time or count windows for aggregation.

Flink exposes layered APIs, including the DataStream API and Flink SQL / Table API for expressing stream and batch logic in SQL.

```sql
-- Flink SQL: a tumbling window aggregation over a stream
SELECT window_start, COUNT(*) AS events
FROM TABLE(
  TUMBLE(TABLE clicks, DESCRIPTOR(event_time), INTERVAL '1' MINUTE))
GROUP BY window_start;
```

## Where Flink fits

Flink is a processing engine for continuous, real-time transformation and aggregation of streams, often reading from and writing to systems like Apache Kafka. It is distinct from analytical query engines used for querying data at rest. Streaming pipelines built with Flink frequently land their output in object storage or a warehouse, where an OLAP engine such as DuckDB or MotherDuck can then run analytical SQL over the results.
