This documentation is for an unreleased version of Apache Flink. We recommend you use the latest stable version.
Table API #
The Table API is a language-integrated query API for Java, Scala, and Python that allows the composition of queries from relational operators such as selection, filter, and join in a very intuitive way. It shares the same underlying engine as Flink SQL, meaning queries specified in either interface have the same semantics and specify the same result regardless of whether the input is continuous (streaming) or bounded (batch).
The Table API and SQL integrate seamlessly with each other and Flink’s DataStream API. You can easily switch between all APIs and libraries which build upon them. For instance, you can detect patterns from a table using the MATCH_RECOGNIZE clause and later use the DataStream API to build alerting based on the matched patterns.
When to Use the Table API #
Use the Table API when you want to:
- Write relational queries in Java, Scala, or Python code
- Compose queries programmatically with type-safe operators
- Combine SQL statements with programmatic table operations
- Integrate with the DataStream API for mixed use cases
For pure SQL usage without programming, see Flink SQL.
Table Program Dependencies #
You will need to add the Table API as a dependency to a project in order to use the Table API for defining data pipelines.
For more information on how to configure these dependencies for Java and Scala, please refer to the project configuration section.
If you are using Python, please refer to the PyFlink documentation.
Where to Go Next #
- Concepts & Common API: Shared concepts and APIs of the Table API and SQL.
- Data Types: Lists pre-defined data types and their properties.
- Streaming Concepts: Streaming-specific documentation for the Table API or SQL such as configuration of time attributes and handling of updating results.
- Connect to External Systems: Available connectors and formats for reading and writing data to external systems.
- Table API Operations: Supported operations and API for the Table API.
- SQL Reference: Supported operations and syntax for SQL.
- Built-in Functions: Supported functions in Table API and SQL.
- PyFlink: Python-specific Flink documentation.