Skip to content

Commit 7e8cbdd

Browse files
committed
Data subscription and synchronization support create if not exists and drop if exists interfaces
1 parent 9b20398 commit 7e8cbdd

File tree

12 files changed

+74
-36
lines changed

12 files changed

+74
-36
lines changed

src/UserGuide/Master/User-Manual/Data-Sync_apache.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Use the `CREATE PIPE` statement to create a data synchronization task. The `Pipe
103103
The SQL example is as follows:
104104

105105
```SQL
106-
CREATE PIPE <PipeId> -- PipeId is the name that uniquely identifies the task.
106+
CREATE PIPE [IF NOT EXISTS] <PipeId> -- PipeId is the name that uniquely identifies the task.
107107
-- Data extraction plugin, optional plugin
108108
WITH SOURCE (
109109
[<parameter> = <value>,],
@@ -118,6 +118,8 @@ WITH SINK (
118118
)
119119
```
120120

121+
**IF NOT EXISTS semantics**: Used in creation operations to ensure that the create command is executed when the specified object does not exist, preventing errors caused by attempting to create an existing object.
122+
121123
### Start Task
122124

123125
After creation, the task will not be processed immediately and needs to be started. Use the `START PIPE` statement to start the task and begin processing data:
@@ -139,8 +141,9 @@ STOP PIPE <PipeId>
139141
Deletes the specified task:
140142

141143
```SQL
142-
DROP PIPE <PipeId>
144+
DROP PIPE [IF EXISTS] <PipeId>
143145
```
146+
**IF EXISTS semantics**: Used in deletion operations to ensure that the delete command is executed when the specified object exists, preventing errors caused by attempting to delete non-existent objects.
144147

145148
Deleting a task does not require stopping the synchronization task first.
146149

src/UserGuide/Master/User-Manual/Data-Sync_timecho.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Use the `CREATE PIPE` statement to create a data synchronization task. The `Pipe
105105
The SQL example is as follows:
106106

107107
```SQL
108-
CREATE PIPE <PipeId> -- PipeId is the name that uniquely identifies the task.
108+
CREATE PIPE [IF NOT EXISTS] <PipeId> -- PipeId is the name that uniquely identifies the task.
109109
-- Data extraction plugin, optional plugin
110110
WITH SOURCE (
111111
[<parameter> = <value>,],
@@ -120,6 +120,8 @@ WITH SINK (
120120
)
121121
```
122122

123+
**IF NOT EXISTS semantics**: Used in creation operations to ensure that the create command is executed when the specified object does not exist, preventing errors caused by attempting to create an existing object.
124+
123125
### Start Task
124126

125127
After creation, the task will not be processed immediately and needs to be started. Use the `START PIPE` statement to start the task and begin processing data:
@@ -141,8 +143,9 @@ STOP PIPE <PipeId>
141143
Deletes the specified task:
142144

143145
```SQL
144-
DROP PIPE <PipeId>
146+
DROP PIPE [IF EXISTS] <PipeId>
145147
```
148+
**IF EXISTS semantics**: Used in deletion operations to ensure that the delete command is executed when the specified object exists, preventing errors caused by attempting to delete non-existent objects.
146149

147150
Deleting a task does not require stopping the synchronization task first.
148151

src/UserGuide/Master/User-Manual/Data-subscription.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ IoTDB supports the creation, deletion, and viewing of Topics through SQL stateme
4646
The SQL statement is as follows:
4747

4848
```SQL
49-
CREATE TOPIC <topicName>
49+
CREATE TOPIC [IF NOT EXISTS] <topicName>
5050
WITH (
5151
[<parameter> = <value>,],
5252
);
5353
```
5454

55+
**IF NOT EXISTS semantics**: Used in creation operations to ensure that the create command is executed when the specified object does not exist, preventing errors caused by attempting to create an existing object.
56+
5557
Detailed explanation of each parameter is as follows:
5658

5759
| Key | Required or Optional with Default | Description |
@@ -74,7 +76,7 @@ Examples are as follows:
7476
CREATE TOPIC root_all;
7577

7678
-- Custom subscription
77-
CREATE TOPIC db_timerange
79+
CREATE TOPIC IF NOT EXISTS db_timerange
7880
WITH (
7981
'path' = 'root.db.**',
8082
'start-time' = '2023-01-01',
@@ -87,8 +89,9 @@ WITH (
8789
A Topic can only be deleted if it is not subscribed to. When a Topic is deleted, its related consumption progress will be cleared.
8890

8991
```SQL
90-
DROP TOPIC <topicName>;
92+
DROP TOPIC [IF EXISTS] <topicName>;
9193
```
94+
**IF EXISTS semantics**: Used in deletion operations to ensure that the delete command is executed when the specified object exists, preventing errors caused by attempting to delete non-existent objects.
9295

9396
#### 3.1.3 View Topic
9497

@@ -142,7 +145,7 @@ The `SubscriptionSession` class in the IoTDB subscription client provides interf
142145
#### 4.1.1 Create Topic
143146

144147
```Java
145-
Topic createTopic(String topicName, Properties properties) throws Exception;
148+
void createTopicIfNotExists(String topicName, Properties properties) throws Exception;
146149
```
147150

148151
Example:
@@ -159,7 +162,7 @@ try (final SubscriptionSession session = new SubscriptionSession(host, port)) {
159162
#### 4.1.2 Delete Topic
160163

161164
```Java
162-
void dropTopic(String topicName) throws Exception;
165+
void dropTopicIfExists(String topicName) throws Exception;
163166
```
164167

165168
#### 4.1.3 View Topic

src/UserGuide/latest/User-Manual/Data-Sync_apache.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Use the `CREATE PIPE` statement to create a data synchronization task. The `Pipe
103103
The SQL example is as follows:
104104

105105
```SQL
106-
CREATE PIPE <PipeId> -- PipeId is the name that uniquely identifies the task.
106+
CREATE PIPE [IF NOT EXISTS] <PipeId> -- PipeId is the name that uniquely identifies the task.
107107
-- Data extraction plugin, optional plugin
108108
WITH SOURCE (
109109
[<parameter> = <value>,],
@@ -118,6 +118,8 @@ WITH SINK (
118118
)
119119
```
120120

121+
**IF NOT EXISTS semantics**: Used in creation operations to ensure that the create command is executed when the specified object does not exist, preventing errors caused by attempting to create an existing object.
122+
121123
### Start Task
122124

123125
After creation, the task will not be processed immediately and needs to be started. Use the `START PIPE` statement to start the task and begin processing data:
@@ -139,8 +141,9 @@ STOP PIPE <PipeId>
139141
Deletes the specified task:
140142

141143
```SQL
142-
DROP PIPE <PipeId>
144+
DROP PIPE [IF EXISTS] <PipeId>
143145
```
146+
**IF EXISTS semantics**: Used in deletion operations to ensure that the delete command is executed when the specified object exists, preventing errors caused by attempting to delete non-existent objects.
144147

145148
Deleting a task does not require stopping the synchronization task first.
146149

src/UserGuide/latest/User-Manual/Data-Sync_timecho.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Use the `CREATE PIPE` statement to create a data synchronization task. The `Pipe
105105
The SQL example is as follows:
106106

107107
```SQL
108-
CREATE PIPE <PipeId> -- PipeId is the name that uniquely identifies the task.
108+
CREATE PIPE [IF NOT EXISTS] <PipeId> -- PipeId is the name that uniquely identifies the task.
109109
-- Data extraction plugin, optional plugin
110110
WITH SOURCE (
111111
[<parameter> = <value>,],
@@ -120,6 +120,8 @@ WITH SINK (
120120
)
121121
```
122122

123+
**IF NOT EXISTS semantics**: Used in creation operations to ensure that the create command is executed when the specified object does not exist, preventing errors caused by attempting to create an existing object.
124+
123125
### Start Task
124126

125127
After creation, the task will not be processed immediately and needs to be started. Use the `START PIPE` statement to start the task and begin processing data:
@@ -141,8 +143,9 @@ STOP PIPE <PipeId>
141143
Deletes the specified task:
142144

143145
```SQL
144-
DROP PIPE <PipeId>
146+
DROP PIPE [IF EXISTS] <PipeId>
145147
```
148+
**IF EXISTS semantics**: Used in deletion operations to ensure that the delete command is executed when the specified object exists, preventing errors caused by attempting to delete non-existent objects.
146149

147150
Deleting a task does not require stopping the synchronization task first.
148151

src/UserGuide/latest/User-Manual/Data-subscription.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ IoTDB supports the creation, deletion, and viewing of Topics through SQL stateme
4646
The SQL statement is as follows:
4747

4848
```SQL
49-
CREATE TOPIC <topicName>
49+
CREATE TOPIC [IF NOT EXISTS] <topicName>
5050
WITH (
5151
[<parameter> = <value>,],
5252
);
5353
```
54+
**IF NOT EXISTS semantics**: Used in creation operations to ensure that the create command is executed when the specified object does not exist, preventing errors caused by attempting to create an existing object.
5455

5556
Detailed explanation of each parameter is as follows:
5657

@@ -74,7 +75,7 @@ Examples are as follows:
7475
CREATE TOPIC root_all;
7576

7677
-- Custom subscription
77-
CREATE TOPIC db_timerange
78+
CREATE TOPIC IF NOT EXISTS db_timerange
7879
WITH (
7980
'path' = 'root.db.**',
8081
'start-time' = '2023-01-01',
@@ -87,8 +88,9 @@ WITH (
8788
A Topic can only be deleted if it is not subscribed to. When a Topic is deleted, its related consumption progress will be cleared.
8889

8990
```SQL
90-
DROP TOPIC <topicName>;
91+
DROP TOPIC [IF EXISTS] <topicName>;
9192
```
93+
**IF EXISTS semantics**: Used in deletion operations to ensure that the delete command is executed when the specified object exists, preventing errors caused by attempting to delete non-existent objects.
9294

9395
#### 3.1.3 View Topic
9496

@@ -142,7 +144,7 @@ The `SubscriptionSession` class in the IoTDB subscription client provides interf
142144
#### 4.1.1 Create Topic
143145

144146
```Java
145-
Topic createTopic(String topicName, Properties properties) throws Exception;
147+
void createTopicIfNotExists(String topicName, Properties properties) throws Exception;
146148
```
147149

148150
Example:
@@ -159,7 +161,7 @@ try (final SubscriptionSession session = new SubscriptionSession(host, port)) {
159161
#### 4.1.2 Delete Topic
160162

161163
```Java
162-
void dropTopic(String topicName) throws Exception;
164+
void dropTopicIfExists(String topicName) throws Exception;
163165
```
164166

165167
#### 4.1.3 View Topic

src/zh/UserGuide/Master/User-Manual/Data-Sync_apache.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
SQL 示例如下:
103103

104104
```SQL
105-
CREATE PIPE <PipeId> -- PipeId 是能够唯一标定任务任务的名字
105+
CREATE PIPE [IF NOT EXISTS] <PipeId> -- PipeId 是能够唯一标定任务任务的名字
106106
-- 数据抽取插件,可选插件
107107
WITH SOURCE (
108108
[<parameter> = <value>,],
@@ -117,6 +117,8 @@ WITH SINK (
117117
)
118118
```
119119

120+
**IF NOT EXISTS 语义**:用于创建操作中,确保当指定对象不存在时,执行创建命令,防止因尝试创建已存在的对象而导致报错。
121+
120122
### 开始任务
121123

122124
创建之后,任务不会立即被处理,需要启动任务。使用`START PIPE`语句来启动任务,从而开始处理数据:
@@ -138,9 +140,11 @@ STOP PIPE <PipeId>
138140
删除指定任务:
139141

140142
```SQL
141-
DROP PIPE <PipeId>
143+
DROP PIPE [IF EXISTS] <PipeId>
142144
```
143145

146+
**IF EXISTS 语义**:用于删除操作中,确保当指定对象存在时,执行删除命令,防止因尝试删除不存在的对象而导致报错。
147+
144148
删除任务不需要先停止同步任务。
145149

146150
### 查看任务

src/zh/UserGuide/Master/User-Manual/Data-Sync_timecho.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
SQL 示例如下:
105105

106106
```SQL
107-
CREATE PIPE <PipeId> -- PipeId 是能够唯一标定任务任务的名字
107+
CREATE PIPE [IF NOT EXISTS] <PipeId> -- PipeId 是能够唯一标定任务任务的名字
108108
-- 数据抽取插件,可选插件
109109
WITH SOURCE (
110110
[<parameter> = <value>,],
@@ -119,6 +119,8 @@ WITH SINK (
119119
)
120120
```
121121

122+
**IF NOT EXISTS 语义**:用于创建操作中,确保当指定对象不存在时,执行创建命令,防止因尝试创建已存在的对象而导致报错。
123+
122124
### 开始任务
123125

124126
创建之后,任务不会立即被处理,需要启动任务。使用`START PIPE`语句来启动任务,从而开始处理数据:
@@ -140,9 +142,11 @@ STOP PIPE <PipeId>
140142
删除指定任务:
141143

142144
```SQL
143-
DROP PIPE <PipeId>
145+
DROP PIPE [IF EXISTS] <PipeId>
144146
```
145147

148+
**IF EXISTS 语义**:用于删除操作中,确保当指定对象存在时,执行删除命令,防止因尝试删除不存在的对象而导致报错。
149+
146150
删除任务不需要先停止同步任务。
147151

148152
### 查看任务

src/zh/UserGuide/Master/User-Manual/Data-subscription.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ IoTDB 支持通过 SQL 语句对 Topic 进行创建、删除、查看操作。To
4444
SQL 语句为:
4545

4646
```SQL
47-
CREATE TOPIC <topicName>
47+
CREATE TOPIC [IF NOT EXISTS] <topicName>
4848
WITH (
4949
[<parameter> = <value>,],
5050
);
5151
```
52+
**IF NOT EXISTS 语义**:用于创建操作中,确保当指定对象不存在时,执行创建命令,防止因尝试创建已存在的对象而导致报错。
5253

5354
各参数详细解释如下:
5455

@@ -69,7 +70,7 @@ SQL 语句为:
6970
CREATE TOPIC root_all;
7071

7172
-- 自定义订阅
72-
CREATE TOPIC db_timerange
73+
CREATE TOPIC IF NOT EXISTS db_timerange
7374
WITH (
7475
'path' = 'root.db.**',
7576
'start-time' = '2023-01-01',
@@ -82,9 +83,11 @@ WITH (
8283
Topic 在没有被订阅的情况下,才能被删除,Topic 被删除时,其相关的消费进度都会被清理
8384

8485
```SQL
85-
DROP TOPIC <topicName>;
86+
DROP TOPIC [IF EXISTS] <topicName>;
8687
```
8788

89+
**IF EXISTS 语义**:用于删除操作中,确保当指定对象存在时,执行删除命令,防止因尝试删除不存在的对象而导致报错。
90+
8891
#### 3.1.3 查看 Topic
8992

9093
```SQL
@@ -137,7 +140,7 @@ IoTDB 订阅客户端中的 `SubscriptionSession` 类提供了 Topic 管理的
137140
#### 4.1.1 创建 Topic
138141

139142
```Java
140-
Topic createTopic(String topicName, Properties properties) throws Exception;
143+
void createTopicIfNotExists(String topicName, Properties properties) throws Exception;
141144
```
142145

143146
示例:
@@ -154,7 +157,7 @@ try (final SubscriptionSession session = new SubscriptionSession(host, port)) {
154157
#### 4.1.2 删除 Topic
155158

156159
```Java
157-
void dropTopic(String topicName) throws Exception;
160+
void dropTopicIfExists(String topicName) throws Exception;
158161
```
159162

160163
#### 4.1.3 查看 Topic

src/zh/UserGuide/latest/User-Manual/Data-Sync_apache.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
SQL 示例如下:
103103

104104
```SQL
105-
CREATE PIPE <PipeId> -- PipeId 是能够唯一标定任务任务的名字
105+
CREATE PIPE [IF NOT EXISTS] <PipeId> -- PipeId 是能够唯一标定任务任务的名字
106106
-- 数据抽取插件,可选插件
107107
WITH SOURCE (
108108
[<parameter> = <value>,],
@@ -116,6 +116,7 @@ WITH SINK (
116116
[<parameter> = <value>,],
117117
)
118118
```
119+
**IF NOT EXISTS 语义**:用于创建操作中,确保当指定对象不存在时,执行创建命令,防止因尝试创建已存在的对象而导致报错。
119120

120121
### 开始任务
121122

@@ -138,9 +139,11 @@ STOP PIPE <PipeId>
138139
删除指定任务:
139140

140141
```SQL
141-
DROP PIPE <PipeId>
142+
DROP PIPE [IF EXISTS] <PipeId>
142143
```
143144

145+
**IF EXISTS 语义**:用于删除操作中,确保当指定对象存在时,执行删除命令,防止因尝试删除不存在的对象而导致报错。
146+
144147
删除任务不需要先停止同步任务。
145148

146149
### 查看任务

0 commit comments

Comments
 (0)