You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2022/05/18 15:56:16 UTC
[iotdb] branch master updated: [IOTDB-3101] definition of attributekey and attributevalue (#5888)
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 406a79f08c [IOTDB-3101] definition of attributekey and attributevalue (#5888)
406a79f08c is described below
commit 406a79f08ceaa9b97d270d28d4ab210303fa4715
Author: Liao Lanyu <48...@users.noreply.github.com>
AuthorDate: Wed May 18 23:56:11 2022 +0800
[IOTDB-3101] definition of attributekey and attributevalue (#5888)
---
.../src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 | 2 +-
.../java/org/apache/iotdb/db/integration/IoTDBTagAlterIT.java | 4 ++--
.../main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java | 8 +++-----
.../src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java | 8 +++-----
4 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index d1b1565cec..f513a4da7a 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -161,7 +161,7 @@ alterTimeseries
alterClause
: RENAME beforeName=attributeKey TO currentName=attributeKey
| SET attributePair (COMMA attributePair)*
- | DROP STRING_LITERAL (COMMA STRING_LITERAL)*
+ | DROP attributeKey (COMMA attributeKey)*
| ADD TAGS attributePair (COMMA attributePair)*
| ADD ATTRIBUTES attributePair (COMMA attributePair)*
| UPSERT aliasClause? tagClause? attributeClause?
diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTagAlterIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTagAlterIT.java
index 0132ea28ab..4bee6635c8 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTagAlterIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBTagAlterIT.java
@@ -98,7 +98,7 @@ public class IoTDBTagAlterIT {
assertEquals(ret1.length, count);
try {
- statement.execute("ALTER timeseries root.turbine.d1.s1 RENAME 'tag3' TO 'tagNew3'");
+ statement.execute("ALTER timeseries root.turbine.d1.s1 RENAME tag3 TO 'tagNew3'");
fail();
} catch (Exception e) {
assertTrue(
@@ -290,7 +290,7 @@ public class IoTDBTagAlterIT {
}
assertEquals(ret.length, count);
- statement.execute("ALTER timeseries root.turbine.d1.s1 DROP 'attr1','tag1'");
+ statement.execute("ALTER timeseries root.turbine.d1.s1 DROP attr1,'tag1'");
hasResult = statement.execute("show timeseries");
assertTrue(hasResult);
resultSet = statement.getResultSet();
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
index 8f9db1267f..8d826f98f2 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
@@ -309,9 +309,7 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
// rename
if (ctx.RENAME() != null) {
alterTimeSeriesStatement.setAlterType(AlterTimeSeriesStatement.AlterType.RENAME);
- alterMap.put(
- parseStringLiteral(ctx.beforeName.getText()),
- parseStringLiteral(ctx.currentName.getText()));
+ alterMap.put(parseAttributeKey(ctx.beforeName), parseAttributeKey(ctx.currentName));
} else if (ctx.SET() != null) {
// set
alterTimeSeriesStatement.setAlterType(AlterTimeSeriesStatement.AlterType.SET);
@@ -319,8 +317,8 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
} else if (ctx.DROP() != null) {
// drop
alterTimeSeriesStatement.setAlterType(AlterTimeSeriesStatement.AlterType.DROP);
- for (int i = 0; i < ctx.STRING_LITERAL().size(); i++) {
- alterMap.put(parseStringLiteral(ctx.STRING_LITERAL(i).getText()), null);
+ for (int i = 0; i < ctx.attributeKey().size(); i++) {
+ alterMap.put(parseAttributeKey(ctx.attributeKey().get(i)), null);
}
} else if (ctx.TAGS() != null) {
// add tag
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
index da67a66f7e..a81179f435 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
@@ -655,9 +655,7 @@ public class IoTDBSqlVisitor extends IoTDBSqlParserBaseVisitor<Operator> {
// rename
if (ctx.RENAME() != null) {
alterTimeSeriesOperator.setAlterType(AlterType.RENAME);
- alterMap.put(
- parseStringLiteral(ctx.beforeName.getText()),
- parseStringLiteral(ctx.currentName.getText()));
+ alterMap.put(parseAttributeKey(ctx.beforeName), parseAttributeKey(ctx.currentName));
} else if (ctx.SET() != null) {
// set
alterTimeSeriesOperator.setAlterType(AlterType.SET);
@@ -665,8 +663,8 @@ public class IoTDBSqlVisitor extends IoTDBSqlParserBaseVisitor<Operator> {
} else if (ctx.DROP() != null) {
// drop
alterTimeSeriesOperator.setAlterType(AlterType.DROP);
- for (int i = 0; i < ctx.STRING_LITERAL().size(); i++) {
- alterMap.put(parseStringLiteral(ctx.STRING_LITERAL(i).getText()), null);
+ for (int i = 0; i < ctx.attributeKey().size(); i++) {
+ alterMap.put(parseAttributeKey(ctx.attributeKey().get(i)), null);
}
} else if (ctx.TAGS() != null) {
// add tag