1-
今天分析一下presto的kafka connector的主要原理和源码
1-1 配置方法
1-1-1 catalog配置
connector.name=kafka
kafka.nodes=localhost:9090,localhost:9091,localhost:9092 //在单机启动3个broker,按照逗号进行分割
kafka.table-names=tpch2.customer,tpch2.orders,tpch2.lineitem,tpch2.part,tpch2.partsupp,tpch2.supplier,tpch2.nation,tpch2.region //所有相关的表名,每一个都是kafka中的一个topic
kafka.hide-internal-columns=false //这个connector有很多的kafka相关的默认字段,这里配置是否在客户端显示
1-1-2 schema配置
以customer表为例,在etc/kafka目录下放置如下文件,这个文件会被在KafkaConnectorConfig读取
etc/kafka/tpch2.customer.json文件内容如下,太长,只列出其中一部分
{
"tableName": "customer",
"schemaName": "tpch",
"topicName": "tpch.customer",
"key": {
"dataFormat": "raw",
"fields": [
{
"name": "kafka_key",
"dataFormat": "LONG",
"type": "BIGINT",
"hidden": "false"
}
]
},
"message": {
"dataFormat": "json",