Supported data file formats
Routine Load supports consuming CSV and JSON formatted data from a Pulsar cluster.NOTE As for data in CSV format, the database supports UTF-8 encoded strings within 50 bytes as column separators. Commonly used column separators include comma (,), tab and pipe (|).
Pulsar-related concepts
Topic Topics in Pulsar are named channels for transmitting messages from producers to consumers. Topics in Pulsar are divided into partitioned topics and non-partitioned topics.- Partitioned topics are a special type of topic that are handled by multiple brokers, thus allowing for higher throughput. A partitioned topic is actually implemented as N internal topics, where N is the number of partitions.
- Non-partitioned topics are a normal type of topic that are served only by a single broker, which limits the maximum throughput of the topic.
ledgerId:entryID:partition-index:batch-index.
Therefore, you can’t get the Message ID directly from the message. As a result, at present, Routine Load does not support specifying initial position when loading data from Pulsar, but only supports consuming data from the beginning or end of a partition.
Subscription
A subscription is a named configuration rule that determines how messages are delivered to consumers. Pulsar also supports consumers simultaneously subscribing to multiple topics. A topic can have multiple subscriptions.
The type of a subscription is defined when a consumer connects to it, and the type can be changed by restarting all consumers with a different configuration. Four subscription types are available in Pulsar:
exclusive(default): Only a single consumer is allowed to attach to the subscription. Only one customer is allowed to consume messages.shared: Multiple consumers can attach to the same subscription. Messages are delivered in a round robin distribution across consumers, and any given message is delivered to only one consumer.failover: Multiple consumers can attach to the same subscription. A master consumer is picked for a non-partitioned topic or each partition of a partitioned topic and receives messages. When the master consumer disconnects, all (non-acknowledged and subsequent) messages are delivered to the next consumer in line.key_shared: Multiple consumers can attach to the same subscription. Messages are delivered in a distribution across consumers and message with same key or same ordering key are delivered to only one consumer.
Note: Currently Routine Load uses exclusive type.
Create a Routine Load job
The following examples describe how to consume CSV-formatted messages in Pulsar, and load the data into the database by creating a Routine Load job. For detailed instruction and reference, see CREATE ROUTINE LOAD.data_source_properties are the same as consuming data from Kafka . For descriptions about parameters except data_source_properties data_source_properties , see CREATE ROUTINE LOAD.
The parameters related to data_source_properties and their descriptions are as follows:
Routine Load supports the following custom parameters for Pulsar.
Check a load job and task
Check a load job
Execute the SHOW ROUTINE LOAD statement to check the status of the load jobroutine_wiki_edit_1. The database returns the execution state State, the statistical information (including the total rows consumed and the total rows loaded) Statistics, and the progress of the load job progress.
When you check a Routine Load job that consumes data from Pulsar, most returned parameters except for progress are the same as consuming data from Kafka. progress refers to backlog, that is the number of unacked messages in a partition.
Check a load task
Execute the SHOW ROUTINE LOAD TASK statement to check the load tasks of the load jobroutine_wiki_edit_1, such as how many tasks are running, the Kafka topic partitions that are consumed and the consumption progress DataSourceProperties, and the corresponding Coordinator BE node BeId.
Alter a load job
Before altering a load job, you must pause it by using the PAUSE ROUTINE LOAD statement. Then you can execute the ALTER ROUTINE LOAD. After altering it, you can execute the RESUME ROUTINE LOAD statement to resume it, and check its status by using the SHOW ROUTINE LOAD statement. When Routine Load is used to consume data from Pulsar, most returned parameters except fordata_source_properties are the same as consuming data from Kafka.
Take note of the following points:
- Among the
data_source_propertiesrelated parameters, onlypulsar_partitions,pulsar_initial_positions, and custom Pulsar parametersproperty.pulsar_default_initial_positionandproperty.auth.tokenare currently supported to be modified. The parameterspulsar_service_url,pulsar_topic, andpulsar_subscriptioncannot be modified. - If you need to modify the partition to be consumed and the matched initilal position, you need to make sure that you specify the partition using
pulsar_partitionswhen you create the Routine Load job, and only the intial positionpulsar_initial_positionsof the specified partition can be modified. - If you specify only Topic
pulsar_topicwhen creating a Routine Load job, but not partitionspulsar_partitions, you can modify the starting position of all partitions under topic viapulsar_default_initial_position.