Updated on 2026-06-27 GMT+08:00

Flink SQL HBase Batch Lookup Join

Scenarios

Lookup Join is a data connection mode of Flink SQL. It is used to join the input stream with the dimension tables in a remote database. Each record in the input stream will be queried in the dimension tables to update the data status. However, frequent I/O operations affect job performance. Enabling Batch Lookup can greatly reduce I/O operations and lower the pressure on the remote database, thereby improving the throughput of Flink jobs.

Notes and Constraints

  • This section applies only to MRS 3.6.0-LTS and later.
  • Batch Lookup uses the memory cache. A too large batch size may cause high memory consumption, especially in asynchronous mode.
  • Batch Lookup already adopts the Minibatch mechanism of Flink. Therefore, you cannot enable Minibatch when using Batch Lookup.

How to Use

To enable Batch Lookup optimization, you can add the custom parameter table.exec.batch-lookup.enabled and set it to true when configuring a Flink job on the FlinkServer web UI. For details, see Creating a FlinkServer Job.

Example SQL statement:
CREATE TABLE hbaseTable (
  -- Use HBase as the dimension table.
  user_id STRING,
  f1 ROW < address STRING >,
  PRIMARY KEY (user_id) NOT ENFORCED
) WITH (
  'connector' = 'hbase-2.2',
  'table-name' = 'hbase_dim_table',
  'lookup.batch' = 'true',  -- Enable HBase Batch Lookup.
  'lookup.batch.size' = '1000',  -- Set the batch size.
  'zookeeper.quorum' = 'Service IP address 1 of the ZooKeeper quorumpeer instance:ZooKeeper client port number,'Service IP address 2 of the ZooKeeper quorumpeer instance:ZooKeeper client port number'
);
CREATE TABLE datagen (
  `user_id` STRING,
  `user_name` STRING,
  proctime as proctime()
) WITH (
  'connector' = 'datagen',
  'rows-per-second' = '100000',
  'fields.user_id.kind' = 'sequence',
  'fields.user_id.start' = '1',
  'fields.user_id.end' = '1000000',
  'fields.user_name.length' = '15'
);
CREATE TABLE print (
  -- Use Kafka as the sink table.
  `user_id` VARCHAR,
  `user_name` VARCHAR,
  `address` VARCHAR
) WITH ('connector' = 'print');
INSERT INTO
  print
SELECT
  t.user_id,
  t.user_name,
  d.address
FROM
  datagen as t
  JOIN hbaseTable FOR SYSTEM_TIME AS OF t.proctime as d ON t.user_id = d.user_id;
  • IP address of the ZooKeeper quorumpeer instance

    To obtain IP addresses of all ZooKeeper quorumpeer instances, log in to FusionInsight Manager and choose Cluster > Services > ZooKeeper. On the displayed page, click Instances and check the IP addresses of all the hosts where the quorumpeer instances are located.

  • Port number of the ZooKeeper client

    To obtain the port number of the ZooKeeper client, log in to FusionInsight Manager and choose Cluster > Services > ZooKeeper. On the displayed page, click Configurations and check the value of clientPort.