Skip to content

Commit 73754ed

Browse files
修竹修竹
authored andcommitted
在kafkaSource.md增加对嵌套json和数组类型字段解析的说明
1 parent 1366c24 commit 73754ed

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

docs/kafkaSource.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,73 @@ CREATE TABLE MyTable(
6363
parallelism ='1'
6464
);
6565
```
66+
67+
## 6.支持嵌套json、数据类型字段解析
68+
69+
嵌套json解析示例
70+
71+
json: {"name":"tom", "obj":{"channel": "root"}, "pv": 4, "xctime":1572932485}
72+
```
73+
CREATE TABLE MyTable(
74+
name varchar,
75+
obj.channel varchar as channel,
76+
pv INT,
77+
xctime bigint,
78+
CHARACTER_LENGTH(channel) AS timeLeng
79+
)WITH(
80+
type ='kafka09',
81+
bootstrapServers ='172.16.8.198:9092',
82+
zookeeperQuorum ='172.16.8.198:2181/kafka',
83+
offsetReset ='latest',
84+
groupId='nbTest',
85+
topic ='nbTest1,nbTest2,nbTest3',
86+
--- topic ='mqTest.*',
87+
---topicIsPattern='true',
88+
parallelism ='1'
89+
);
90+
```
91+
92+
数组类型字段解析示例
93+
94+
json: {"name":"tom", "obj":{"channel": "root"}, "user": [{"pv": 4}, {"pv": 10}], "xctime":1572932485}
95+
```
96+
CREATE TABLE MyTable(
97+
name varchar,
98+
obj.channel varchar as channel,
99+
user[1].pv INT as pv,
100+
xctime bigint,
101+
CHARACTER_LENGTH(channel) AS timeLeng
102+
)WITH(
103+
type ='kafka09',
104+
bootstrapServers ='172.16.8.198:9092',
105+
zookeeperQuorum ='172.16.8.198:2181/kafka',
106+
offsetReset ='latest',
107+
groupId='nbTest',
108+
topic ='nbTest1,nbTest2,nbTest3',
109+
--- topic ='mqTest.*',
110+
---topicIsPattern='true',
111+
parallelism ='1'
112+
);
113+
```
114+
or
115+
116+
json: {"name":"tom", "obj":{"channel": "root"}, "pv": [4, 7, 10], "xctime":1572932485}
117+
```
118+
CREATE TABLE MyTable(
119+
name varchar,
120+
obj.channel varchar as channel,
121+
pv[1] INT as pv,
122+
xctime bigint,
123+
CHARACTER_LENGTH(channel) AS timeLeng
124+
)WITH(
125+
type ='kafka09',
126+
bootstrapServers ='172.16.8.198:9092',
127+
zookeeperQuorum ='172.16.8.198:2181/kafka',
128+
offsetReset ='latest',
129+
groupId='nbTest',
130+
topic ='nbTest1,nbTest2,nbTest3',
131+
--- topic ='mqTest.*',
132+
---topicIsPattern='true',
133+
parallelism ='1'
134+
);
135+
```

0 commit comments

Comments
 (0)