Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
86ab422e
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 搜索 >>
未验证
提交
86ab422e
编写于
7月 05, 2023
作者:
C
Chen YZ
提交者:
GitHub
7月 05, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make error messages more detailed when creating and upserting templates
上级
a5fb4f8d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
76 addition
and
15 deletion
+76
-15
integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBSchemaTemplateIT.java
.../org/apache/iotdb/db/it/schema/IoTDBSchemaTemplateIT.java
+28
-0
iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/persistence/schema/TemplateTableTest.java
...otdb/confignode/persistence/schema/TemplateTableTest.java
+15
-0
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java
...che/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java
+11
-3
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/template/ClusterTemplateManager.java
...otdb/db/schemaengine/template/ClusterTemplateManager.java
+15
-10
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/template/Template.java
...a/org/apache/iotdb/db/schemaengine/template/Template.java
+7
-2
未找到文件。
integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBSchemaTemplateIT.java
浏览文件 @
86ab422e
...
...
@@ -800,4 +800,32 @@ public class IoTDBSchemaTemplateIT extends AbstractSchemaIT {
Assert
.
assertTrue
(
expectedResult
.
isEmpty
());
}
}
@Test
public
void
testAlterTemplateTimeseries
()
throws
Exception
{
try
(
Connection
connection
=
EnvFactory
.
getEnv
().
getConnection
();
Statement
statement
=
connection
.
createStatement
())
{
statement
.
execute
(
"SET SCHEMA TEMPLATE t1 TO root.sg1.d1;"
);
statement
.
execute
(
"CREATE TIMESERIES OF SCHEMA TEMPLATE ON root.sg1.d1;"
);
try
{
statement
.
execute
(
"ALTER timeseries root.sg1.d1.s1 UPSERT tags(s0_tag1=s0_tag1, s0_tag2=s0_tag2) attributes(s0_attr1=s0_attr1, s0_attr2=s0_attr2);"
);
Assert
.
fail
(
"expect exception because the template timeseries does not support tag"
);
}
catch
(
Exception
e
)
{
Assert
.
assertTrue
(
e
.
getMessage
()
.
contains
(
"Cannot alter template timeseries [root.sg1.d1.s1] since schema template [t1] already set on path [root.sg1.d1]"
));
}
try
{
statement
.
execute
(
"ALTER timeseries root.sg1.d1.s1 UPSERT ALIAS=s0Alias;"
);
Assert
.
fail
(
"expect exception because the template timeseries does not support alias"
);
}
catch
(
Exception
e
)
{
Assert
.
assertTrue
(
e
.
getMessage
()
.
contains
(
"Cannot alter template timeseries [root.sg1.d1.s1] since schema template [t1] already set on path [root.sg1.d1]"
));
}
}
}
}
iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/persistence/schema/TemplateTableTest.java
浏览文件 @
86ab422e
...
...
@@ -88,6 +88,21 @@ public class TemplateTableTest {
}
}
@Test
public
void
testDuplicatePath
()
{
List
<
String
>
measurements
=
Arrays
.
asList
(
"s1"
,
"s1"
);
List
<
TSDataType
>
dataTypes
=
Arrays
.
asList
(
TSDataType
.
FLOAT
,
TSDataType
.
BOOLEAN
);
List
<
TSEncoding
>
encodings
=
Arrays
.
asList
(
TSEncoding
.
RLE
,
TSEncoding
.
PLAIN
);
List
<
CompressionType
>
compressors
=
Arrays
.
asList
(
CompressionType
.
SNAPPY
,
CompressionType
.
SNAPPY
);
try
{
new
Template
(
"template"
,
measurements
,
dataTypes
,
encodings
,
compressors
);
Assert
.
fail
(
"expect IllegalPathException"
);
}
catch
(
IllegalPathException
e
)
{
// do nothing
}
}
private
Template
newSchemaTemplate
(
String
name
)
throws
IllegalPathException
{
List
<
String
>
measurements
=
Arrays
.
asList
(
name
+
"_"
+
"temperature"
,
name
+
"_"
+
"status"
);
List
<
TSDataType
>
dataTypes
=
Arrays
.
asList
(
TSDataType
.
FLOAT
,
TSDataType
.
BOOLEAN
);
...
...
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java
浏览文件 @
86ab422e
...
...
@@ -2141,9 +2141,17 @@ public class AnalyzeVisitor extends StatementVisitor<Analysis, MPPQueryContext>
Analysis
analysis
=
new
Analysis
();
analysis
.
setStatement
(
alterTimeSeriesStatement
);
if
(
alterTimeSeriesStatement
.
getAlias
()
!=
null
)
{
checkIsTemplateCompatible
(
alterTimeSeriesStatement
.
getPath
(),
alterTimeSeriesStatement
.
getAlias
());
Pair
<
Template
,
PartialPath
>
templateInfo
=
schemaFetcher
.
checkTemplateSetAndPreSetInfo
(
alterTimeSeriesStatement
.
getPath
(),
alterTimeSeriesStatement
.
getAlias
());
if
(
templateInfo
!=
null
)
{
throw
new
RuntimeException
(
new
TemplateImcompatibeException
(
String
.
format
(
"Cannot alter template timeseries [%s] since schema template [%s] already set on path [%s]."
,
alterTimeSeriesStatement
.
getPath
().
getFullPath
(),
templateInfo
.
left
.
getName
(),
templateInfo
.
right
)));
}
PathPatternTree
patternTree
=
new
PathPatternTree
();
...
...
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/template/ClusterTemplateManager.java
浏览文件 @
86ab422e
...
...
@@ -26,6 +26,7 @@ import org.apache.iotdb.commons.consensus.ConfigRegionId;
import
org.apache.iotdb.commons.exception.IllegalPathException
;
import
org.apache.iotdb.commons.exception.IoTDBException
;
import
org.apache.iotdb.commons.exception.MetadataException
;
import
org.apache.iotdb.commons.exception.runtime.SchemaExecutionException
;
import
org.apache.iotdb.commons.path.PartialPath
;
import
org.apache.iotdb.commons.path.PathPatternUtil
;
import
org.apache.iotdb.commons.utils.TestOnly
;
...
...
@@ -135,16 +136,20 @@ public class ClusterTemplateManager implements ITemplateManager {
private
TCreateSchemaTemplateReq
constructTCreateSchemaTemplateReq
(
CreateSchemaTemplateStatement
statement
)
{
TCreateSchemaTemplateReq
req
=
new
TCreateSchemaTemplateReq
();
Template
template
=
new
Template
(
statement
.
getName
(),
statement
.
getMeasurements
(),
statement
.
getDataTypes
(),
statement
.
getEncodings
(),
statement
.
getCompressors
(),
statement
.
isAligned
());
req
.
setName
(
template
.
getName
());
req
.
setSerializedTemplate
(
template
.
serialize
());
try
{
Template
template
=
new
Template
(
statement
.
getName
(),
statement
.
getMeasurements
(),
statement
.
getDataTypes
(),
statement
.
getEncodings
(),
statement
.
getCompressors
(),
statement
.
isAligned
());
req
.
setName
(
template
.
getName
());
req
.
setSerializedTemplate
(
template
.
serialize
());
}
catch
(
IllegalPathException
e
)
{
throw
new
SchemaExecutionException
(
e
);
}
return
req
;
}
...
...
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/template/Template.java
浏览文件 @
86ab422e
...
...
@@ -55,7 +55,8 @@ public class Template implements Serializable {
List
<
String
>
measurements
,
List
<
TSDataType
>
dataTypes
,
List
<
TSEncoding
>
encodings
,
List
<
CompressionType
>
compressors
)
{
List
<
CompressionType
>
compressors
)
throws
IllegalPathException
{
this
(
name
,
measurements
,
dataTypes
,
encodings
,
compressors
,
false
);
}
...
...
@@ -65,11 +66,15 @@ public class Template implements Serializable {
List
<
TSDataType
>
dataTypes
,
List
<
TSEncoding
>
encodings
,
List
<
CompressionType
>
compressors
,
boolean
isAligned
)
{
boolean
isAligned
)
throws
IllegalPathException
{
this
.
isDirectAligned
=
isAligned
;
this
.
schemaMap
=
new
ConcurrentHashMap
<>();
this
.
name
=
name
;
for
(
int
i
=
0
;
i
<
measurements
.
size
();
i
++)
{
if
(
schemaMap
.
containsKey
(
measurements
.
get
(
i
)))
{
throw
new
IllegalPathException
(
"Path duplicated: "
+
measurements
.
get
(
i
));
}
IMeasurementSchema
schema
=
new
MeasurementSchema
(
measurements
.
get
(
i
),
dataTypes
.
get
(
i
),
encodings
.
get
(
i
),
compressors
.
get
(
i
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录