This is an automated email from the ASF dual-hosted git repository.
zyk pushed a commit to branch rel/1.2
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/1.2 by this push:
new e1810830e43 [To rel/1.2] Fix duplicate tag/attribute check and alias
check when altering view (#10339)
e1810830e43 is described below
commit e1810830e438ad507dfb34b8d64d60e34c673e1f
Author: Marcos_Zyk <[email protected]>
AuthorDate: Tue Jun 27 22:09:06 2023 +0800
[To rel/1.2] Fix duplicate tag/attribute check and alias check when
altering view (#10339)
---
.../iotdb/db/mpp/plan/parser/ASTVisitor.java | 27 +++++++++++++++++-----
.../node/metedata/write/AlterTimeSeriesNode.java | 3 ++-
2 files changed, 23 insertions(+), 7 deletions(-)
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 0096ea11900..6fb0c6d1e09 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
@@ -1085,6 +1085,9 @@ public class ASTVisitor extends
IoTDBSqlParserBaseVisitor<Statement> {
alterTimeSeriesStatement.setPath(parseFullPath(ctx.fullPath()));
parseAlterClause(ctx.alterClause(), alterTimeSeriesStatement);
alterTimeSeriesStatement.setAlterView(true);
+ if (alterTimeSeriesStatement.getAlias() != null) {
+ throw new SemanticException("View doesn't support alias.");
+ }
return alterTimeSeriesStatement;
}
}
@@ -3003,11 +3006,17 @@ public class ASTVisitor extends
IoTDBSqlParserBaseVisitor<Statement> {
/** Utils */
private void setMap(IoTDBSqlParser.AlterClauseContext ctx, Map<String,
String> alterMap) {
List<IoTDBSqlParser.AttributePairContext> tagsList = ctx.attributePair();
+ String key;
if (ctx.attributePair(0) != null) {
for (IoTDBSqlParser.AttributePairContext attributePair : tagsList) {
- String value;
- value = parseAttributeValue(attributePair.attributeValue());
- alterMap.put(parseAttributeKey(attributePair.attributeKey()), value);
+ key = parseAttributeKey(attributePair.attributeKey());
+ alterMap.computeIfPresent(
+ key,
+ (k, v) -> {
+ throw new SemanticException(
+ String.format("There's duplicate [%s] in tag or attribute
clause.", k));
+ });
+ alterMap.put(key, parseAttributeValue(attributePair.attributeValue()));
}
}
}
@@ -3017,10 +3026,16 @@ public class ASTVisitor extends
IoTDBSqlParserBaseVisitor<Statement> {
IoTDBSqlParser.AttributePairContext attributePair3) {
Map<String, String> tags = new HashMap<>(attributePair2.size());
if (attributePair3 != null) {
+ String key;
for (IoTDBSqlParser.AttributePairContext attributePair : attributePair2)
{
- tags.put(
- parseAttributeKey(attributePair.attributeKey()),
- parseAttributeValue(attributePair.attributeValue()));
+ key = parseAttributeKey(attributePair.attributeKey());
+ tags.computeIfPresent(
+ key,
+ (k, v) -> {
+ throw new SemanticException(
+ String.format("There's duplicate [%s] in tag or attribute
clause.", k));
+ });
+ tags.put(key, parseAttributeValue(attributePair.attributeValue()));
}
}
return tags;
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/metedata/write/AlterTimeSeriesNode.java
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/metedata/write/AlterTimeSeriesNode.java
index 1d413676e49..ec6809c0363 100644
---
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/metedata/write/AlterTimeSeriesNode.java
+++
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/metedata/write/AlterTimeSeriesNode.java
@@ -60,7 +60,7 @@ public class AlterTimeSeriesNode extends WritePlanNode {
private Map<String, String> tagsMap;
private Map<String, String> attributesMap;
- private transient boolean isAlterView;
+ private boolean isAlterView;
private TRegionReplicaSet regionReplicaSet;
@@ -80,6 +80,7 @@ public class AlterTimeSeriesNode extends WritePlanNode {
this.alias = alias;
this.tagsMap = tagsMap;
this.attributesMap = attributesMap;
+ this.isAlterView = isAlterView;
}
public PartialPath getPath() {