Apache Iceberg 支持Apache Flink的DataStream API 和 Table API 将记录写入 iceberg 的表,当前,我们只提供 iceberg 与 apache flink 1.11.x 的集成支持。
Feature support | Flink 1.11.0 | Notes |
---|---|---|
SQL create catalog | ✔️ | |
SQL create database | ✔️ | |
SQL create table | ✔️ | |
SQL alter table | ✔️ | Only support altering table properties, Columns/PartitionKey changes are not supported now |
SQL drop_table | ✔️ | |
SQL select | ✔️ | Only support batch mode now. |
SQL insert into | ✔️ ️ | Support both streaming and batch mode |
SQL insert overwrite | ✔️ ️ | |
DataStream read | ✔️ ️ | |
DataStream append | ✔️ ️ | |
DataStream overwrite | ✔️ ️ | |
Metadata tables | ️ |
准备
为了在 Flink 中创建 iceberg 表,我们推荐使用Flink SQL Client以便用户更容易理解概念。
第一步,在 apache flinkdownload page页面下载 flink 1.11.x binary 包,我们当前使用 scala 2.12 来实现 apache iceberg-flink-runtime jar,因此推荐使用绑定 scala 2.12 的 flink 1.11。
wget https://downloads.apache.org/flink/flink-1.11.1/flink-1.11.1-bin-scala_2.12.tgz tar xzvf flink-1.11.1-bin-scala_2.12.tgz
第二步,启动一个基于 Hadoop 环境 的 standalone 模式的 flink 集群。
# HADOOP_HOME is your hadoop root directory after unpack the binary package. export HADOOP_CLASSPATH=`$HADOOP_HOME/bin/hadoop classpath`
# Start the flink standalone cluster
./bin/start-cluster.sh
第三步,启动 flink SQL client。
我们已经在 iceberg 项目中创建独立的 flink-runtime 模块来生成一个捆绑的 jar, 可以直接被 flink SQL client加载。
如果我们要手动构建 flink-runtime 的 jar,那么只需要构建一个 iceberg 工程,它就会在 /flink-runtime/build/libs 下生成 jar。当然,我们也可以从 apache 官方仓库下载 flink-runtime jar。
# HADOOP_HOME is your hadoop root directory after unpack the binary package.
export HADOOP_CLASSPATH=`$HADOOP_HOME/bin/hadoop classpath`
.<