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

Doris Connector

Overview

The Doris connector is used to read from and write data to the CloudTable Doris database, a table storage service. It supports efficient data writing via Stream Load and data reading through the Doris FE query interface.

Table 1 Connector details

Category

Details

Supported type

Source table, dimension table, and result table

Running mode

Stream mode and batch mode

Data format

Not supported currently

API type

SQL, DataStream

Whether result table can be updated or deleted

Yes

Application Scenarios

  • Real-time data write: Flink writes the real-time data processed by itself to the Doris OLAP table to support real-time report query.
  • Data synchronization: Data from data sources such as Kafka is synchronized to Doris to build a real-time data warehouse.
  • OLAP analysis: Dimension data is read from Doris and associated with real-time streams for analysis.
  • ETL output: The Flink ETL processing result is written to Doris for BI tools to directly query.

Notes and Constraints

  • To enable exactly-once write, you need to enable Flink Checkpoint and set a unique sink.label-prefix.
  • When data is written to Doris, the field type must be compatible with the column type in the Doris table.

Syntax Structure

Source

CREATE TABLE {table_name} (
  {column_name} {column_type},
  ...
) WITH (
  'connector' = 'doris',
  'fenodes' = '{fe_host:http_port}',
  'table.identifier' = '{database}.{table}',
  'username' = '{username}',
  'password' = '{password}'
);

Sink

CREATE TABLE {table_name} (
  {column_name} {column_type},
  ...
) WITH (
  'connector' = 'doris',
  'fenodes' = '{fe_host:http_port}',
  'table.identifier' = '{database}.{table}',
  'username' = '{username}',
  'password' = '{password}',
  'sink.label-prefix' = '{label_prefix}',
  'sink.properties.format' = '{data_format}',
  'sink.enable-delete' = '{enable_delete}'
);

WITH Parameters

Common parameters

Parameter

Mandatory

Type

Default Value

Value Range

Description

connector

Yes

String

None

doris

Specifies that the connector type is Doris.

This parameter is mandatory and must be set to the fixed value doris. The Flink runtime loads the Doris connector factory class based on this value and declares the table as a Doris data source or output table.

fenodes

Yes

String

None

Host:port list

Specifies the HTTP address of the Doris FE node. Use commas (,) to separate multiple addresses.

This parameter is mandatory for both the source and sink. The Flink runtime uses this address to connect to the Doris FE node to obtain the query plan or submit a Stream Load request. You are advised to configure multiple FE addresses to implement high-availability failover.

table.identifier

Yes

String

None

database.table

Specifies the Doris table identifier in the format of database_name.table_name.

This parameter is mandatory for both the source and sink. The Flink runtime uses this identifier to locate the target table in Doris, which determines the data read and write targets.

username

Yes

String

None

Valid username

Specifies the username of the Doris database.

This parameter is mandatory for both the source and sink. The Flink runtime uses this username to authenticate with Doris. You must have the read and write permissions on the corresponding table.

password

Yes

String

None

Valid password

Specifies the password of the Doris database.

This parameter is mandatory for both the source and sink. The Flink runtime uses this password together with the username to authenticate with Doris.

Source parameters

Parameter

Mandatory

Type

Default Value

Value Range

Description

doris.read.field

No

String

None

Column name list

Specifies the columns to be read. Multiple columns are separated by commas (,).

If this parameter is not specified, all columns are read. The Flink runtime pushes down this column list to the SELECT clause of the Doris query SQL statement, reducing unnecessary data transmission and improving read efficiency.

doris.filter.query

No

String

None

SQL filter condition

Specifies the filter condition for reading data, which is pushed down to Doris for execution.

When Flink is running, this condition is appended to the WHERE clause of the Doris query SQL statement to filter data on the Doris side, reducing the amount of data transmitted to Flink.

doris.request.tablet.size

No

Integer

2

Positive integer

Specifies the number of tablets that can be concurrently read from each Doris BE partition.

When Flink is running, tablets are allocated to multiple read subtasks based on this value for parallel execution. Increasing this value can improve the read parallelism but increase the load on the Doris side.

doris.request.connect.timeout.ms

No

Integer

30000

Positive integer

Specifies the timeout interval for connecting to the Doris BE, in milliseconds.

When Flink runtime establishes a connection to the Doris BE, a timeout exception is thrown if the connection is not successfully established within this time. You can increase this value if the network is unstable.

doris.request.read.timeout.ms

No

Integer

30000

Positive integer

Specifies the timeout interval for reading data from the Doris BE, in milliseconds.

When Flink runtime reads data from the Doris BE, a timeout exception is thrown if no response is received within this time. You can increase this value in large query scenarios.

doris.request.query.timeout.s

No

Integer

3600

Positive integer

Specifies the timeout interval for querying Doris, in seconds.

After the Flink runtime submits a query to Doris, if the query is not completed within the specified time, the query is canceled. You can increase this value in full read scenarios for large tables.

doris.request.retries

No

Integer

3

Positive integer

Specifies the number of retry times for requesting Doris.

When a request fails, the Flink runtime automatically retries. If the number of retry times reaches the maximum, an exception is thrown. You can increase this value if the network is unstable.

doris.deserialize.arrow.async

No

Boolean

false

true/false

Specifies whether to deserialize Arrow data asynchronously.

The default value is false, indicating synchronous deserialization. If this parameter is set to true, the Flink runtime uses an independent thread pool to asynchronously convert Arrow to RowData. This increases read throughput but also increases memory consumption.

doris.deserialize.queue.size

No

Integer

64

Positive integer

Specifies the size of the asynchronous deserialization queue.

This parameter takes effect only when doris.deserialize.arrow.async is set to true. In asynchronous deserialization mode, the Flink runtime uses this queue to buffer deserialized data. When the queue is full, the deserialization thread is blocked and waits.

Sink parameters

Parameter

Mandatory

Type

Default Value

Value Range

Description

sink.label-prefix

No

String

None

Valid label prefix

Specifies the label prefix for Stream Load.

You are advised to set a unique prefix for each job to ensure exactly-once semantics. The Flink runtime generates a Stream Load label using the label prefix and a unique identifier. Doris uses the label for deduplication to ensure that the same batch of data is not written repeatedly.

sink.properties.format

No

String

json

json / csv

Specifies the data transfer format for Stream Load.

The default value is json. The Flink runtime serializes Flink row data into the specified format and sends it to the Doris Stream Load API. The json format offers good compatibility, while the csv format results in a smaller data volume.

sink.properties.max_filter_ratio

No

String

0

0–1

Specifies the maximum filtering ratio of Stream Load.

If the filtering ratio of a batch of data exceeds this value, the entire batch fails to be written. After Stream Load is complete, the Flink runtime checks the filtering ratio. If the ratio exceeds the threshold, an exception is thrown and the batch is retried. If this parameter is set to 0, no filtering error is allowed.

sink.enable-delete

No

Boolean

true

true/false

Controls whether to enable the delete operation.

The default value is false. After this parameter is enabled, the retract records (-U and -D) of Flink are converted into the DELETE operation of Doris. When Flink serializes records, it generates Doris delete markers for retract records instead of common writes. Only the Doris Unique Key model table supports the delete operation.

sink.buffer-size

No

MemorySize

1 MB

Valid memory size, for example, 128 MB or 256 MB.

Sets the size of the sink buffer.

Flink buffers data in memory during runtime. When the buffer is full, a Stream Load submission is triggered. Increasing this value reduces the number of submissions and improves throughput, but it also increases memory usage and data latency.

sink.buffer.count

No

Integer

3

Positive integer

Sets the number of sink buffers.

Flink maintains multiple buffers and uses them in turn during runtime. When one buffer is being submitted, other buffers continue to receive data. Increasing this value improves write concurrency, but it also increases memory usage.

sink.max-retries

No

Integer

1

Positive integer

Specifies the maximum number of retry attempts for failed writes.

When a Stream Load submission fails during Flink runtime, the system automatically retries. The job fails if the maximum number of retries is exhausted. You can increase this value when the network or Doris is unstable.

sink.check-interval

No

Duration

0s

Valid duration, for example, 30 seconds or 5 minutes.

Specifies the interval for checking whether the buffer needs to be flushed, in milliseconds.

During Flink runtime, a background thread is started to check the buffer status at this interval. When the flush conditions are met, a Stream Load submission is triggered. A shorter interval results in lower data latency but higher check overhead.

Lookup parameters

Parameter

Mandatory

Type

Default Value

Value Range

Description

lookup.cache.max-rows

No

Long

-1

Positive integer

Specifies the maximum number of rows in the dimension table lookup cache.

This parameter is valid only in the Lookup JOIN scenario. The Flink runtime maintains an LRU cache in memory. When the number of cached rows reaches this upper limit, the least recently accessed record is evicted. Increasing this value improves the query hit ratio but increases memory consumption.

lookup.cache.ttl

No

Duration

10s

Positive integer + time unit

Specifies the time to live (TTL) for the dimension table lookup cache.

This parameter is valid only in the Lookup JOIN scenario. When the TTL of cached records expires, Flink invalidates the records and loads them from Doris again during the next access. This balances data timeliness and query performance.

lookup.max-retries

No

Integer

1

Positive integer

Specifies the maximum number of retries for dimension table query.

When Flink fails to query Doris, it automatically retries. If the number of retries reaches the maximum, an exception is thrown. You can increase the value of this parameter if the Doris load is high.

jdbc-url

Yes

String

None

None

Specifies the MySQL protocol address for connecting to Doris.

Usage Example

  • Example 1: Read data from the Doris table in batches.
    -- Create a Doris source table.
    CREATE TABLE doris_source (
      user_id BIGINT,
      user_name STRING,
      age INT,
      city STRING
    ) WITH (
      'connector' = 'doris',
      'fenodes' = 'doris-fe:8030',
      'table.identifier' = 'user_db.user_info',
      'username' = 'root',
      'password' = 'xxxx'
    );
    
    -- Create the Print result table.
    CREATE TABLE print_sink (
      user_id BIGINT,
      user_name STRING,
      age INT,
      city STRING
    ) WITH (
      'connector' = 'print',
      'print-identifier' = 'doris-data'
    );
    
    -- Submit the job.
    INSERT INTO print_sink
    SELECT user_id, user_name, age, city
    FROM doris_source;
  • Example 2: Write data to the Doris table in JSON format.
    -- Create a DataGen source table.
    CREATE TABLE datagen_source (
      user_id BIGINT,
      event_type STRING,
      event_time TIMESTAMP(3),
      event_count BIGINT
    ) WITH (
      'connector' = 'datagen',
      'rows-per-second' = '100',
      'fields.user_id.kind' = 'sequence',
      'fields.user_id.start' = '1',
      'fields.user_id.end' = '100000',
      'fields.event_count.kind' = 'sequence',
      'fields.event_count.start' = '1',
      'fields.event_count.end' = '100'
    );
    
    -- Create the Doris result table.
    CREATE TABLE doris_sink (
      user_id BIGINT,
      event_type STRING,
      event_time TIMESTAMP(3),
      event_count BIGINT
    ) WITH (
      'connector' = 'doris',
      'fenodes' = 'doris-fe:8030',
      'table.identifier' = 'analytics_db.user_events',
      'username' = 'root',
      'password' = 'xxxx',
      'sink.label-prefix' = 'flink-user-events',
      'sink.properties.format' = 'json',
      'sink.max-retries' = '3'
    );
    
    -- Submit the job.
    INSERT INTO doris_sink
    SELECT user_id, event_type, event_time, event_count
    FROM datagen_source;
  • Example 3: Consume real-time event data from Kafka, perform aggregation, and write the results to Doris to support real-time OLAP queries.
    -- Kafka source table
    CREATE TABLE kafka_event_source (
      user_id BIGINT,
      event_type STRING,
      page_url STRING,
      event_time TIMESTAMP(3),
      WATERMARK FOR event_time AS event_time - INTERVAL '5' SECOND
    ) WITH (
      'connector' = 'kafka',
      'topic' = 'user-events',
      'properties.bootstrap.servers' = 'kafka-broker:9092',
      'properties.group.id' = 'doris-writer',
      'scan.startup.mode' = 'latest-offset',
      'format' = 'json',
      'json.ignore-parse-errors' = 'true'
    );
    
    -- Doris result table
    CREATE TABLE doris_event_sink (
      window_start TIMESTAMP(3),
      window_end TIMESTAMP(3),
      event_type STRING,
      event_count BIGINT,
      unique_users BIGINT
    ) WITH (
      'connector' = 'doris',
      'fenodes' = 'doris-fe:8030',
      'table.identifier' = 'analytics_db.event_stats',
      'username' = 'root',
      'password' = 'xxxx',
      'sink.label-prefix' = 'flink-event-stats',
      'sink.properties.format' = 'json',
      'sink.enable-delete' = 'false'
    );
    
    -- 5-minute window aggregation and write
    INSERT INTO doris_event_sink
    SELECT
      window_start AS window_start,
      window_end AS window_end,
      event_type,
      COUNT(*) AS event_count,
      COUNT(DISTINCT user_id) AS unique_users
    FROM TABLE(
      HOP(TABLE kafka_event_source, DESCRIPTOR(event_time), INTERVAL '1' MINUTE, INTERVAL '5' MINUTE)
    )
    GROUP BY window_start, window_end, event_type;
  • Example 4: Use a Doris table as a dimension table and associate it with Kafka real-time streams through Lookup JOIN.
    -- Doris dimension table
    CREATE TABLE doris_dim (
      user_id BIGINT,
      user_name STRING,
      city STRING,
      PRIMARY KEY (user_id) NOT ENFORCED
    ) WITH (
      'connector' = 'doris',
      'fenodes' = 'doris-fe:8030',
      'table.identifier' = 'user_db.user_info',
      'jdbc-url' = 'jdbc:mysql://<FE-instance-IP-address>:<FE-query-connection-port>',
      'username' = 'root',
      'password' = 'xxxx',
      'lookup.cache.max-rows' = '10000',
      'lookup.cache.ttl' = '10min'
    );
    
    -- Kafka real-time stream
    CREATE TABLE kafka_realtime_source (
      user_id BIGINT,
      event_type STRING,
      event_time TIMESTAMP(3),
      proctime AS PROCTIME()
    ) WITH (
      'connector' = 'kafka',
      'topic' = 'events',
      'properties.bootstrap.servers' = 'kafka-broker:9092',
      'properties.group.id' = 'doris-lookup',
      'scan.startup.mode' = 'earliest-offset',  
      'format' = 'json'
    );
    
    -- Create the Print result table.
    CREATE TABLE print_sink (
      user_id BIGINT,
      user_name STRING,
      city STRING,
      event_type STRING,
      event_time TIMESTAMP(3)
    ) WITH (
      'connector' = 'print',
      'print-identifier' = 'doris-lookup-result'
    );
    
    -- Submit the job: Output after Lookup JOIN.
    INSERT INTO print_sink
    SELECT e.user_id, d.user_name, d.city, e.event_type, e.event_time
    FROM kafka_realtime_source e
    LEFT JOIN doris_dim FOR SYSTEM_TIME AS OF e.proctime AS d
    ON e.user_id = d.user_id;
  • Example 5: Enable the delete capability of the Doris sink to convert Flink retraction records into Doris delete operations.
    -- Create a DataGen source table.
    CREATE TABLE datagen_source (
      user_id BIGINT,
      user_name STRING,
      city STRING
    ) WITH (
      'connector' = 'datagen',
      'rows-per-second' = '100',
      'fields.user_id.kind' = 'sequence',
      'fields.user_id.start' = '1',
      'fields.user_id.end' = '10000',
      'fields.user_name.length' = '10'
    );
    
    -- Create the Doris Upsert result table.
    CREATE TABLE doris_upsert_sink (
      user_id BIGINT,
      user_name STRING,
      city STRING,
      PRIMARY KEY (user_id) NOT ENFORCED
    ) WITH (
      'connector' = 'doris',
      'fenodes' = 'doris-fe:8030',
      'table.identifier' = 'user_db.user_info',
      'username' = 'root',
      'password' = 'xxxx',
      'sink.label-prefix' = 'flink-user-upsert',
      'sink.properties.format' = 'json',
      'sink.enable-delete' = 'true'
    );
    
    -- Submit the job.
    INSERT INTO doris_upsert_sink
    SELECT user_id, user_name, city
    FROM datagen_source;