This is an automated email from the ASF dual-hosted git repository. wanghailin pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/seatunnel.git
The following commit(s) were added to refs/heads/dev by this push: new de44573482 [Doc][Improve] translate Redis/Paimon related chinese document (#8584) de44573482 is described below commit de445734820e6637be6a5db71234376fd596c5e6 Author: lyne <33561138+lyne7...@users.noreply.github.com> AuthorDate: Wed Feb 5 16:26:39 2025 +0800 [Doc][Improve] translate Redis/Paimon related chinese document (#8584) --- docs/zh/connector-v2/source/Paimon.md | 224 ++++++++++++++++++++++++++ docs/zh/connector-v2/source/Redis.md | 295 ++++++++++++++++++++++++++++++++++ 2 files changed, 519 insertions(+) diff --git a/docs/zh/connector-v2/source/Paimon.md b/docs/zh/connector-v2/source/Paimon.md new file mode 100644 index 0000000000..27d546a138 --- /dev/null +++ b/docs/zh/connector-v2/source/Paimon.md @@ -0,0 +1,224 @@ +# Paimon + +> Paimon 源连接器 + +## 描述 + +用于从 `Apache Paimon` 读取数据 + +## 主要功能 + +- [x] [批处理](../../concept/connector-v2-features.md) +- [x] [流处理](../../concept/connector-v2-features.md) +- [ ] [精确一次](../../concept/connector-v2-features.md) +- [ ] [列投影](../../concept/connector-v2-features.md) +- [ ] [并行度](../../concept/connector-v2-features.md) +- [ ] [支持用户自定义分片](../../concept/connector-v2-features.md) + +## 配置选项 + +| 名称 | 类型 | 是否必须 | 默认值 | +|-------------------------|--------|----------|---------------| +| warehouse | String | 是 | - | +| catalog_type | String | 否 | filesystem | +| catalog_uri | String | 否 | - | +| database | String | 是 | - | +| table | String | 是 | - | +| hdfs_site_path | String | 否 | - | +| query | String | 否 | - | +| paimon.hadoop.conf | Map | 否 | - | +| paimon.hadoop.conf-path | String | 否 | - | + +### warehouse [string] + +Paimon warehouse 路径 + +### catalog_type [string] + +Paimon Catalog 类型,支持 filesystem 和 hive + +### catalog_uri [string] + +Paimon 的 catalog uri,仅当 catalog_type 为 hive 时需要 + +### database [string] + +需要访问的数据库 + +### table [string] + +需要访问的表 + +### hdfs_site_path [string] + +`hdfs-site.xml` 文件地址 + +### query [string] + +读取表格的筛选条件,例如:`select * from st_test where id > 100`。如果未指定,则将读取所有记录。 + +目前,`where` 支持`<, <=, >, >=, =, !=, or, and,is null, is not null`,其他暂不支持。 + +由于 Paimon 限制,目前不支持 `Having`, `Group By` 和 `Order By`,未来版本将会支持 `projection` 和 `limit`。 + +注意:当 `where` 后的字段为字符串或布尔值时,其值必须使用单引号,否则将会报错。例如 `name='abc'` 或 `tag='true'`。 + +当前 `where` 支持的字段数据类型如下: + +* string +* boolean +* tinyint +* smallint +* int +* bigint +* float +* double +* date +* timestamp + +### paimon.hadoop.conf [string] + +hadoop conf 属性 + +### paimon.hadoop.conf-path [string] + +指定 'core-site.xml', 'hdfs-site.xml', 'hive-site.xml' 文件加载路径。 + +## Filesystems + +Paimon 连接器支持向多个文件系统写入数据。目前,支持的文件系统有 `hdfs` 和 `s3`。 +如果使用 `s3` 文件系统,可以在 `paimon.hadoop.conf` 中配置`fs.s3a.access-key`、`fs.s3a.secret-key`、`fs.s3a.endpoint`、`fs.s3a.path.style.access`、`fs.s3a.aws.credentials.provider` 属性,数仓地址应该以 `s3a://` 开头。 + +## 示例 + +### 简单示例 + +```hocon +source { + Paimon { + warehouse = "/tmp/paimon" + database = "default" + table = "st_test" + } +} +``` + +### Filter 示例 + +```hocon +source { + Paimon { + warehouse = "/tmp/paimon" + database = "full_type" + table = "st_test" + query = "select c_boolean, c_tinyint from st_test where c_boolean= 'true' and c_tinyint > 116 and c_smallint = 15987 or c_decimal='2924137191386439303744.39292213'" + } +} +``` + +### S3 示例 +```hocon +env { + execution.parallelism = 1 + job.mode = "BATCH" +} + +source { + Paimon { + warehouse = "s3a://test/" + database = "seatunnel_namespace11" + table = "st_test" + paimon.hadoop.conf = { + fs.s3a.access-key=G52pnxg67819khOZ9ezX + fs.s3a.secret-key=SHJuAQqHsLrgZWikvMa3lJf5T0NfM5LMFliJh9HF + fs.s3a.endpoint="http://minio4:9000" + fs.s3a.path.style.access=true + fs.s3a.aws.credentials.provider=org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider + } + } +} + +sink { + Console{} +} +``` + +### Hadoop 配置示例 + +```hocon +source { + Paimon { + catalog_name="seatunnel_test" + warehouse="hdfs:///tmp/paimon" + database="seatunnel_namespace1" + table="st_test" + query = "select * from st_test where pk_id is not null and pk_id < 3" + paimon.hadoop.conf = { + fs.defaultFS = "hdfs://nameservice1" + dfs.nameservices = "nameservice1" + dfs.ha.namenodes.nameservice1 = "nn1,nn2" + dfs.namenode.rpc-address.nameservice1.nn1 = "hadoop03:8020" + dfs.namenode.rpc-address.nameservice1.nn2 = "hadoop04:8020" + dfs.client.failover.proxy.provider.nameservice1 = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" + dfs.client.use.datanode.hostname = "true" + } + } +} +``` + +### Hive catalog 示例 + +```hocon +source { + Paimon { + catalog_name="seatunnel_test" + catalog_type="hive" + catalog_uri="thrift://hadoop04:9083" + warehouse="hdfs:///tmp/seatunnel" + database="seatunnel_test" + table="st_test3" + paimon.hadoop.conf = { + fs.defaultFS = "hdfs://nameservice1" + dfs.nameservices = "nameservice1" + dfs.ha.namenodes.nameservice1 = "nn1,nn2" + dfs.namenode.rpc-address.nameservice1.nn1 = "hadoop03:8020" + dfs.namenode.rpc-address.nameservice1.nn2 = "hadoop04:8020" + dfs.client.failover.proxy.provider.nameservice1 = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" + dfs.client.use.datanode.hostname = "true" + } + } +} +``` + +## Changelog + +如果要读取 paimon 表的 changelog,首先要为 Paimon 源表设置 `changelog-producer`,然后使用 SeaTunnel 流任务读取。 + +### Note + +目前,批读取总是读取最新的快照,如需读取更完整的 changelog 数据,需使用流读取,并在将数据写入 Paimon 表之前开始流读取,为了确保顺序,流读取任务并行度应该设置为 1。 + +### Streaming read 示例 +```hocon +env { + parallelism = 1 + job.mode = "Streaming" +} + +source { + Paimon { + warehouse = "/tmp/paimon" + database = "full_type" + table = "st_test" + } +} + +sink { + Paimon { + warehouse = "/tmp/paimon" + database = "full_type" + table = "st_test_sink" + paimon.table.primary-keys = "c_tinyint" + } +} +``` diff --git a/docs/zh/connector-v2/source/Redis.md b/docs/zh/connector-v2/source/Redis.md new file mode 100644 index 0000000000..8e30d87579 --- /dev/null +++ b/docs/zh/connector-v2/source/Redis.md @@ -0,0 +1,295 @@ +# Redis + +> Redis 源连接器 + +## 描述 + +用于从 `Redis` 读取数据 + +## 主要功能 + +- [x] [批处理](../../concept/connector-v2-features.md) +- [ ] [流处理](../../concept/connector-v2-features.md) +- [ ] [精确一次](../../concept/connector-v2-features.md) +- [ ] [列投影](../../concept/connector-v2-features.md) +- [ ] [并行度](../../concept/connector-v2-features.md) +- [ ] [支持用户自定义分片](../../concept/connector-v2-features.md) + +## 配置选项 + +| 名称 | 类型 | 是否必须 | 默认值 | +|---------------------|--------|--------------------|--------| +| host | string | 是 | - | +| port | int | 是 | - | +| keys | string | 是 | - | +| batch_size | int | 是 | 10 | +| data_type | string | 是 | - | +| user | string | 否 | - | +| auth | string | 否 | - | +| db_num | int | 否 | 0 | +| mode | string | 否 | single | +| hash_key_parse_mode | string | 否 | all | +| nodes | list | `mode=cluster` 时必须 | - | +| schema | config | `format=json` 时必须 | - | +| format | string | 否 | json | +| common-options | | 否 | - | + +### host [string] + +redis 主机地址 + +### port [int] + +redis 端口号 + +### hash_key_parse_mode [string] + +指定 hash key 解析模式, 支持 `all` `kv` 模式, 用于设定连接器如何解析 hash key。 + +当设定为 `all` 时,连接器会将 hash key 的值视为一行并根据 schema config 配置进行解析,当设定为 `kv` 时,连接器会将 hash key 的每个 kv 视为一行,并根据 schema config 进行解析。 + +例如,如果 hash key 的值如下设置: + +```text +{ + "001": { + "name": "tyrantlucifer", + "age": 26 + }, + "002": { + "name": "Zongwen", + "age": 26 + } +} + +``` + +如果 `hash_key_parse_mode` 设置为 `all` 模式,且 schema config 如下所示,将会生成下表数据: + +```hocon +schema { + fields { + 001 { + name = string + age = int + } + 002 { + name = string + age = int + } + } +} + +``` + +| 001 | 002 | +| ------------------------------- | ------------------------- | +| Row(name=tyrantlucifer, age=26) | Row(name=Zongwen, age=26) | + +如果 `hash_key_parse_mode` 设置为 `kv` 模式,且 schema config 如下所示,将会生成下表数据: + +```hocon +schema { + fields { + hash_key = string + name = string + age = int + } +} + +``` + +| hash_key | name | age | +| -------- | ------------- | ---- | +| 001 | tyrantlucifer | 26 | +| 002 | Zongwen | 26 | + +hash key 中的每个 kv 将会被视为一行并被发送给上游。 + +**提示:连接器将使用 scheme config 的第一个字段信息作为每个 kv 中每个 k 的字段名称** + +### keys [string] + +keys 模式 + +### batch_size [int] + +表示每次迭代尝试返回的键的数量,默认值为 10。 + +**提示:Redis 连接器支持模糊键匹配,用户需要确保匹配的键类型相同** + +### data_type [string] + +redis 数据类型, 支持 `key` `hash` `list` `set` `zset`。 + +- key + +> 将每个 key 的值将作为单行数据发送给下游。 +> 例如,key 对应的值为 `SeaTunnel test message`,则下游接收到的数据为 `SeaTunnel test message`,并且仅会收到一条信息。 + +- hash + +> hash 键值对将会被格式化为 json,并以单行数据的形式发送给下游。 +> 例如,hash 值为 `name:tyrantlucifer age:26`,则下游接收到的数据为 `{"name":"tyrantlucifer", "age":"26"}`,并且仅会收到一条信息。 + +- list + +> list 中的每个元素都将作为单行数据向下游发送。 +> 例如,list 值为 `[tyrantlucier, CalvinKirs]`,则下游接收到的数据为 `tyrantlucifer` 和 `CalvinKirs`,并且仅会收到两条信息。 + +- set + +> set 中的每个元素都将作为单行数据向下游发送。 +> 例如,set 值为 `[tyrantlucier, CalvinKirs]`,则下游接收到的数据为 `tyrantlucifer` 和 `CalvinKirs`,并且仅会收到两条信息。 + +- zset + +> zset 中的每个元素都将作为单行数据向下游发送。 +> 例如,zset 值为 `[tyrantlucier, CalvinKirs]`,则下游接收到的数据为 `tyrantlucifer` 和 `CalvinKirs`,并且仅会收到两条信息。 + +### user [string] + +Redis 认证身份用户,当连接到加密集群时需要使用 + +### auth [string] + +Redis 认证密钥,当连接到加密集群时需要使用 + +### db_num [int] + +Redis 数据库索引 ID,默认将连接到 db 0 + +### mode [string] + +Redis 模式,`single` 或 `cluster`,默认值为 `single` + +### nodes [list] + +Redis 节点信息,在 cluster 模式下使用,必须设置为以下格式: + +["host1:port1", "host2:port2"] + +### format [string] + +上游数据格式,目前仅支持 `json` `text`,默认为 `json` + +当指定格式为 `json` 时,还需要指定 scheme option,例如: + +当上游数据如下时: + +```json +{"code": 200, "data": "get success", "success": true} + +``` + +需要指定 schema 为如下配置: + +```hocon +schema { + fields { + code = int + data = string + success = boolean + } +} + +``` + +连接器将会生成如下格式数据: + +| code | data | success | +| ---- | ----------- | ------- | +| 200 | get success | true | + +当指定格式为 `text` 时,连接器不会对上游数据做任何处理,例如: + +当上游数据如下时: + +```json +{"code": 200, "data": "get success", "success": true} + +``` + +连接器将会生成如下格式数据: + +| content | +| -------------------------------------------------------- | +| {"code": 200, "data": "get success", "success": true} | + +### schema [config] + +#### fields [config] + +Redis 数据的 schema 字段列表 + +### common options + +源连接器插件通用参数,详情请参见 [Source Common Options](../source-common-options.md) + +## 示例 + +简单使用示例: + +```hocon +Redis { + host = localhost + port = 6379 + keys = "key_test*" + data_type = key + format = text +} +``` + +```hocon +Redis { + host = localhost + port = 6379 + keys = "key_test*" + data_type = key + format = json + schema { + fields { + name = string + age = int + } + } +} +``` + +读取 string 类型并附加到 list 示例: + + +```hocon +source { + Redis { + host = "redis-e2e" + port = 6379 + auth = "U2VhVHVubmVs" + keys = "string_test*" + data_type = string + batch_size = 33 + } +} + +sink { + Redis { + host = "redis-e2e" + port = 6379 + auth = "U2VhVHVubmVs" + key = "string_test_list" + data_type = list + batch_size = 33 + } +} +``` + +## Changelog + +### 2.2.0-beta 2022-09-26 + +- Add Redis Source Connector + +### next version + +- [Improve] Support redis cluster mode connection and user authentication [3188](https://github.com/apache/seatunnel/pull/3188) +- [Bug] Redis scan command supports versions 5, 6, 7 [7666](https://github.com/apache/seatunnel/pull/7666) \ No newline at end of file