Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4c158238
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4c158238
编写于
11月 28, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test cases
上级
ab86b6ba
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
204 addition
and
8 deletion
+204
-8
tests/system-test/2-query/count.py
tests/system-test/2-query/count.py
+136
-8
tests/system-test/2-query/countAlwaysReturnValue.py
tests/system-test/2-query/countAlwaysReturnValue.py
+68
-0
未找到文件。
tests/system-test/2-query/count.py
浏览文件 @
4c158238
...
...
@@ -51,6 +51,136 @@ class TDTestCase:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
rownum
)
tdSql
.
query
(
f
'select count(
{
k
}
) from
{
ntbname
}
where ts <=
{
self
.
ts
+
self
.
rowNum
-
2
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
rownum
-
1
)
def
query_empty_stb
(
self
):
tdSql
.
query
(
f
'select count(*) from (select distinct tbname from
{
self
.
stbname
}
)'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
self
.
tbnum
)
tdSql
.
query
(
f
'select count(*) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
function_names
=
[
'count'
,
'hyperloglog'
]
for
function_name
in
function_names
:
tdSql
.
query
(
f
'select
{
function_name
}
(tbname) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(ts) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(1) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1),sum(c2),max(1) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkCols
(
3
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
0
,
2
,
None
)
tdSql
.
query
(
f
'select sum(1),
{
function_name
}
(1),max(c2) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkCols
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
0
,
1
,
0
)
tdSql
.
checkData
(
0
,
2
,
None
)
tdSql
.
query
(
f
'select
{
function_name
}
(1),sum(1),max(c2),min(1),min(2),min(3),min(4),min(5),min(6),min(7),min(8) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkCols
(
11
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
0
,
2
,
None
)
tdSql
.
checkData
(
0
,
10
,
None
)
tdSql
.
query
(
f
'select sum(1),max(c2),min(1),leastsquares(c1,1,1) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1),sum(c1) from
{
self
.
stbname
}
group by tbname'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
1
,
0
,
0
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
1
,
1
,
None
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1),sum(c1) from
{
self
.
stbname
}
group by c1'
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(1) from (select
{
function_name
}
(c1),sum(c1) from
{
self
.
stbname
}
group by c1)'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1),sum(c1) from
{
self
.
stbname
}
interval(1s)'
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1),sum(c1) from
{
self
.
stbname
}
partition by tbname interval(1s)'
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1),sum(c1) from
{
self
.
stbname
}
partition by c1 interval(1s)'
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
'select count(1),sum(1) from (select count(1) from
{
self
.
stbname
}
group by tbname)'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
checkData
(
0
,
1
,
2
)
tdSql
.
query
(
f
'select hyperloglog(1),sum(1) from (select hyperloglog(1) from
{
self
.
stbname
}
group by tbname)'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
checkData
(
0
,
1
,
2
)
def
query_empty_ntb
(
self
):
tdSql
.
query
(
f
'select count(*) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
function_names
=
[
'count'
,
'hyperloglog'
]
for
function_name
in
function_names
:
tdSql
.
query
(
f
'select
{
function_name
}
(tbname) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(ts) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(1) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1),sum(c2),max(1) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkCols
(
3
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
0
,
2
,
None
)
tdSql
.
query
(
f
'select sum(1),
{
function_name
}
(1),max(c2) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkCols
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
0
,
1
,
0
)
tdSql
.
checkData
(
0
,
2
,
None
)
tdSql
.
query
(
f
'select
{
function_name
}
(1),sum(1),max(c2),min(1),min(2),min(3),min(4),min(5),min(6),min(7),min(8) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkCols
(
11
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
0
,
2
,
None
)
tdSql
.
checkData
(
0
,
10
,
None
)
tdSql
.
query
(
f
'select sum(1),max(c2),min(1),leastsquares(c1,1,1) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1),sum(c1) from
{
self
.
ntbname
}
group by tbname'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1),sum(c1) from
{
self
.
ntbname
}
group by c1'
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(1) from (select
{
function_name
}
(c1),sum(c1) from
{
self
.
ntbname
}
group by c1)'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1),sum(c1) from
{
self
.
ntbname
}
interval(1s)'
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1),sum(c1) from
{
self
.
ntbname
}
partition by tbname interval(1s)'
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
'select
{
function_name
}
(c1),sum(c1) from
{
self
.
ntbname
}
partition by c1 interval(1s)'
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
'select count(1),sum(1) from (select count(1) from
{
self
.
ntbname
}
group by tbname)'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
query
(
f
'select hyperloglog(1),sum(1) from (select hyperloglog(1) from
{
self
.
ntbname
}
group by tbname)'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
checkData
(
0
,
1
,
1
)
def
count_query_stb
(
self
,
column_dict
,
tag_dict
,
stbname
,
tbnum
,
rownum
):
tdSql
.
query
(
f
'select count(tbname) from
{
stbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
tbnum
*
rownum
)
...
...
@@ -81,11 +211,11 @@ class TDTestCase:
def
check_ntb
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
self
.
setsql
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
tdSql
.
query
(
f
'select count(tbname) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
0
)
self
.
query_empty_ntb
()
tdSql
.
execute
(
'flush database db'
)
tdSql
.
query
(
f
'select count(tbname) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
self
.
insert_data
(
self
.
column_dict
,
self
.
ntbname
,
self
.
rowNum
)
self
.
count_query_ntb
(
self
.
column_dict
,
self
.
ntbname
,
self
.
rowNum
)
tdSql
.
execute
(
'flush database db'
)
...
...
@@ -96,13 +226,11 @@ class TDTestCase:
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_values
[
i
]
}
)'
)
tdSql
.
query
(
f
'SELECT count(*) from (select distinct tbname from
{
self
.
stbname
}
)'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
self
.
tbnum
)
tdSql
.
query
(
f
'select count(tbname) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
0
)
self
.
query_empty_stb
()
tdSql
.
execute
(
'flush database db'
)
tdSql
.
query
(
f
'select count(tbname) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
f
'SELECT count(*) from (select distinct tbname from
{
self
.
stbname
}
)'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
self
.
tbnum
)
for
i
in
range
(
self
.
tbnum
):
...
...
tests/system-test/2-query/countAlwaysReturnValue.py
浏览文件 @
4c158238
...
...
@@ -33,6 +33,19 @@ class TDTestCase:
f
"create table
{
dbname
}
.ctb2 using
{
dbname
}
.stb tags (2)"
)
tdSql
.
execute
(
f
"create table
{
dbname
}
.tb_empty (ts timestamp, c0 int)"
)
tdSql
.
execute
(
f
"create table
{
dbname
}
.stb_empty (ts timestamp, c0 int) tags (t0 int)"
)
tdSql
.
execute
(
f
"create table
{
dbname
}
.ctb1_empty using
{
dbname
}
.stb tags (1)"
)
tdSql
.
execute
(
f
"create table
{
dbname
}
.ctb2_empty using
{
dbname
}
.stb tags (2)"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.tb values (now(), NULL)"
)
...
...
@@ -94,6 +107,61 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
# test empty table/input
tdSql
.
query
(
f
"select count(*) from
{
dbname
}
.tb where ts > now + 1h"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select count(ts) from
{
dbname
}
.stb where ts > now + 1h"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select count(c0) from
{
dbname
}
.ctb1 where ts > now + 1h"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select count(1) from
{
dbname
}
.ctb2 where ts > now + 1h"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select count(*) from
{
dbname
}
.tb_empty"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select count(ts) from
{
dbname
}
.stb_empty"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select count(c0) from
{
dbname
}
.ctb1_empty"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select count(1) from
{
dbname
}
.ctb2_empty"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select hyperloglog(c0) from
{
dbname
}
.tb where ts > now + 1h"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select hyperloglog(ts) from
{
dbname
}
.stb where ts > now + 1h"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select hyperloglog(1) from
{
dbname
}
.ctb1 where ts > now + 1h"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select hyperloglog(1) from
{
dbname
}
.ctb2 where ts > now + 1h"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select hyperloglog(c0) from
{
dbname
}
.tb_empty"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select hyperloglog(ts) from
{
dbname
}
.stb_empty"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select hyperloglog(1) from
{
dbname
}
.ctb1_empty"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select hyperloglog(1) from
{
dbname
}
.ctb2_empty"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select count(*), hyperloglog(c0), sum(1), max(c0) from
{
dbname
}
.tb where ts > now + 1h"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select count(*), hyperloglog(c0), sum(1), max(c0) from
{
dbname
}
.tb_empty"
)
tdSql
.
checkRows
(
0
)
def
run
(
self
):
tdSql
.
prepare
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录