Apache Flink features two relational APIs - the Table API and SQL - for unified stream and batch processing. The Table API is a language-integrated query API for Scala and Java that allows the composition of queries from relational operators such as selection, filter, and join in a very intuitive way. Flink’s SQL support is based on Apache Calcite which implements the SQL standard. Queries specified in either interface have the same semantics and specify the same result regardless whether the input is a batch input (DataSet) or a stream input (DataStream).
The Table API and the SQL interfaces are tightly integrated with each other as well as Flink’s DataStream and DataSet APIs. You can easily switch between all APIs and libraries which build upon the APIs. For instance, you can extract patterns from a DataStream using the CEP library and later use the Table API to analyze the patterns, or you might scan, filter, and aggregate a batch table using a SQL query before running a Gelly graph algorithm on the preprocessed data.
Please note that the Table API and SQL are not yet feature complete and are being actively developed. Not all operations are supported by every combination of [Table API, SQL] and [stream, batch] input.
All Table API and SQL components are bundled in the flink-table
Maven artifact.
The following dependencies are relevant for most projects:
flink-table-common
: A common module for extending the table ecosystem by custom functions, formats, etc.flink-table-api-java
: The Table & SQL API for pure table programs using the Java programming language (in early development stage, not recommended!).flink-table-api-scala
: The Table & SQL API for pure table programs using the Scala programming language (in early development stage, not recommended!).flink-table-api-java-bridge
: The Table & SQL API with DataStream/DataSet API support using the Java programming language.flink-table-api-scala-bridge
: The Table & SQL API with DataStream/DataSet API support using the Scala programming language.flink-table-planner
: The table program planner and runtime.flink-table-uber
: Packages the modules above into a distribution for most Table & SQL API use cases. The uber JAR file flink-table*.jar
is located in the /opt
directory of a Flink release and can be moved to /lib
if desired.The following dependencies must be added to a project in order to use the Table API & SQL for defining pipelines:
Additionally, depending on the target programming language, you need to add the Java or Scala API.
Internally, parts of the table ecosystem are implemented in Scala. Therefore, please make sure to add the following dependency for both batch and streaming applications:
If you want to implement a custom format for interacting with Kafka or a set of user-defined functions, the following dependency is sufficient and can be used for JAR files for the SQL Client:
Currently, the module includes extension points for:
SerializationSchemaFactory
DeserializationSchemaFactory
ScalarFunction
TableFunction
AggregateFunction