Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
227811f9
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
227811f9
编写于
6月 30, 2022
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update alter_stable case
上级
24a9d3e5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
121 addition
and
8 deletion
+121
-8
tests/system-test/1-insert/alter_stable.py
tests/system-test/1-insert/alter_stable.py
+121
-8
未找到文件。
tests/system-test/1-insert/alter_stable.py
浏览文件 @
227811f9
...
...
@@ -16,12 +16,74 @@ import string
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.sqlset
import
*
from
util
import
constant
from
util.common
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
setsql
=
TDSetSql
()
self
.
ntbname
=
'ntb'
self
.
stbname
=
'stb'
self
.
binary_length
=
20
# the length of binary for column_dict
self
.
nchar_length
=
20
# the length of nchar for column_dict
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
'col4'
:
'bigint'
,
'col5'
:
'tinyint unsigned'
,
'col6'
:
'smallint unsigned'
,
'col7'
:
'int unsigned'
,
'col8'
:
'bigint unsigned'
,
'col9'
:
'float'
,
'col10'
:
'double'
,
'col11'
:
'bool'
,
'col12'
:
f
'binary(
{
self
.
binary_length
}
)'
,
'col13'
:
f
'nchar(
{
self
.
nchar_length
}
)'
}
self
.
tag_dict
=
{
'ts_tag'
:
'timestamp'
,
't1'
:
'tinyint'
,
't2'
:
'smallint'
,
't3'
:
'int'
,
't4'
:
'bigint'
,
't5'
:
'tinyint unsigned'
,
't6'
:
'smallint unsigned'
,
't7'
:
'int unsigned'
,
't8'
:
'bigint unsigned'
,
't9'
:
'float'
,
't10'
:
'double'
,
't11'
:
'bool'
,
't12'
:
f
'binary(
{
self
.
binary_length
}
)'
,
't13'
:
f
'nchar(
{
self
.
nchar_length
}
)'
}
self
.
tag_list
=
[
f
'now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据"'
]
self
.
tbnum
=
1
self
.
values_list
=
[
f
'now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据"'
]
self
.
column_add_dict
=
{
'col_time'
:
'timestamp'
,
'col_tinyint'
:
'tinyint'
,
'col_smallint'
:
'smallint'
,
'col_int'
:
'int'
,
'col_bigint'
:
'bigint'
,
'col_untinyint'
:
'tinyint unsigned'
,
'col_smallint'
:
'smallint unsigned'
,
'col_int'
:
'int unsigned'
,
'col_bigint'
:
'bigint unsigned'
,
'col_bool'
:
'bool'
,
'col_float'
:
'float'
,
'col_double'
:
'double'
,
'col_binary'
:
f
'binary(
{
constant
.
BINARY_LENGTH_MAX
}
)'
,
'col_nchar'
:
f
'nchar(
{
constant
.
NCAHR_LENGTH_MAX
}
)'
}
def
get_long_name
(
self
,
length
,
mode
=
"mixed"
):
"""
generate long name
...
...
@@ -133,15 +195,66 @@ class TDTestCase:
# tdSql.execute(f'create table ntb (ts timestamp,c0 int)')
tdSql
.
error
(
f
'alter stable ntb add column c2 '
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
def
alter_stable_check
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
for
i
in
range
(
self
.
tbnum
):
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_list
[
i
]
}
)'
)
for
j
in
self
.
values_list
:
tdSql
.
execute
(
f
'insert into
{
self
.
stbname
}
_
{
i
}
values(
{
j
}
)'
)
for
key
,
values
in
self
.
column_add_dict
.
items
():
tdSql
.
execute
(
f
'alter stable
{
self
.
stbname
}
add column
{
key
}
{
values
}
'
)
tdSql
.
query
(
f
'describe
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
len
(
self
.
column_dict
)
+
len
(
self
.
tag_dict
)
+
1
)
for
i
in
range
(
self
.
tbnum
):
tdSql
.
query
(
f
'describe
{
self
.
stbname
}
_
{
i
}
'
)
tdSql
.
checkRows
(
len
(
self
.
column_dict
)
+
len
(
self
.
tag_dict
)
+
1
)
tdSql
.
query
(
f
'select
{
key
}
from
{
self
.
stbname
}
_
{
i
}
'
)
tdSql
.
checkRows
(
len
(
self
.
values_list
))
tdSql
.
execute
(
f
'alter stable
{
self
.
stbname
}
drop column
{
key
}
'
)
tdSql
.
query
(
f
'describe
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
len
(
self
.
column_dict
)
+
len
(
self
.
tag_dict
))
for
i
in
range
(
self
.
tbnum
):
tdSql
.
query
(
f
'describe
{
self
.
stbname
}
_
{
i
}
'
)
tdSql
.
checkRows
(
len
(
self
.
column_dict
)
+
len
(
self
.
tag_dict
))
tdSql
.
error
(
f
'select
{
key
}
from
{
self
.
stbname
}
'
)
for
key
,
values
in
self
.
column_dict
.
items
():
if
'binary'
in
values
.
lower
():
v
=
f
'binary(
{
self
.
binary_length
+
1
}
)'
v_error
=
f
'binary(
{
self
.
binary_length
-
1
}
)'
tdSql
.
error
(
f
'alter stable
{
self
.
stbname
}
modify column
{
key
}
{
v_error
}
'
)
tdSql
.
execute
(
f
'alter stable
{
self
.
stbname
}
modify column
{
key
}
{
v
}
'
)
tdSql
.
query
(
f
'describe
{
self
.
stbname
}
'
)
result
=
tdCom
.
getOneRow
(
1
,
'VARCHAR'
)
tdSql
.
checkEqual
(
result
[
0
][
2
],
self
.
binary_length
+
1
)
for
i
in
range
(
self
.
tbnum
):
tdSql
.
query
(
f
'describe
{
self
.
stbname
}
_
{
i
}
'
)
result
=
tdCom
.
getOneRow
(
1
,
'VARCHAR'
)
tdSql
.
checkEqual
(
result
[
0
][
2
],
self
.
binary_length
+
1
)
elif
'nchar'
in
values
.
lower
():
v
=
f
'nchar(
{
self
.
binary_length
+
1
}
)'
v_error
=
f
'nchar(
{
self
.
binary_length
-
1
}
)'
tdSql
.
error
(
f
'alter stable
{
self
.
stbname
}
modify column
{
key
}
{
v_error
}
'
)
tdSql
.
execute
(
f
'alter stable
{
self
.
stbname
}
modify column
{
key
}
{
v
}
'
)
tdSql
.
query
(
f
'describe
{
self
.
stbname
}
'
)
result
=
tdCom
.
getOneRow
(
1
,
'NCHAR'
)
tdSql
.
checkEqual
(
result
[
0
][
2
],
self
.
binary_length
+
1
)
for
i
in
range
(
self
.
tbnum
):
tdSql
.
query
(
f
'describe
{
self
.
stbname
}
_
{
i
}
'
)
result
=
tdCom
.
getOneRow
(
1
,
'NCHAR'
)
tdSql
.
checkEqual
(
result
[
0
][
2
],
self
.
binary_length
+
1
)
else
:
for
v
in
self
.
column_dict
.
values
():
tdSql
.
error
(
f
'alter stable
{
self
.
stbname
}
modify column
{
key
}
{
v
}
'
)
pass
def
run
(
self
):
dbname
=
self
.
get_long_name
(
length
=
10
,
mode
=
"letters"
)
stbname
=
self
.
get_long_name
(
length
=
5
,
mode
=
"letters"
)
tbname
=
self
.
get_long_name
(
length
=
5
,
mode
=
"letters"
)
self
.
alter_stable_column_check
(
dbname
,
stbname
,
tbname
)
self
.
alter_stable_tag_check
(
dbname
,
stbname
,
tbname
)
#
dbname = self.get_long_name(length=10, mode="letters")
#
stbname = self.get_long_name(length=5, mode="letters")
#
tbname = self.get_long_name(length=5, mode="letters")
#
self.alter_stable_column_check(dbname,stbname,tbname)
#
self.alter_stable_tag_check(dbname,stbname,tbname)
self
.
alter_stable_check
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录