Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
848c908f
I
Iotdb
项目概览
apache
/
Iotdb
10 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
848c908f
编写于
7月 06, 2023
作者:
C
Chen YZ
提交者:
GitHub
7月 06, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix duplicate tag/attribute check and alias check when altering view
上级
e5d4745c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
77 addition
and
7 deletion
+77
-7
integration-test/src/test/java/org/apache/iotdb/db/it/schema/view/IoTDBAlterViewIT.java
.../org/apache/iotdb/db/it/schema/view/IoTDBAlterViewIT.java
+54
-0
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
...g/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
+21
-6
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/metedata/write/AlterTimeSeriesNode.java
...planner/plan/node/metedata/write/AlterTimeSeriesNode.java
+2
-1
未找到文件。
integration-test/src/test/java/org/apache/iotdb/db/it/schema/view/IoTDBAlterViewIT.java
浏览文件 @
848c908f
...
...
@@ -346,4 +346,58 @@ public class IoTDBAlterViewIT {
Assert
.
assertTrue
(
expectedResult
.
isEmpty
());
}
}
@Test
public
void
testUpsertAliasException
()
throws
Exception
{
try
(
Connection
connection
=
EnvFactory
.
getEnv
().
getConnection
();
Statement
statement
=
connection
.
createStatement
())
{
statement
.
execute
(
"create timeseries root.db.d1.s1 with datatype=INT32"
);
statement
.
execute
(
"create view root.view.d1.s1 as root.db.d1.s1;"
);
try
{
statement
.
execute
(
"alter view root.view.d1.s1 upsert alias=a;"
);
Assert
.
fail
(
"expect exception"
);
}
catch
(
Exception
e
)
{
Assert
.
assertTrue
(
e
.
getMessage
().
contains
(
"View doesn't support alias"
));
}
}
}
@Test
public
void
testAlterViewTagAttributesException
()
throws
Exception
{
try
(
Connection
connection
=
EnvFactory
.
getEnv
().
getConnection
();
Statement
statement
=
connection
.
createStatement
())
{
statement
.
execute
(
"create timeseries root.db.d1.s1 with datatype=INT32"
);
statement
.
execute
(
"create view root.view.d1.s1 as root.db.d1.s1;"
);
try
{
statement
.
execute
(
"alter view root.view.d1.s1 add tags t1=a,t1=b;"
);
Assert
.
fail
(
"expect exception"
);
}
catch
(
Exception
e
)
{
Assert
.
assertTrue
(
e
.
getMessage
().
contains
(
"There's duplicate [t1] in tag or attribute clause."
));
}
statement
.
execute
(
"alter view root.view.d1.s1 add tags t1=a,t2=b;"
);
try
{
statement
.
execute
(
"alter view root.view.d1.s1 set t1=a,t1=b;"
);
Assert
.
fail
(
"expect exception"
);
}
catch
(
Exception
e
)
{
Assert
.
assertTrue
(
e
.
getMessage
().
contains
(
"There's duplicate [t1] in tag or attribute clause."
));
}
try
{
statement
.
execute
(
"alter view root.view.d1.s1 upsert tags(t1=a,t1=b);"
);
Assert
.
fail
(
"expect exception"
);
}
catch
(
Exception
e
)
{
Assert
.
assertTrue
(
e
.
getMessage
().
contains
(
"There's duplicate [t1] in tag or attribute clause."
));
}
try
{
statement
.
execute
(
"alter view root.view.d1.s1 rename t2 to t1;"
);
Assert
.
fail
(
"expect exception"
);
}
catch
(
Exception
e
)
{
Assert
.
assertTrue
(
e
.
getMessage
()
.
contains
(
"TimeSeries [root.view.d1.s1] already has a tag/attribute named [t1]"
));
}
}
}
}
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
浏览文件 @
848c908f
...
...
@@ -1089,6 +1089,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
;
}
}
...
...
@@ -3002,11 +3005,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
()));
}
}
}
...
...
@@ -3016,10 +3025,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
;
...
...
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/metedata/write/AlterTimeSeriesNode.java
浏览文件 @
848c908f
...
...
@@ -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
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录