更新时间:2024-02-07 GMT+08:00

Redis源表

功能描述

创建source流从Redis获取数据,作为作业的输入数据。

前提条件

要建立增强型跨源连接,且用户可以根据实际所需设置相应安全组规则。

语法格式

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
create table dwsSource (
  attr_name attr_type 
  (',' attr_name attr_type)* 
  (',' watermark for rowtime_column_name as watermark-strategy_expression)
)
with (
  'connector.type' = 'redis',
  'connector.host' = '',
  'connector.port' = ''
);

参数说明

表1 参数说明

参数

是否必选

说明

connector.type

connector类型,对于redis,需配置为'redis'。

connector.host

redis连接地址。

connector.port

redis连接端口。

connector.password

redis认证密码。

connector.deploy-mode

redis部署模式,支持standalone/cluster,默认standalone。

connector.table-name

table存储模式下必配,redis中存储表名。在table存储模式下,数据将以hash类型存储到redis,其中key为:${table-name}:${ext-key},field名为列名。

说明:

table存储模式:将connector.table-name、connector.key-column作为redis的key。redis的hash类型,每个key对应一个hashmap,hashmap的hashkey为源表的字段名,hashvalue为源表的字段值。

connector.use-internal-schema

table存储模式下可配置,是否使用redis中已存在schema,默认为false。

connector.key-column

table存储模式下可配置,将该字段值作为redis中的ext-key,未配置时,ext-key为生成的uuid。

示例

从Redis中读取数据。

create table redisSource(
  car_id STRING,
  car_owner STRING,
  car_brand STRING,
  car_speed INT
) with (
 'connector.type' = 'redis',
  'connector.host' = 'xx.xx.xx.xx',
  'connector.port' = '6379',
  'connector.password' = 'xx',
  'connector.table-name' = 'car_info'
);