Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5a0668da
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看板
未验证
提交
5a0668da
编写于
7月 20, 2022
作者:
G
Ganlin Zhao
提交者:
GitHub
7月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15181 from taosdata/fix/TD-17511
fix(query): twa function handling null constant or all null column
上级
aa84a1bf
01385a4b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
92 addition
and
55 deletion
+92
-55
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+53
-16
tests/system-test/2-query/max_partition.py
tests/system-test/2-query/max_partition.py
+27
-27
tests/system-test/2-query/twa.py
tests/system-test/2-query/twa.py
+12
-12
未找到文件。
source/libs/function/src/builtinsimpl.c
浏览文件 @
5a0668da
...
@@ -165,6 +165,7 @@ typedef struct SElapsedInfo {
...
@@ -165,6 +165,7 @@ typedef struct SElapsedInfo {
typedef
struct
STwaInfo
{
typedef
struct
STwaInfo
{
double
dOutput
;
double
dOutput
;
bool
isNull
;
SPoint1
p
;
SPoint1
p
;
STimeWindow
win
;
STimeWindow
win
;
}
STwaInfo
;
}
STwaInfo
;
...
@@ -5181,8 +5182,9 @@ bool twaFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) {
...
@@ -5181,8 +5182,9 @@ bool twaFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) {
}
}
STwaInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
STwaInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
pInfo
->
p
.
key
=
INT64_MIN
;
pInfo
->
isNull
=
false
;
pInfo
->
win
=
TSWINDOW_INITIALIZER
;
pInfo
->
p
.
key
=
INT64_MIN
;
pInfo
->
win
=
TSWINDOW_INITIALIZER
;
return
true
;
return
true
;
}
}
...
@@ -5208,27 +5210,47 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
...
@@ -5208,27 +5210,47 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
SPoint1
*
last
=
&
pInfo
->
p
;
SPoint1
*
last
=
&
pInfo
->
p
;
int32_t
numOfElems
=
0
;
int32_t
numOfElems
=
0
;
if
(
IS_NULL_TYPE
(
pInputCol
->
info
.
type
))
{
pInfo
->
isNull
=
true
;
goto
_twa_over
;
}
int32_t
i
=
pInput
->
startRowIndex
;
int32_t
i
=
pInput
->
startRowIndex
;
if
(
pCtx
->
start
.
key
!=
INT64_MIN
)
{
if
(
pCtx
->
start
.
key
!=
INT64_MIN
)
{
ASSERT
((
pCtx
->
start
.
key
<
tsList
[
i
]
&&
pCtx
->
order
==
TSDB_ORDER_ASC
)
||
ASSERT
((
pCtx
->
start
.
key
<
tsList
[
i
]
&&
pCtx
->
order
==
TSDB_ORDER_ASC
)
||
(
pCtx
->
start
.
key
>
tsList
[
i
]
&&
pCtx
->
order
==
TSDB_ORDER_DESC
));
(
pCtx
->
start
.
key
>
tsList
[
i
]
&&
pCtx
->
order
==
TSDB_ORDER_DESC
));
ASSERT
(
last
->
key
==
INT64_MIN
);
ASSERT
(
last
->
key
==
INT64_MIN
);
last
->
key
=
tsList
[
i
];
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
++
i
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
}
GET_TYPED_DATA
(
last
->
val
,
double
,
pInputCol
->
info
.
type
,
colDataGetData
(
pInputCol
,
i
))
;
last
->
key
=
tsList
[
i
]
;
pInfo
->
dOutput
+=
twa_get_area
(
pCtx
->
start
,
*
last
);
GET_TYPED_DATA
(
last
->
val
,
double
,
pInputCol
->
info
.
type
,
colDataGetData
(
pInputCol
,
i
));
pInfo
->
win
.
skey
=
pCtx
->
start
.
key
;
numOfElems
++
;
pInfo
->
dOutput
+=
twa_get_area
(
pCtx
->
start
,
*
last
);
i
+=
1
;
pInfo
->
win
.
skey
=
pCtx
->
start
.
key
;
numOfElems
++
;
i
+=
1
;
break
;
}
}
else
if
(
pInfo
->
p
.
key
==
INT64_MIN
)
{
}
else
if
(
pInfo
->
p
.
key
==
INT64_MIN
)
{
last
->
key
=
tsList
[
i
];
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
++
i
)
{
GET_TYPED_DATA
(
last
->
val
,
double
,
pInputCol
->
info
.
type
,
colDataGetData
(
pInputCol
,
i
));
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
}
pInfo
->
win
.
skey
=
last
->
key
;
last
->
key
=
tsList
[
i
];
numOfElems
++
;
i
+=
1
;
GET_TYPED_DATA
(
last
->
val
,
double
,
pInputCol
->
info
.
type
,
colDataGetData
(
pInputCol
,
i
));
pInfo
->
win
.
skey
=
last
->
key
;
numOfElems
++
;
i
+=
1
;
break
;
}
}
}
SPoint1
st
=
{
0
};
SPoint1
st
=
{
0
};
...
@@ -5241,6 +5263,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
...
@@ -5241,6 +5263,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
}
}
numOfElems
++
;
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
...
@@ -5255,6 +5278,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
...
@@ -5255,6 +5278,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
}
}
numOfElems
++
;
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
...
@@ -5268,6 +5292,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
...
@@ -5268,6 +5292,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
}
}
numOfElems
++
;
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
...
@@ -5281,6 +5306,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
...
@@ -5281,6 +5306,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
}
}
numOfElems
++
;
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
...
@@ -5294,6 +5320,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
...
@@ -5294,6 +5320,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
}
}
numOfElems
++
;
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
...
@@ -5307,6 +5334,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
...
@@ -5307,6 +5334,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
}
}
numOfElems
++
;
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
...
@@ -5320,6 +5348,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
...
@@ -5320,6 +5348,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
}
}
numOfElems
++
;
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
...
@@ -5333,6 +5362,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
...
@@ -5333,6 +5362,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
}
}
numOfElems
++
;
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
...
@@ -5346,6 +5376,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
...
@@ -5346,6 +5376,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
}
}
numOfElems
++
;
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
...
@@ -5359,6 +5390,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
...
@@ -5359,6 +5390,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
}
}
numOfElems
++
;
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
...
@@ -5379,7 +5411,12 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
...
@@ -5379,7 +5411,12 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
pInfo
->
win
.
ekey
=
pInfo
->
p
.
key
;
pInfo
->
win
.
ekey
=
pInfo
->
p
.
key
;
SET_VAL
(
pResInfo
,
numOfElems
,
1
);
_twa_over:
if
(
numOfElems
==
0
)
{
pInfo
->
isNull
=
true
;
}
SET_VAL
(
pResInfo
,
1
,
1
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -5400,8 +5437,8 @@ int32_t twaFinalize(struct SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
...
@@ -5400,8 +5437,8 @@ int32_t twaFinalize(struct SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STwaInfo
*
pInfo
=
(
STwaInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
STwaInfo
*
pInfo
=
(
STwaInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
if
(
p
ResInfo
->
numOfRes
==
0
)
{
if
(
p
Info
->
isNull
==
true
)
{
pResInfo
->
isNullRes
=
1
;
pResInfo
->
numOfRes
=
0
;
}
else
{
}
else
{
if
(
pInfo
->
win
.
ekey
==
pInfo
->
win
.
skey
)
{
if
(
pInfo
->
win
.
ekey
==
pInfo
->
win
.
skey
)
{
pInfo
->
dOutput
=
pInfo
->
p
.
val
;
pInfo
->
dOutput
=
pInfo
->
p
.
val
;
...
...
tests/system-test/2-query/max_partition.py
浏览文件 @
5a0668da
...
@@ -11,13 +11,13 @@ class TDTestCase:
...
@@ -11,13 +11,13 @@ class TDTestCase:
self
.
row_nums
=
10
self
.
row_nums
=
10
self
.
tb_nums
=
10
self
.
tb_nums
=
10
self
.
ts
=
1537146000000
self
.
ts
=
1537146000000
def
prepare_datas
(
self
,
stb_name
,
tb_nums
,
row_nums
):
def
prepare_datas
(
self
,
stb_name
,
tb_nums
,
row_nums
):
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
f
" create stable
{
stb_name
}
(ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,
\
tdSql
.
execute
(
f
" create stable
{
stb_name
}
(ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,
\
uc2 bigint unsigned ,uc3 smallint unsigned , uc4 tinyint unsigned ) tags(t1 timestamp , t2 int , t3 bigint , t4 float , t5 double , t6 smallint , t7 tinyint , t8 bool , t9 binary(36)
\
uc2 bigint unsigned ,uc3 smallint unsigned , uc4 tinyint unsigned ) tags(t1 timestamp , t2 int , t3 bigint , t4 float , t5 double , t6 smallint , t7 tinyint , t8 bool , t9 binary(36)
\
, t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) "
)
, t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) "
)
for
i
in
range
(
tb_nums
):
for
i
in
range
(
tb_nums
):
tbname
=
f
"sub_
{
stb_name
}
_
{
i
}
"
tbname
=
f
"sub_
{
stb_name
}
_
{
i
}
"
ts
=
self
.
ts
+
i
*
10000
ts
=
self
.
ts
+
i
*
10000
...
@@ -30,7 +30,7 @@ class TDTestCase:
...
@@ -30,7 +30,7 @@ class TDTestCase:
for
null
in
range
(
5
):
for
null
in
range
(
5
):
ts
=
self
.
ts
+
row_nums
*
1000
+
null
*
1000
ts
=
self
.
ts
+
row_nums
*
1000
+
null
*
1000
tdSql
.
execute
(
f
"insert into
{
tbname
}
values(
{
ts
}
, NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL )"
)
tdSql
.
execute
(
f
"insert into
{
tbname
}
values(
{
ts
}
, NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL )"
)
def
basic_query
(
self
):
def
basic_query
(
self
):
tdSql
.
query
(
"select count(*) from stb"
)
tdSql
.
query
(
"select count(*) from stb"
)
tdSql
.
checkData
(
0
,
0
,(
self
.
row_nums
+
5
)
*
self
.
tb_nums
)
tdSql
.
checkData
(
0
,
0
,(
self
.
row_nums
+
5
)
*
self
.
tb_nums
)
...
@@ -44,7 +44,7 @@ class TDTestCase:
...
@@ -44,7 +44,7 @@ class TDTestCase:
tdSql
.
query
(
" select max(t2) from stb group by c1 order by t1 "
)
tdSql
.
query
(
" select max(t2) from stb group by c1 order by t1 "
)
tdSql
.
query
(
" select max(c1) from stb group by tbname order by tbname "
)
tdSql
.
query
(
" select max(c1) from stb group by tbname order by tbname "
)
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkRows
(
self
.
tb_nums
)
# bug need fix
# bug need fix
tdSql
.
query
(
" select max(t2) from stb group by t2 order by t2 "
)
tdSql
.
query
(
" select max(t2) from stb group by t2 order by t2 "
)
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
query
(
" select max(c1) from stb group by c1 order by c1 "
)
tdSql
.
query
(
" select max(c1) from stb group by c1 order by c1 "
)
...
@@ -62,8 +62,8 @@ class TDTestCase:
...
@@ -62,8 +62,8 @@ class TDTestCase:
# bug need fix
# bug need fix
# tdSql.query(" select tbname , max(c1) from sub_stb_1 where c1 is null group by c1 order by c1 desc ")
# tdSql.query(" select tbname , max(c1) from sub_stb_1 where c1 is null group by c1 order by c1 desc ")
# tdSql.checkRows(1)
# tdSql.checkRows(1)
# tdSql.checkData(0,0,"sub_stb_1")
# tdSql.checkData(0,0,"sub_stb_1")
tdSql
.
query
(
"select max(c1) ,c2 ,t2,tbname from stb group by abs(c1) order by abs(c1)"
)
tdSql
.
query
(
"select max(c1) ,c2 ,t2,tbname from stb group by abs(c1) order by abs(c1)"
)
tdSql
.
checkRows
(
self
.
row_nums
+
1
)
tdSql
.
checkRows
(
self
.
row_nums
+
1
)
...
@@ -80,7 +80,7 @@ class TDTestCase:
...
@@ -80,7 +80,7 @@ class TDTestCase:
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
" select max(c1) from stb where abs(c1+t2)=1 partition by tbname "
)
tdSql
.
query
(
" select max(c1) from stb where abs(c1+t2)=1 partition by tbname "
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
" select tbname , max(c1) from stb partition by tbname order by tbname "
)
tdSql
.
query
(
" select tbname , max(c1) from stb partition by tbname order by tbname "
)
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkData
(
0
,
1
,
self
.
row_nums
-
1
)
tdSql
.
checkData
(
0
,
1
,
self
.
row_nums
-
1
)
...
@@ -89,7 +89,7 @@ class TDTestCase:
...
@@ -89,7 +89,7 @@ class TDTestCase:
tdSql
.
query
(
"select tbname , max(t2) from stb partition by t1 order by t1"
)
tdSql
.
query
(
"select tbname , max(t2) from stb partition by t1 order by t1"
)
tdSql
.
query
(
"select tbname , max(t2) from stb partition by t2 order by t2"
)
tdSql
.
query
(
"select tbname , max(t2) from stb partition by t2 order by t2"
)
# # bug need fix
# # bug need fix
tdSql
.
query
(
"select t2 , max(t2) from stb partition by t2 order by t2"
)
tdSql
.
query
(
"select t2 , max(t2) from stb partition by t2 order by t2"
)
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkRows
(
self
.
tb_nums
)
...
@@ -97,7 +97,7 @@ class TDTestCase:
...
@@ -97,7 +97,7 @@ class TDTestCase:
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkData
(
0
,
1
,
self
.
row_nums
-
1
)
tdSql
.
checkData
(
0
,
1
,
self
.
row_nums
-
1
)
tdSql
.
query
(
"select tbname , max(c1) from stb partition by t2 order by t2"
)
tdSql
.
query
(
"select tbname , max(c1) from stb partition by t2 order by t2"
)
tdSql
.
query
(
"select c2, max(c1) from stb partition by c2 order by c2 desc"
)
tdSql
.
query
(
"select c2, max(c1) from stb partition by c2 order by c2 desc"
)
...
@@ -125,10 +125,10 @@ class TDTestCase:
...
@@ -125,10 +125,10 @@ class TDTestCase:
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkData
(
0
,
0
,
self
.
row_nums
)
tdSql
.
checkData
(
0
,
0
,
self
.
row_nums
)
# bug need fix
# bug need fix
tdSql
.
query
(
"select count(c1) , max(t2) ,abs(c1) from stb partition by abs(c1) order by abs(c1)"
)
tdSql
.
query
(
"select count(c1) , max(t2) ,abs(c1) from stb partition by abs(c1) order by abs(c1)"
)
tdSql
.
checkRows
(
self
.
row_nums
+
1
)
tdSql
.
checkRows
(
self
.
row_nums
+
1
)
tdSql
.
query
(
"select max(ceil(c2)) , max(floor(t2)) ,max(floor(c2)) from stb partition by abs(c2) order by abs(c2)"
)
tdSql
.
query
(
"select max(ceil(c2)) , max(floor(t2)) ,max(floor(c2)) from stb partition by abs(c2) order by abs(c2)"
)
tdSql
.
checkRows
(
self
.
row_nums
+
1
)
tdSql
.
checkRows
(
self
.
row_nums
+
1
)
...
@@ -148,15 +148,15 @@ class TDTestCase:
...
@@ -148,15 +148,15 @@ class TDTestCase:
tdSql
.
query
(
" select c1 , sample(c1,2) from stb partition by tbname order by tbname "
)
tdSql
.
query
(
" select c1 , sample(c1,2) from stb partition by tbname order by tbname "
)
tdSql
.
checkRows
(
self
.
tb_nums
*
2
)
tdSql
.
checkRows
(
self
.
tb_nums
*
2
)
# interval
# interval
tdSql
.
query
(
"select max(c1) from stb interval(2s) sliding(1s)"
)
tdSql
.
query
(
"select max(c1) from stb interval(2s) sliding(1s)"
)
# bug need fix
# bug need fix
tdSql
.
query
(
'select max(c1) from stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)'
)
tdSql
.
query
(
'select max(c1) from stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)'
)
tdSql
.
query
(
" select tbname , count(c1) from stb partition by tbname interval(10s) slimit 5 soffset 1 "
)
tdSql
.
query
(
" select tbname , count(c1) from stb partition by tbname interval(10s) slimit 5 soffset 1 "
)
tdSql
.
query
(
"select tbname , max(c1) from stb partition by tbname interval(10s)"
)
tdSql
.
query
(
"select tbname , max(c1) from stb partition by tbname interval(10s)"
)
...
@@ -179,12 +179,12 @@ class TDTestCase:
...
@@ -179,12 +179,12 @@ class TDTestCase:
tdSql
.
query
(
"select c1 , sample(c1,2) from stb partition by c1 order by c1"
)
tdSql
.
query
(
"select c1 , sample(c1,2) from stb partition by c1 order by c1"
)
tdSql
.
checkRows
(
21
)
tdSql
.
checkRows
(
21
)
# bug need fix
# bug need fix
# tdSql.checkData(0,1,None)
# tdSql.checkData(0,1,None)
tdSql
.
query
(
"select c1 , twa(c1) from stb partition by c1 order by c1"
)
tdSql
.
query
(
"select c1 , twa(c1) from stb partition by c1 order by c1"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
0
,
1
,
0.000000000
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
"select c1 , irate(c1) from stb partition by c1 order by c1"
)
tdSql
.
query
(
"select c1 , irate(c1) from stb partition by c1 order by c1"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkRows
(
11
)
...
@@ -192,7 +192,7 @@ class TDTestCase:
...
@@ -192,7 +192,7 @@ class TDTestCase:
tdSql
.
query
(
"select c1 , DERIVATIVE(c1,2,1) from stb partition by c1 order by c1"
)
tdSql
.
query
(
"select c1 , DERIVATIVE(c1,2,1) from stb partition by c1 order by c1"
)
tdSql
.
checkRows
(
72
)
tdSql
.
checkRows
(
72
)
# bug need fix
# bug need fix
# tdSql.checkData(0,1,None)
# tdSql.checkData(0,1,None)
...
@@ -201,15 +201,15 @@ class TDTestCase:
...
@@ -201,15 +201,15 @@ class TDTestCase:
# bug need fix
# bug need fix
# tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 0 ")
# tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 0 ")
# tdSql.checkRows(5)
# tdSql.checkRows(5)
# tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 1 ")
# tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 1 ")
# tdSql.checkRows(5)
# tdSql.checkRows(5)
tdSql
.
query
(
" select tbname , max(c1) from sub_stb_1 partition by tbname interval(10s) sliding(5s) "
)
tdSql
.
query
(
" select tbname , max(c1) from sub_stb_1 partition by tbname interval(10s) sliding(5s) "
)
tdSql
.
query
(
f
'select max(c1) from stb where ts>=
{
self
.
ts
}
and ts <
{
self
.
ts
}
+1000 interval(50s) sliding(30s)'
)
tdSql
.
query
(
f
'select max(c1) from stb where ts>=
{
self
.
ts
}
and ts <
{
self
.
ts
}
+1000 interval(50s) sliding(30s)'
)
tdSql
.
query
(
f
'select tbname , max(c1) from stb where ts>=
{
self
.
ts
}
and ts <
{
self
.
ts
}
+1000 interval(50s) sliding(30s)'
)
tdSql
.
query
(
f
'select tbname , max(c1) from stb where ts>=
{
self
.
ts
}
and ts <
{
self
.
ts
}
+1000 interval(50s) sliding(30s)'
)
...
@@ -219,18 +219,18 @@ class TDTestCase:
...
@@ -219,18 +219,18 @@ class TDTestCase:
self
.
prepare_datas
(
"stb"
,
self
.
tb_nums
,
self
.
row_nums
)
self
.
prepare_datas
(
"stb"
,
self
.
tb_nums
,
self
.
row_nums
)
self
.
basic_query
()
self
.
basic_query
()
# # coverage case for taosd crash about bug fix
# # coverage case for taosd crash about bug fix
tdSql
.
query
(
" select sum(c1) from stb where t2+10 >1 "
)
tdSql
.
query
(
" select sum(c1) from stb where t2+10 >1 "
)
tdSql
.
query
(
" select count(c1),count(t1) from stb where -t2<1 "
)
tdSql
.
query
(
" select count(c1),count(t1) from stb where -t2<1 "
)
tdSql
.
query
(
" select tbname ,max(ceil(c1)) from stb group by tbname "
)
tdSql
.
query
(
" select tbname ,max(ceil(c1)) from stb group by tbname "
)
tdSql
.
query
(
" select avg(abs(c1)) , tbname from stb group by tbname "
)
tdSql
.
query
(
" select avg(abs(c1)) , tbname from stb group by tbname "
)
tdSql
.
query
(
" select t1,c1 from stb where abs(t2+c1)=1 "
)
tdSql
.
query
(
" select t1,c1 from stb where abs(t2+c1)=1 "
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/2-query/twa.py
浏览文件 @
5a0668da
...
@@ -7,7 +7,7 @@ import platform
...
@@ -7,7 +7,7 @@ import platform
import
math
import
math
class
TDTestCase
:
class
TDTestCase
:
updatecfgDict
=
{
'debugFlag'
:
143
,
"cDebugFlag"
:
143
,
"uDebugFlag"
:
143
,
"rpcDebugFlag"
:
143
,
"tmrDebugFlag"
:
143
,
updatecfgDict
=
{
'debugFlag'
:
143
,
"cDebugFlag"
:
143
,
"uDebugFlag"
:
143
,
"rpcDebugFlag"
:
143
,
"tmrDebugFlag"
:
143
,
"jniDebugFlag"
:
143
,
"simDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"vDebugFlag"
:
143
,
"mDebugFlag"
:
143
,
"qDebugFlag"
:
143
,
"jniDebugFlag"
:
143
,
"simDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"vDebugFlag"
:
143
,
"mDebugFlag"
:
143
,
"qDebugFlag"
:
143
,
"wDebugFlag"
:
143
,
"sDebugFlag"
:
143
,
"tsdbDebugFlag"
:
143
,
"tqDebugFlag"
:
143
,
"fsDebugFlag"
:
143
,
"udfDebugFlag"
:
143
,
"wDebugFlag"
:
143
,
"sDebugFlag"
:
143
,
"tsdbDebugFlag"
:
143
,
"tqDebugFlag"
:
143
,
"fsDebugFlag"
:
143
,
"udfDebugFlag"
:
143
,
"maxTablesPerVnode"
:
2
,
"minTablesPerVnode"
:
2
,
"tableIncStepPerVnode"
:
2
}
"maxTablesPerVnode"
:
2
,
"minTablesPerVnode"
:
2
,
"tableIncStepPerVnode"
:
2
}
...
@@ -22,7 +22,7 @@ class TDTestCase:
...
@@ -22,7 +22,7 @@ class TDTestCase:
self
.
time_step
=
1000
self
.
time_step
=
1000
def
prepare_datas_of_distribute
(
self
):
def
prepare_datas_of_distribute
(
self
):
# prepate datas for 20 tables distributed at different vgroups
# prepate datas for 20 tables distributed at different vgroups
tdSql
.
execute
(
"create database if not exists testdb keep 3650 duration 1000 vgroups 5"
)
tdSql
.
execute
(
"create database if not exists testdb keep 3650 duration 1000 vgroups 5"
)
tdSql
.
execute
(
" use testdb "
)
tdSql
.
execute
(
" use testdb "
)
...
@@ -32,16 +32,16 @@ class TDTestCase:
...
@@ -32,16 +32,16 @@ class TDTestCase:
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
'''
'''
)
)
for
i
in
range
(
self
.
tb_nums
):
for
i
in
range
(
self
.
tb_nums
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
ts
=
self
.
ts
ts
=
self
.
ts
for
j
in
range
(
self
.
row_nums
):
for
j
in
range
(
self
.
row_nums
):
ts
+=
j
*
self
.
time_step
ts
+=
j
*
self
.
time_step
tdSql
.
execute
(
tdSql
.
execute
(
f
"insert into ct
{
i
+
1
}
values(
{
ts
}
, 1, 11111, 111, 1, 1.11, 11.11, 2, 'binary
{
j
}
', 'nchar
{
j
}
', now()+
{
1
*
j
}
a )"
f
"insert into ct
{
i
+
1
}
values(
{
ts
}
, 1, 11111, 111, 1, 1.11, 11.11, 2, 'binary
{
j
}
', 'nchar
{
j
}
', now()+
{
1
*
j
}
a )"
)
)
tdSql
.
execute
(
"insert into ct1 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct1 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct1 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct1 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct1 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct1 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
...
@@ -64,7 +64,7 @@ class TDTestCase:
...
@@ -64,7 +64,7 @@ class TDTestCase:
vgroups
=
tdSql
.
queryResult
vgroups
=
tdSql
.
queryResult
vnode_tables
=
{}
vnode_tables
=
{}
for
vgroup_id
in
vgroups
:
for
vgroup_id
in
vgroups
:
vnode_tables
[
vgroup_id
[
0
]]
=
[]
vnode_tables
[
vgroup_id
[
0
]]
=
[]
...
@@ -73,7 +73,7 @@ class TDTestCase:
...
@@ -73,7 +73,7 @@ class TDTestCase:
table_names
=
tdSql
.
queryResult
table_names
=
tdSql
.
queryResult
tablenames
=
[]
tablenames
=
[]
for
table_name
in
table_names
:
for
table_name
in
table_names
:
vnode_tables
[
table_name
[
6
]].
append
(
table_name
[
0
])
vnode_tables
[
table_name
[
6
]].
append
(
table_name
[
0
])
self
.
vnode_disbutes
=
vnode_tables
self
.
vnode_disbutes
=
vnode_tables
count
=
0
count
=
0
...
@@ -103,12 +103,12 @@ class TDTestCase:
...
@@ -103,12 +103,12 @@ class TDTestCase:
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkData
(
0
,
0
,
1.000000000
)
tdSql
.
checkData
(
0
,
0
,
1.000000000
)
# union all
# union all
tdSql
.
query
(
" select twa(c1) from stb1 partition by tbname union all select twa(c1) from stb1 partition by tbname "
)
tdSql
.
query
(
" select twa(c1) from stb1 partition by tbname union all select twa(c1) from stb1 partition by tbname "
)
tdSql
.
checkRows
(
40
)
tdSql
.
checkRows
(
40
)
tdSql
.
checkData
(
0
,
0
,
1.000000000
)
tdSql
.
checkData
(
0
,
0
,
1.000000000
)
# join
# join
tdSql
.
execute
(
" create database if not exists db "
)
tdSql
.
execute
(
" create database if not exists db "
)
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" use db "
)
...
@@ -116,7 +116,7 @@ class TDTestCase:
...
@@ -116,7 +116,7 @@ class TDTestCase:
tdSql
.
execute
(
" create table tb1 using st tags(1) "
)
tdSql
.
execute
(
" create table tb1 using st tags(1) "
)
tdSql
.
execute
(
" create table tb2 using st tags(2) "
)
tdSql
.
execute
(
" create table tb2 using st tags(2) "
)
for
i
in
range
(
10
):
for
i
in
range
(
10
):
ts
=
i
*
10
+
self
.
ts
ts
=
i
*
10
+
self
.
ts
tdSql
.
execute
(
f
" insert into tb1 values(
{
ts
}
,
{
i
}
,
{
i
}
.0)"
)
tdSql
.
execute
(
f
" insert into tb1 values(
{
ts
}
,
{
i
}
,
{
i
}
.0)"
)
...
@@ -127,7 +127,7 @@ class TDTestCase:
...
@@ -127,7 +127,7 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
4.500000000
)
tdSql
.
checkData
(
0
,
0
,
4.500000000
)
tdSql
.
checkData
(
0
,
1
,
4.500000000
)
tdSql
.
checkData
(
0
,
1
,
4.500000000
)
# group by
# group by
tdSql
.
execute
(
" use testdb "
)
tdSql
.
execute
(
" use testdb "
)
# mixup with other functions
# mixup with other functions
...
@@ -141,7 +141,7 @@ class TDTestCase:
...
@@ -141,7 +141,7 @@ class TDTestCase:
self
.
check_distribute_datas
()
self
.
check_distribute_datas
()
self
.
twa_support_types
()
self
.
twa_support_types
()
self
.
distribute_twa_query
()
self
.
distribute_twa_query
()
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录