Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改kafka输出格式,适配starrocks #174

Open
wants to merge 1 commit into
base: v1.8.x
Choose a base branch
from

Conversation

Lxuty
Copy link
Contributor

@Lxuty Lxuty commented Mar 14, 2022

Bifrost针对kafka插件输出格式,做了一定的变化,主要是只保存更新后的数据,去掉DDL语句与COMMIT语句,让StarRocks Routine可以识别消费。

MySQL原表:
CREATE TABLE a (
id int(11) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

StarRocks主键表创建及routine示例:
CREATE TABLE a(
id int NOT NULL
) PRIMARY KEY (id)
DISTRIBUTED BY HASH(id) BUCKETS 32
PROPERTIES('replication_num' = '1');

--必须要先创建一个kafka topic才可以
create routine load routine_a on a
COLUMNS TERMINATED BY ",",
COLUMNS(id,EventType, __op=case when EventType="insert" then 0 when EventType="update" then 0 when EventType="delete" then 1 else null end) PROPERTIES
(
"format" = "json",
"jsonpaths"= "["$.Rows[0].id","$.EventType"]",
"desired_concurrent_number"="1",
"strict_mode" = "false",
"strip_outer_array" ="false",
"max_error_number" = "1000"
)
FROM KAFKA
(
"kafka_broker_list" = "xxx.xxx.xxx.xxx:9092",
"kafka_topic" = "a",
"kafka_partitions" = "0",
"kafka_offsets" = "OFFSET_BEGINNING"
);

Bifrost针对kafka格式,做了一定的变化,主要是只保存更新后的数据,去掉DDL语句与COMMIT语句,让StarRocks Routine可以识别消费。

MySQL原表:
 CREATE TABLE `a` (
  `id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

StarRocks主键表创建及routine示例:
CREATE TABLE `a`(
`id` int NOT NULL 
) PRIMARY KEY (`id`)
DISTRIBUTED BY HASH(`id`) BUCKETS 32
PROPERTIES('replication_num' = '1');

--必须要先创建一个kafka topic才可以
create routine load routine_a on `a`
COLUMNS TERMINATED BY ",",
COLUMNS(id,EventType, __op=case when EventType="insert" then 0 when EventType="update" then 0 when EventType="delete" then 1 else null end) PROPERTIES
(
                "format" = "json",
                "jsonpaths"= "[\"$.Rows[0].id\",\"$.EventType\"]",
                "desired_concurrent_number"="1",
                "strict_mode" = "false",
                "strip_outer_array" ="false",
                "max_error_number" = "1000"
)
FROM KAFKA
(
                "kafka_broker_list" = "xxx.xxx.xxx.xxx:9092",
                "kafka_topic" = "a",
                "kafka_partitions" = "0",
                "kafka_offsets" = "OFFSET_BEGINNING"
);
@jc3wish
Copy link
Member

jc3wish commented Apr 4, 2024

当前輸出到kafka,支持以一个json map的方式输出了

同时已经 以mysql协议连接starrocks 同步 ,并且 支持自动建表等功能

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants