This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new b339ba86a47 Pipe: optimize the 'Create Pipe' SQL statement to allow
omitting 'With Sink' when no Source or Processor attributes are defined.
(#13534)
b339ba86a47 is described below
commit b339ba86a47438a357485ddc7f210d1e1343de66
Author: Zhenyu Luo <[email protected]>
AuthorDate: Fri Sep 20 17:55:54 2024 +0800
Pipe: optimize the 'Create Pipe' SQL statement to allow omitting 'With
Sink' when no Source or Processor attributes are defined. (#13534)
---
.../apache/iotdb/pipe/it/autocreate/IoTDBPipeSyntaxIT.java | 11 +++++++++++
.../main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 | 9 +++++++--
.../apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java | 11 +++++++++--
3 files changed, 27 insertions(+), 4 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/pipe/it/autocreate/IoTDBPipeSyntaxIT.java
b/integration-test/src/test/java/org/apache/iotdb/pipe/it/autocreate/IoTDBPipeSyntaxIT.java
index b0293361b62..b9de28b7158 100644
---
a/integration-test/src/test/java/org/apache/iotdb/pipe/it/autocreate/IoTDBPipeSyntaxIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/pipe/it/autocreate/IoTDBPipeSyntaxIT.java
@@ -718,4 +718,15 @@ public class IoTDBPipeSyntaxIT extends
AbstractPipeDualAutoIT {
Assert.assertEquals(1, showPipeResult.size());
}
}
+
+ @Test
+ public void testValidPipeWithoutWithSink() {
+ try (final Connection connection = senderEnv.getConnection();
+ final Statement statement = connection.createStatement()) {
+ statement.execute("create pipe p1('sink'='do-nothing-sink')");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
}
diff --git
a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index d742d79ac8d..25bff7e5499 100644
---
a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++
b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -543,9 +543,10 @@ verifyConnection
// Pipe Task
=========================================================================================
createPipe
: CREATE PIPE (IF NOT EXISTS)? pipeName=identifier
- extractorAttributesClause?
+ ((extractorAttributesClause?
processorAttributesClause?
- connectorAttributesClause
+ connectorAttributesClause)
+ |connectorAttributesWithoutWithSinkClause)
;
extractorAttributesClause
@@ -577,6 +578,10 @@ connectorAttributesClause
RR_BRACKET
;
+connectorAttributesWithoutWithSinkClause
+ : LR_BRACKET (connectorAttributeClause COMMA)* connectorAttributeClause?
RR_BRACKET
+ ;
+
connectorAttributeClause
: connectorKey=STRING_LITERAL OPERATOR_SEQ connectorValue=STRING_LITERAL
;
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
index e063139e75b..f184d34dba0 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
@@ -3811,8 +3811,15 @@ public class ASTVisitor extends
IoTDBSqlParserBaseVisitor<Statement> {
} else {
createPipeStatement.setProcessorAttributes(new HashMap<>());
}
- createPipeStatement.setConnectorAttributes(
-
parseConnectorAttributesClause(ctx.connectorAttributesClause().connectorAttributeClause()));
+ if (ctx.connectorAttributesClause() != null) {
+ createPipeStatement.setConnectorAttributes(
+ parseConnectorAttributesClause(
+ ctx.connectorAttributesClause().connectorAttributeClause()));
+ } else {
+ createPipeStatement.setConnectorAttributes(
+ parseConnectorAttributesClause(
+
ctx.connectorAttributesWithoutWithSinkClause().connectorAttributeClause()));
+ }
return createPipeStatement;
}