Skip to main content
Last updated on

Reading Data from Doris

Flink Doris Connector can use a Doris table as the source of a Flink job. By default it reads a bounded snapshot of the table; to continuously read row-level changes, see Incremental Reading with Doris Binlog.

Read Principle

FlinkConnectorPrinciples-JDBC-Doris

Compared to Flink JDBC Connector, Flink Doris Connector offers higher performance when reading data and is recommended:

  • Flink JDBC Connector: Although Doris is compatible with the MySQL protocol, reading and writing through JDBC causes data to be read and written serially on a single FE node, creating a bottleneck that affects performance. It is not recommended.
  • Flink Doris Connector: Starting from Doris 2.1, the ADBC protocol is used as the default read protocol. The read process is as follows:
    1. Flink Doris Connector obtains the Tablet ID information in the query plan from FE.
    2. Generates the query statement SELECT * FROM tbs TABLET(id1, id2, id3).
    3. Executes the query through FE's ADBC port.
    4. BE returns data directly, avoiding data flow through FE and eliminating the FE single-point bottleneck.

Read Protocols

The following two read protocols are supported:

ProtocolDescriptionRecommended Version
ThriftReads data by calling BE's thrift interfaceCompatible with all versions
ArrowFlightSQLReads large batches of data at high speed via the Arrow Flight SQL protocol, based on Doris 2.1Connector 24.0.0+

Thrift Method

CREATE TABLE student (
id INT,
name STRING,
age INT
)
WITH (
'connector' = 'doris',
'fenodes' = '127.0.0.1:8030', -- FE host:HttpPort
'table.identifier' = 'test.student',
'username' = 'root',
'password' = ''
);

SELECT * FROM student;

Arrow Flight SQL Method

CREATE TABLE student (
id INT,
name STRING,
age INT
)
WITH (
'connector' = 'doris',
'fenodes' = '{fe.conf:http_port}',
'table.identifier' = 'test.student',
'source.use-flight-sql' = 'true',
'source.flight-sql-port' = '{fe.conf:arrow_flight_sql_port}',
'username' = 'root',
'password' = ''
);

SELECT * FROM student;

DataStream API Read

For reading with DorisSource, see DataStream API.

Options

The general connection options are listed in Connection Options and TLS; the options for incremental reading are listed in Incremental Reading with Doris Binlog.

KeyDefault ValueRequiredComment
doris.request.query.timeout21600sNTimeout for querying Doris. The default value is 6 hours.
doris.request.tablet.size1NThe number of Doris Tablets corresponding to one Partition. The smaller this value is set, the more Partitions will be generated, increasing parallelism on the Flink side, but also placing more pressure on Doris.
doris.batch.size4064NThe maximum number of rows read from BE at a time. Increasing this value can reduce the number of connections established between Flink and Doris, thereby reducing the additional time overhead caused by network latency.
doris.exec.mem.limit8192mbNMemory limit for a single query. The default is 8GB, in bytes.
source.use-flight-sqlTRUENWhether to use Arrow Flight SQL for reading
source.flight-sql-port-NWhen using Arrow Flight SQL for reading, the FE's arrow_flight_sql_port

DataStream-Specific Configuration

KeyDefault ValueRequiredComment
doris.read.field--NList of column names to read from the Doris table, separated by commas
doris.filter.query--NAn expression to filter the data being read; this expression is passed through to Doris, which uses it to filter data at the source. For example, age=18.