Skip to content
Permalink
Browse files
[IOTDB-3101] definition of attributekey and attributevalue (#5888)
  • Loading branch information
Plutooooooo committed May 18, 2022
1 parent 3e63945 commit 406a79f08ceaa9b97d270d28d4ab210303fa4715
Showing 4 changed files with 9 additions and 13 deletions.
@@ -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?
@@ -98,7 +98,7 @@ public void renameTest() {
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 void dropTest() {
}
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();
@@ -309,18 +309,16 @@ private void parseAlterClause(
// 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);
setMap(ctx, alterMap);
} 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
@@ -655,18 +655,16 @@ private void parseAlterClause(
// 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);
setMap(ctx, alterMap);
} 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

0 comments on commit 406a79f

Please sign in to comment.