Skip to content

Commit 39ec2fc

Browse files
authored
Data subscription and synchronization support create if not exists an… (#420)
* Data subscription and synchronization support create if not exists and drop if exists interfaces * The pipe plugin supports the create if not exists and drop if exists interfaces
1 parent 9b20398 commit 39ec2fc

20 files changed

+134
-64
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 Pipe does not exist, preventing errors caused by attempting to create an existing Pipe.
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 when a specified Pipe exists, the delete command is executed to prevent errors caused by attempting to delete non-existent Pipes.
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 Pipe does not exist, preventing errors caused by attempting to create an existing Pipe.
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 when a specified Pipe exists, the delete command is executed to prevent errors caused by attempting to delete non-existent Pipes.
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 topic does not exist, preventing errors caused by attempting to create an existing topic.
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 a specified topic exists, preventing errors caused by attempting to delete non-existent topics.
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/Master/User-Manual/Streaming_apache.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,15 +445,17 @@ In IoTDB, to dynamically load a user-defined plugin into the system, you first n
445445
The syntax of the loading plugin management statement is as follows:
446446

447447
```sql
448-
CREATE PIPEPLUGIN <alias>
448+
CREATE PIPEPLUGIN [IF NOT EXISTS] <alias>
449449
AS <Full class name>
450450
USING <URL of jar file>
451451
```
452452

453+
**IF NOT EXISTS semantics**: Used in creation operations to ensure that the create command is executed when the specified Pipe Plugin does not exist, preventing errors caused by attempting to create an existing Pipe Plugin.
454+
453455
For example, if a user implements a data processing plugin with the fully qualified class name "edu.tsinghua.iotdb.pipe.ExampleProcessor" and packages it into a jar file, which is stored at "https://example.com:8080/iotdb/pipe-plugin.jar", and the user wants to use this plugin in the stream processing engine, marking the plugin as "example". The creation statement for this data processing plugin is as follows:
454456

455457
```sql
456-
CREATE PIPEPLUGIN example
458+
CREATE PIPEPLUGIN IF NOT EXISTS example
457459
AS 'edu.tsinghua.iotdb.pipe.ExampleProcessor'
458460
USING URI '<https://example.com:8080/iotdb/pipe-plugin.jar>'
459461
```
@@ -462,9 +464,11 @@ USING URI '<https://example.com:8080/iotdb/pipe-plugin.jar>'
462464

463465
When user no longer wants to use a plugin and needs to uninstall the plugin from the system, you can use the Remove plugin statement as shown below.
464466
```sql
465-
DROP PIPEPLUGIN <alias>
467+
DROP PIPEPLUGIN [IF EXISTS] <alias>
466468
```
467469

470+
**IF EXISTS semantics**: Used in deletion operations to ensure that when a specified Pipe Plugin exists, the delete command is executed to prevent errors caused by attempting to delete a non-existent Pipe Plugin.
471+
468472
### Show Plugin Statement
469473

470474
User can also view the plugin in the system on need. The statement to view plugin is as follows.

src/UserGuide/Master/User-Manual/Streaming_timecho.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,11 @@ Then the plugin class needs to be compiled and packaged into a jar executable fi
451451
The syntax of the management statement for loading the plugin is shown in the figure.
452452

453453
```sql
454-
CREATE PIPEPLUGIN <alias>
454+
CREATE PIPEPLUGIN [IF NOT EXISTS] <alias>
455455
AS <full class name>
456456
USING <URI of JAR package>
457457
```
458+
**IF NOT EXISTS semantics**: Used in creation operations to ensure that the create command is executed when the specified Pipe Plugin does not exist, preventing errors caused by attempting to create an existing Pipe Plugin.
458459

459460
Example: If you implement a data processing plugin named edu.tsinghua.iotdb.pipe.ExampleProcessor, and the packaged jar package is pipe-plugin.jar, you want to use this plugin in the stream processing engine, and mark the plugin as example. There are two ways to use the plugin package, one is to upload to the URI server, and the other is to upload to the local directory of the cluster.
460461

@@ -465,7 +466,7 @@ Preparation: To register in this way, you need to upload the JAR package to the
465466
SQL:
466467

467468
```sql
468-
CREATE PIPEPLUGIN example
469+
CREATE PIPEPLUGIN IF NOT EXISTS example
469470
AS 'edu.tsinghua.iotdb.pipe.ExampleProcessor'
470471
USING URI '<https://example.com:8080/iotdb/pipe-plugin.jar>'
471472
```
@@ -477,7 +478,7 @@ Preparation: To register in this way, you need to place the JAR package in any p
477478
SQL:
478479

479480
```sql
480-
CREATE PIPEPLUGIN example
481+
CREATE PIPEPLUGIN IF NOT EXISTS example
481482
AS 'edu.tsinghua.iotdb.pipe.ExampleProcessor'
482483
USING URI '<file:/IoTDB installation path/iotdb-1.x.x-bin/ext/pipe/pipe-plugin.jar>'
483484
```
@@ -487,9 +488,11 @@ USING URI '<file:/IoTDB installation path/iotdb-1.x.x-bin/ext/pipe/pipe-plugin.j
487488
When the user no longer wants to use a plugin and needs to uninstall the plugin from the system, he can use the delete plugin statement as shown in the figure.
488489

489490
```sql
490-
DROP PIPEPLUGIN <alias>
491+
DROP PIPEPLUGIN [IF EXISTS] <alias>
491492
```
492493

494+
**IF EXISTS semantics**: Used in deletion operations to ensure that when a specified Pipe Plugin exists, the delete command is executed to prevent errors caused by attempting to delete a non-existent Pipe Plugin.
495+
493496
### View plugin statements
494497

495498
Users can also view plugins in the system on demand. View the statement of the plugin as shown in the figure.

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 Pipe does not exist, preventing errors caused by attempting to create an existing Pipe.
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 when a specified Pipe exists, the delete command is executed to prevent errors caused by attempting to delete non-existent Pipes.
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 Pipe does not exist, preventing errors caused by attempting to create an existing Pipe.
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 when a specified Pipe exists, the delete command is executed to prevent errors caused by attempting to delete non-existent Pipes.
146149

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

src/UserGuide/latest/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 topic does not exist, preventing errors caused by attempting to create an existing topic.
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 a specified topic exists, preventing errors caused by attempting to delete non-existent topics.
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/Streaming_apache.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,15 +445,17 @@ In IoTDB, to dynamically load a user-defined plugin into the system, you first n
445445
The syntax of the loading plugin management statement is as follows:
446446

447447
```sql
448-
CREATE PIPEPLUGIN <alias>
448+
CREATE PIPEPLUGIN [IF NOT EXISTS] <alias>
449449
AS <Full class name>
450450
USING <URL of jar file>
451451
```
452452

453+
**IF NOT EXISTS semantics**: Used in creation operations to ensure that the create command is executed when the specified Pipe Plugin does not exist, preventing errors caused by attempting to create an existing Pipe Plugin.
454+
453455
For example, if a user implements a data processing plugin with the fully qualified class name "edu.tsinghua.iotdb.pipe.ExampleProcessor" and packages it into a jar file, which is stored at "https://example.com:8080/iotdb/pipe-plugin.jar", and the user wants to use this plugin in the stream processing engine, marking the plugin as "example". The creation statement for this data processing plugin is as follows:
454456

455457
```sql
456-
CREATE PIPEPLUGIN example
458+
CREATE PIPEPLUGIN IF NOT EXISTS example
457459
AS 'edu.tsinghua.iotdb.pipe.ExampleProcessor'
458460
USING URI '<https://example.com:8080/iotdb/pipe-plugin.jar>'
459461
```
@@ -462,9 +464,11 @@ USING URI '<https://example.com:8080/iotdb/pipe-plugin.jar>'
462464

463465
When user no longer wants to use a plugin and needs to uninstall the plugin from the system, you can use the Remove plugin statement as shown below.
464466
```sql
465-
DROP PIPEPLUGIN <alias>
467+
DROP PIPEPLUGIN [IF EXISTS] <alias>
466468
```
467469

470+
**IF EXISTS semantics**: Used in deletion operations to ensure that when a specified Pipe Plugin exists, the delete command is executed to prevent errors caused by attempting to delete a non-existent Pipe Plugin.
471+
468472
### Show Plugin Statement
469473

470474
User can also view the plugin in the system on need. The statement to view plugin is as follows.

src/UserGuide/latest/User-Manual/Streaming_timecho.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,11 @@ Then the plugin class needs to be compiled and packaged into a jar executable fi
451451
The syntax of the management statement for loading the plugin is shown in the figure.
452452

453453
```sql
454-
CREATE PIPEPLUGIN <alias>
454+
CREATE PIPEPLUGIN [IF NOT EXISTS] <alias>
455455
AS <full class name>
456456
USING <URI of JAR package>
457457
```
458+
**IF NOT EXISTS semantics**: Used in creation operations to ensure that the create command is executed when the specified Pipe Plugin does not exist, preventing errors caused by attempting to create an existing Pipe Plugin.
458459

459460
Example: If you implement a data processing plugin named edu.tsinghua.iotdb.pipe.ExampleProcessor, and the packaged jar package is pipe-plugin.jar, you want to use this plugin in the stream processing engine, and mark the plugin as example. There are two ways to use the plugin package, one is to upload to the URI server, and the other is to upload to the local directory of the cluster.
460461

@@ -465,7 +466,7 @@ Preparation: To register in this way, you need to upload the JAR package to the
465466
SQL:
466467

467468
```sql
468-
CREATE PIPEPLUGIN example
469+
CREATE PIPEPLUGIN IF NOT EXISTS example
469470
AS 'edu.tsinghua.iotdb.pipe.ExampleProcessor'
470471
USING URI '<https://example.com:8080/iotdb/pipe-plugin.jar>'
471472
```
@@ -477,7 +478,7 @@ Preparation: To register in this way, you need to place the JAR package in any p
477478
SQL:
478479

479480
```sql
480-
CREATE PIPEPLUGIN example
481+
CREATE PIPEPLUGIN IF NOT EXISTS example
481482
AS 'edu.tsinghua.iotdb.pipe.ExampleProcessor'
482483
USING URI '<file:/IoTDB installation path/iotdb-1.x.x-bin/ext/pipe/pipe-plugin.jar>'
483484
```
@@ -487,9 +488,11 @@ USING URI '<file:/IoTDB installation path/iotdb-1.x.x-bin/ext/pipe/pipe-plugin.j
487488
When the user no longer wants to use a plugin and needs to uninstall the plugin from the system, he can use the delete plugin statement as shown in the figure.
488489

489490
```sql
490-
DROP PIPEPLUGIN <alias>
491+
DROP PIPEPLUGIN [IF EXISTS] <alias>
491492
```
492493

494+
**IF EXISTS semantics**: Used in deletion operations to ensure that when a specified Pipe Plugin exists, the delete command is executed to prevent errors caused by attempting to delete a non-existent Pipe Plugin.
495+
493496
### View plugin statements
494497

495498
Users can also view plugins in the system on demand. View the statement of the plugin as shown in the figure.

0 commit comments

Comments
 (0)