This file provides guidance for AI coding agents working with the Apache Flink codebase.
flink-tests-java17 module../mvnw included; prefer it)./mvnw clean install -DskipTests -Dfast -Pskip-webui-build -T1C./mvnw clean package -DskipTests -Djdk17 -Pjava17-target./mvnw clean package -DskipTests -Djdk11 -Pjava11-target./mvnw clean package -DskipTests -Djdk21 -Pjava21-target./mvnw clean verify./mvnw clean package -DskipTests -pl flink-core-api./mvnw clean verify -pl flink-core-api./mvnw -pl flink-core-api -Dtest=MemorySizeTest test./mvnw -pl flink-core-api -Dtest=MemorySizeTest#testParseBytes test./mvnw spotless:apply./mvnw spotless:check./mvnw checkstyle:check -T1Ctools/maven/checkstyle.xmlEvery module from the root pom.xml, organized by function. Flink provides three main user-facing APIs (recommended in this order: SQL, Table API, DataStream API) plus a newer DataStream v2 API.
flink-annotations — Stability annotations (@Public, @PublicEvolving, @Internal, @Experimental) and @VisibleForTestingflink-core-api — Core API interfaces (functions, state, types) shared by all APIsflink-core — Core implementation (type system, serialization, memory management, configuration)flink-runtime — Distributed runtime (JobManager, TaskManager, scheduling, network, state)flink-clients — CLI and client-side job submissionflink-rpc/ — RPC frameworkflink-rpc-core — RPC interfacesflink-rpc-akka, flink-rpc-akka-loader — Pekko-based RPC implementationflink-table/flink-sql-parser — SQL parser (extends Calcite SQL parser)flink-table-common — Shared types, descriptors, catalog interfacesflink-table-api-java — Table API for Javaflink-table-api-scala — Table API for Scalaflink-table-api-bridge-base, flink-table-api-java-bridge, flink-table-api-scala-bridge — Bridges between Table and DataStream APIsflink-table-api-java-uber — Uber JAR for Table APIflink-table-planner — SQL/Table query planning and optimization (Calcite-based)flink-table-planner-loader, flink-table-planner-loader-bundle — Classloader isolation for plannerflink-table-runtime — Runtime operators for Table/SQL queriesflink-table-calcite-bridge — Bridge to Apache Calciteflink-sql-gateway-api, flink-sql-gateway — SQL Gateway for remote SQL executionflink-sql-client — Interactive SQL CLIflink-sql-jdbc-driver, flink-sql-jdbc-driver-bundle — JDBC driver for SQL Gatewayflink-table-code-splitter — Code generation utilitiesflink-table-test-utils — Test utilities for Table/SQLflink-streaming-java — DataStream API and stream processing operator implementationsflink-datastream-api — DataStream v2 API definitionsflink-datastream — DataStream v2 API implementationflink-connectors/flink-connector-base — Base classes for source/sink connectorsflink-connector-files — Unified file system source and sinkflink-connector-datagen — DataGen source for testingflink-connector-datagen-test — Tests for DataGen connectorflink-hadoop-compatibility — Hadoop InputFormat/OutputFormat compatibilityflink-file-sink-common — Common file sink utilitiesflink-formats/flink-json, flink-csv, flink-avro, flink-parquet, flink-orc, flink-protobuf — Serialization formatsflink-avro-confluent-registry — Avro with Confluent Schema Registryflink-sequence-file, flink-compress, flink-hadoop-bulk, flink-orc-nohive — Hadoop-related formatsflink-format-common — Shared format utilitiesflink-sql-json, flink-sql-csv, flink-sql-avro, flink-sql-parquet, flink-sql-orc, flink-sql-protobuf — SQL-layer format integrationsflink-sql-avro-confluent-registry — SQL-layer Avro with Confluent Schema Registryflink-state-backends/flink-statebackend-rocksdb — RocksDB state backendflink-statebackend-forst — ForSt state backend (experimental; a fork of RocksDB)flink-statebackend-heap-spillable — Heap-based spillable state backendflink-statebackend-changelog — Changelog state backendflink-statebackend-common — Shared state backend utilitiesflink-dstl/flink-dstl-dfs — State changelog storage (DFS-based persistent changelog for incremental checkpointing)flink-filesystems/flink-hadoop-fs — Hadoop FileSystem abstractionflink-s3-fs-hadoop, flink-s3-fs-presto, flink-s3-fs-base — S3 file systemsflink-oss-fs-hadoop — Alibaba OSSflink-azure-fs-hadoop — Azure Blob Storageflink-gs-fs-hadoop — Google Cloud Storageflink-fs-hadoop-shaded — Shaded Hadoop dependenciesflink-queryable-state/flink-queryable-state-runtime — Server-side queryable state serviceflink-queryable-state-client-java — Client for querying operator state from running jobsflink-kubernetes — Kubernetes integrationflink-yarn — YARN integrationflink-dist, flink-dist-scala — Distribution packagingflink-container — Container entry-point and utilities for containerized deploymentsflink-metrics/flink-metrics-core — Metrics API and core implementationflink-metrics-jmx, flink-metrics-prometheus, flink-metrics-datadog, flink-metrics-statsd, flink-metrics-graphite, flink-metrics-influxdb, flink-metrics-slf4j, flink-metrics-dropwizard, flink-metrics-otelflink-libraries/flink-cep — Complex Event Processingflink-state-processing-api — Offline state access (savepoint reading/writing)flink-models — AI model integration (sub-module: flink-model-openai)flink-python — PyFlink (Python API)flink-runtime-web — Web UI for JobManager dashboardflink-external-resources — External resource management (e.g., GPU)docs/ — Documentation content (Hugo site). This is where user-facing docs are written.flink-docs — Documentation build module (auto-generated config reference docs)flink-examples — Example programsflink-quickstart — Maven archetype for new projectsflink-walkthroughs — Tutorial walkthrough projectsflink-tests — Integration testsflink-end-to-end-tests — End-to-end testsflink-test-utils-parent — Test utility classesflink-yarn-tests — YARN-specific testsflink-fs-tests — FileSystem testsflink-architecture-tests — ArchUnit architectural boundary teststools/ci/flink-ci-tools — CI toolingbin/flink run via flink-clients), the SQL Client (bin/sql-client.sh via flink-sql-client), the SQL Gateway (flink-sql-gateway, also accessible via JDBC driver), the REST API (direct HTTP to JobManager), programmatic execution (StreamExecutionEnvironment.execute() or TableEnvironment.executeSql()), and PyFlink (flink-python, wraps the Java APIs).flink-runtime) orchestrates execution: receives jobs, creates the execution graph, manages scheduling, coordinates checkpoints, and handles failover. Never runs user code directly.flink-runtime) executes the user's operators in task slots. Manages network buffers, state backends, and I/O.flink-table-planner) translates SQL/Table API programs into DataStream programs. The planner is loaded in a separate classloader (flink-table-planner-loader) to isolate Calcite dependencies.Source API (FLIP-27); sinks implement the Sink API (package sink2). Most connectors are externalized to separate repositories.Key separations:
flink-table-planner; changes to runtime operators live in flink-table-runtime or flink-streaming-java.flink-table-planner/.../functions/casting/ and call generators in flink-table-planner/.../codegen/calls/, then compiled by Janino into the surrounding operator class. Operators with fixed structure (joins, aggregations, source/sink runtime) are hand-written Java in flink-table-runtime or flink-streaming-java. New scalar functions usually only need a BuiltInFunctionDefinitions entry plus a BuiltInScalarFunction subclass - the planner wires up codegen automatically. New cast behaviour or a custom call shape needs a cast rule or call generator.flink-core-api, flink-datastream-api, flink-table-api-java) are separate from implementation modules. API stability annotations control what users can depend on.flink-architecture-tests/ contains ArchUnit tests that enforce module boundaries. New violations should be avoided; if unavoidable, follow the freeze procedure in flink-architecture-tests/README.md.This section maps common types of Flink changes to the modules they touch and the verification they require.
flink-table-common in BuiltInFunctionDefinitions.java (definition, input/output type strategies, runtime class reference)flink-table-runtime under functions/ (extend the appropriate base class: BuiltInScalarFunction, BuiltInTableFunction, BuiltInAggregateFunction, or BuiltInProcessTableFunction)flink-table-planner and flink-table-runtimedocs/ConfigOption<T> in the relevant config class (e.g., ExecutionConfigOptions.java in flink-table-api-java)ConfigOptions.key("table.exec....") builder with type, default value, and description@Documentation.TableOption annotation for auto-generated docsdocs/ if user-facingflink-table-runtime (operator), flink-table-planner (ExecNode, physical/logical rules), and tests across bothSource API (flink-connector-base): SplitEnumerator, SourceReader, SourceSplit, serializers (SimpleVersionedSerializer)Sink API (package sink2) for sinksgithub.com/apache, not in the main Flink repoTypeSerializer require a corresponding TypeSerializerSnapshot for migrationgetCurrentVersion(), handle old versions in readSnapshot()resolveSchemaCompatibility() for upgrade paths@Public, @PublicEvolving, @Experimental)@Public, @PublicEvolving, and @Experimental since users build against all three@Public or @PublicEvolving API must maintain backward compatibility@Internal APIs can be changed freely; users should not depend on them./mvnw spotless:apply. Uses google-java-format with AOSP style..scalafmt.conf, maxColumn 100).tools/maven/checkstyle.xml (version defined in root pom.xml as checkstyle.version). Some modules (flink-core, flink-optimizer, flink-runtime) are not covered by checkstyle enforcement, but conventions should still be followed.@Public (stable across minor releases), @PublicEvolving (may change in minor releases), @Experimental (may change at any time). These are all part of the public API surface that users build against. @Internal marks APIs with no stability guarantees that users should not depend on.{} placeholders), never string concatenation.final for variables and fields where applicable.ITCase suffix (e.g., MyFeatureITCase.java).[FLINK-XXXX][component] Description where FLINK-XXXX is the JIRA issue number[hotfix][component] Description for typo fixes without JIRAGenerated-by: <Tool Name and Version> trailer per ASF generative tooling guidance[FLINK-XXXX][component] Title of the pull request./mvnw clean verify passes before opening a PRapache/flinkdocs/content/release-notes/flink-X.Y.md will be generated based of the jira tickets, so make sure to fill them in properly.Generated-by line in the PR templateGenerated-by: <Tool Name and Version> to commit messagesCo-Authored-By with an AI agent as co-author; agents are assistants, not authors@Public, @PublicEvolving, or @Experimental annotations (these are user-facing API commitments requiring a FLIP)apache/flink; always work from your forkSourceFunction or SinkFunction interfaces for connectors; use the Source API (FLIP-27) and Sink API (package sink2) insteadCo-Authored-By with an AI agent as co-author in commit messages; AI agents are assistants, not authors. Use Generated-by: <Tool Name and Version> instead.CHECKSTYLE:ON/CHECKSTYLE:OFF comments, no adding entries to tools/maven/suppressions.xml, no @SuppressWarnings). Fix the code to satisfy checkstyle instead.org.apache.flink.* package (for example, classes copied from Calcite)Parser.jj (Calcite's generated parser grammar; expected to be removed in future Calcite upgrades)