Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c72c3472
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
c72c3472
编写于
12月 19, 2022
作者:
H
Hui Li
提交者:
GitHub
12月 19, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18969 from taosdata/test/TD-19841
test: add test case for leastsquares
上级
94e89963
9eeba415
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
25 deletion
+40
-25
tests/system-test/2-query/leastsquares.py
tests/system-test/2-query/leastsquares.py
+40
-25
未找到文件。
tests/system-test/2-query/leastsquares.py
浏览文件 @
c72c3472
...
...
@@ -19,12 +19,17 @@ BINARY_COL = "c8"
NCHAR_COL
=
"c9"
TS_COL
=
"c10"
NUM_COL
=
[
INT_COL
,
BINT_COL
,
SINT_COL
,
TINT_COL
,
FLOAT_COL
,
DOUBLE_COL
,
]
UINT_COL
=
"c11"
UBINT_COL
=
"c12"
USINT_COL
=
"c13"
UTINT_COL
=
"c14"
NUM_COL
=
[
INT_COL
,
BINT_COL
,
SINT_COL
,
TINT_COL
,
FLOAT_COL
,
DOUBLE_COL
,
UINT_COL
,
UBINT_COL
,
USINT_COL
,
UTINT_COL
]
CHAR_COL
=
[
BINARY_COL
,
NCHAR_COL
,
]
BOOLEAN_COL
=
[
BOOL_COL
,
]
TS_TYPE_COL
=
[
TS_COL
,
]
ALL_COL
=
[
INT_COL
,
BINT_COL
,
SINT_COL
,
TINT_COL
,
FLOAT_COL
,
DOUBLE_COL
,
BOOL_COL
,
BINARY_COL
,
NCHAR_COL
,
TS_COL
]
ALL_COL
=
[
INT_COL
,
BINT_COL
,
SINT_COL
,
TINT_COL
,
FLOAT_COL
,
DOUBLE_COL
,
BOOL_COL
,
BINARY_COL
,
NCHAR_COL
,
TS_COL
,
UINT_COL
,
UBINT_COL
,
USINT_COL
,
UTINT_COL
]
DBNAME
=
"db"
class
TDTestCase
:
...
...
@@ -208,6 +213,13 @@ class TDTestCase:
tdLog
.
info
(
f
"sql:
{
current_sqls
[
i
]
}
"
)
tdSql
.
query
(
current_sqls
[
i
])
def
check_result
(
self
):
for
col
in
NUM_COL
:
tdSql
.
query
(
"select leastsquares(%s, 1, 9) from %s.stb1"
%
(
col
,
DBNAME
))
tdSql
.
checkRows
(
1
)
res
=
tdSql
.
getData
(
0
,
0
)
if
res
is
None
:
tdLog
.
exit
(
"result is not correct"
)
def
__test_current
(
self
):
# tdSql.query("explain select c1 from {dbname}.ct1")
...
...
@@ -236,6 +248,7 @@ class TDTestCase:
def
all_test
(
self
):
self
.
__test_error
()
self
.
__test_current
()
self
.
check_result
()
def
__create_tb
(
self
,
dbname
=
DBNAME
):
...
...
@@ -243,13 +256,15 @@ class TDTestCase:
create_stb_sql
=
f
'''create table
{
dbname
}
.stb1(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp,
{
UINT_COL
}
int unsigned,
{
UBINT_COL
}
bigint unsigned,
{
USINT_COL
}
smallint unsigned,
{
UTINT_COL
}
tinyint unsigned
) tags (t1 int)
'''
create_ntb_sql
=
f
'''create table
{
dbname
}
.nt1(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp,
{
UINT_COL
}
int unsigned,
{
UBINT_COL
}
bigint unsigned,
{
USINT_COL
}
smallint unsigned,
{
UTINT_COL
}
tinyint unsigned
)
'''
tdSql
.
execute
(
create_stb_sql
)
...
...
@@ -262,49 +277,49 @@ class TDTestCase:
now_time
=
int
(
datetime
.
datetime
.
timestamp
(
datetime
.
datetime
.
now
())
*
1000
)
for
i
in
range
(
rows
):
tdSql
.
execute
(
f
"insert into
{
dbname
}
.ct1 values (
{
now_time
-
i
*
1000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
dbname
}
.ct1 values (
{
now_time
-
i
*
1000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
)"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.ct4 values (
{
now_time
-
i
*
7776000000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
dbname
}
.ct4 values (
{
now_time
-
i
*
7776000000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
)"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.ct2 values (
{
now_time
-
i
*
7776000000
}
,
{
-
i
}
,
{
-
11111
*
i
}
,
{
-
111
*
i
%
32767
}
,
{
-
11
*
i
%
127
}
,
{
-
1.11
*
i
}
,
{
-
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
dbname
}
.ct2 values (
{
now_time
-
i
*
7776000000
}
,
{
-
i
}
,
{
-
11111
*
i
}
,
{
-
111
*
i
%
32767
}
,
{
-
11
*
i
%
127
}
,
{
-
1.11
*
i
}
,
{
-
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
)"
)
tdSql
.
execute
(
f
'''insert into
{
dbname
}
.ct1 values
(
{
now_time
-
rows
*
5
}
, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0',
{
now_time
+
8
}
)
(
{
now_time
+
10000
}
,
{
rows
}
, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9',
{
now_time
+
9
}
)
(
{
now_time
-
rows
*
5
}
, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0',
{
now_time
+
8
}
, 0, 0, 0, 0
)
(
{
now_time
+
10000
}
,
{
rows
}
, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9',
{
now_time
+
9
}
, 0, 0, 0, NULL
)
'''
)
tdSql
.
execute
(
f
'''insert into
{
dbname
}
.ct4 values
(
{
now_time
-
rows
*
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3888000000
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
+
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
)
(
{
now_time
-
rows
*
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL
)
(
{
now_time
-
rows
*
3888000000
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL
)
(
{
now_time
+
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL
)
(
{
now_time
+
5184000000
}
,
{
pow
(
2
,
31
)
-
pow
(
2
,
15
)
}
,
{
pow
(
2
,
63
)
-
pow
(
2
,
30
)
}
, 32767, 127,
{
3.3
*
pow
(
10
,
38
)
}
,
{
1.3
*
pow
(
10
,
308
)
}
,
{
rows
%
2
}
, "binary_limit-1", "nchar_测试_limit-1",
{
now_time
-
86400000
}
{
3.3
*
pow
(
10
,
38
)
}
,
{
1.3
*
pow
(
10
,
308
)
}
,
{
rows
%
2
}
, "binary_limit-1", "nchar_测试_limit-1",
{
now_time
-
86400000
}
, NULL, NULL, NULL, NULL
)
(
{
now_time
+
2592000000
}
,
{
pow
(
2
,
31
)
-
pow
(
2
,
16
)
}
,
{
pow
(
2
,
63
)
-
pow
(
2
,
31
)
}
, 32766, 126,
{
3.2
*
pow
(
10
,
38
)
}
,
{
1.2
*
pow
(
10
,
308
)
}
,
{
(
rows
-
1
)
%
2
}
, "binary_limit-2", "nchar_测试_limit-2",
{
now_time
-
172800000
}
{
3.2
*
pow
(
10
,
38
)
}
,
{
1.2
*
pow
(
10
,
308
)
}
,
{
(
rows
-
1
)
%
2
}
, "binary_limit-2", "nchar_测试_limit-2",
{
now_time
-
172800000
}
, NULL, NULL, NULL, NULL
)
'''
)
tdSql
.
execute
(
f
'''insert into
{
dbname
}
.ct2 values
(
{
now_time
-
rows
*
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
)
(
{
now_time
-
rows
*
3888000000
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
+
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL
)
(
{
now_time
-
rows
*
3888000000
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL
)
(
{
now_time
+
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL
)
(
{
now_time
+
5184000000
}
,
{
-
1
*
pow
(
2
,
31
)
+
pow
(
2
,
15
)
}
,
{
-
1
*
pow
(
2
,
63
)
+
pow
(
2
,
30
)
}
, -32766, -126,
{
-
1
*
3.2
*
pow
(
10
,
38
)
}
,
{
-
1.2
*
pow
(
10
,
308
)
}
,
{
rows
%
2
}
, "binary_limit-1", "nchar_测试_limit-1",
{
now_time
-
86400000
}
{
-
1
*
3.2
*
pow
(
10
,
38
)
}
,
{
-
1.2
*
pow
(
10
,
308
)
}
,
{
rows
%
2
}
, "binary_limit-1", "nchar_测试_limit-1",
{
now_time
-
86400000
}
, NULL, NULL, NULL, NULL
)
(
{
now_time
+
2592000000
}
,
{
-
1
*
pow
(
2
,
31
)
+
pow
(
2
,
16
)
}
,
{
-
1
*
pow
(
2
,
63
)
+
pow
(
2
,
31
)
}
, -32767, -127,
{
-
3.3
*
pow
(
10
,
38
)
}
,
{
-
1.3
*
pow
(
10
,
308
)
}
,
{
(
rows
-
1
)
%
2
}
, "binary_limit-2", "nchar_测试_limit-2",
{
now_time
-
172800000
}
{
-
3.3
*
pow
(
10
,
38
)
}
,
{
-
1.3
*
pow
(
10
,
308
)
}
,
{
(
rows
-
1
)
%
2
}
, "binary_limit-2", "nchar_测试_limit-2",
{
now_time
-
172800000
}
, NULL, NULL, NULL, NULL
)
'''
)
...
...
@@ -312,22 +327,22 @@ class TDTestCase:
for
i
in
range
(
rows
):
insert_data
=
f
'''insert into
{
dbname
}
.nt1 values
(
{
now_time
-
i
*
3600000
}
,
{
i
}
,
{
i
*
11111
}
,
{
i
%
32767
}
,
{
i
%
127
}
,
{
i
*
1.11111
}
,
{
i
*
1000.1111
}
,
{
i
%
2
}
,
"binary_
{
i
}
", "nchar_测试_
{
i
}
",
{
now_time
-
1000
*
i
}
)
"binary_
{
i
}
", "nchar_测试_
{
i
}
",
{
now_time
-
1000
*
i
}
, NULL, NULL, NULL, NULL
)
'''
tdSql
.
execute
(
insert_data
)
tdSql
.
execute
(
f
'''insert into
{
dbname
}
.nt1 values
(
{
now_time
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
((
rows
//
2
)
*
60
+
30
)
*
60000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3600000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL
)
(
{
now_time
-
((
rows
//
2
)
*
60
+
30
)
*
60000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL
)
(
{
now_time
-
rows
*
3600000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
, NULL, NULL, NULL, NULL
)
(
{
now_time
+
7200000
}
,
{
pow
(
2
,
31
)
-
pow
(
2
,
15
)
}
,
{
pow
(
2
,
63
)
-
pow
(
2
,
30
)
}
, 32767, 127,
{
3.3
*
pow
(
10
,
38
)
}
,
{
1.3
*
pow
(
10
,
308
)
}
,
{
rows
%
2
}
,
"binary_limit-1", "nchar_测试_limit-1",
{
now_time
-
86400000
}
"binary_limit-1", "nchar_测试_limit-1",
{
now_time
-
86400000
}
, NULL, NULL, NULL, NULL
)
(
{
now_time
+
3600000
}
,
{
pow
(
2
,
31
)
-
pow
(
2
,
16
)
}
,
{
pow
(
2
,
63
)
-
pow
(
2
,
31
)
}
, 32766, 126,
{
3.2
*
pow
(
10
,
38
)
}
,
{
1.2
*
pow
(
10
,
308
)
}
,
{
(
rows
-
1
)
%
2
}
,
"binary_limit-2", "nchar_测试_limit-2",
{
now_time
-
172800000
}
"binary_limit-2", "nchar_测试_limit-2",
{
now_time
-
172800000
}
, NULL, NULL, NULL, NULL
)
'''
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录