Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
51756b83
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看板
提交
51756b83
编写于
3月 23, 2022
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-14227: apply ignoreNegative parameter to diff output instead of input
上级
78d86afc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
130 addition
and
109 deletion
+130
-109
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+58
-53
tests/develop-test/2-query/diff_funcs.py
tests/develop-test/2-query/diff_funcs.py
+68
-52
tests/develop-test/2-query/diff_ignore_negative.py
tests/develop-test/2-query/diff_ignore_negative.py
+4
-4
未找到文件。
src/query/src/qAggMain.c
浏览文件 @
51756b83
...
...
@@ -3647,23 +3647,24 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
if
((
pDiffInfo
->
ignoreNegative
)
&&
(
pData
[
i
]
<
0
))
{
continue
;
}
if
(
pDiffInfo
->
valueAssigned
)
{
*
pOutput
=
(
int32_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
);
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
int32_t
diff
=
(
int32_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
);
if
(
diff
>=
0
||
!
pDiffInfo
->
ignoreNegative
)
{
*
pOutput
=
(
int32_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
);
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
}
}
pDiffInfo
->
i64Prev
=
pData
[
i
];
pDiffInfo
->
valueAssigned
=
true
;
notNullElems
++
;
}
break
;
};
case
TSDB_DATA_TYPE_BIGINT
:
{
int64_t
*
pData
=
(
int64_t
*
)
data
;
int64_t
*
pOutput
=
(
int64_t
*
)
pCtx
->
pOutput
;
...
...
@@ -3672,23 +3673,24 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
if
((
pDiffInfo
->
ignoreNegative
)
&&
(
pData
[
i
]
<
0
))
{
continue
;
}
if
(
pDiffInfo
->
valueAssigned
)
{
*
pOutput
=
pData
[
i
]
-
pDiffInfo
->
i64Prev
;
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
int64_t
diff
=
pData
[
i
]
-
pDiffInfo
->
i64Prev
;
if
(
diff
>=
0
||
!
pDiffInfo
->
ignoreNegative
)
{
*
pOutput
=
pData
[
i
]
-
pDiffInfo
->
i64Prev
;
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
}
}
pDiffInfo
->
i64Prev
=
pData
[
i
];
pDiffInfo
->
valueAssigned
=
true
;
notNullElems
++
;
}
break
;
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
double
*
pData
=
(
double
*
)
data
;
double
*
pOutput
=
(
double
*
)
pCtx
->
pOutput
;
...
...
@@ -3697,23 +3699,24 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
if
((
pDiffInfo
->
ignoreNegative
)
&&
(
pData
[
i
]
<
0
))
{
continue
;
}
if
(
pDiffInfo
->
valueAssigned
)
{
// initial value is not set yet
SET_DOUBLE_VAL
(
pOutput
,
pData
[
i
]
-
pDiffInfo
->
d64Prev
);
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
if
(
pDiffInfo
->
valueAssigned
)
{
double
diff
=
pData
[
i
]
-
pDiffInfo
->
d64Prev
;
if
(
diff
>=
0
||
!
pDiffInfo
->
ignoreNegative
)
{
SET_DOUBLE_VAL
(
pOutput
,
pData
[
i
]
-
pDiffInfo
->
d64Prev
);
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
}
}
pDiffInfo
->
d64Prev
=
pData
[
i
];
pDiffInfo
->
valueAssigned
=
true
;
notNullElems
++
;
}
break
;
}
case
TSDB_DATA_TYPE_FLOAT
:
{
float
*
pData
=
(
float
*
)
data
;
float
*
pOutput
=
(
float
*
)
pCtx
->
pOutput
;
...
...
@@ -3722,23 +3725,24 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
if
((
pDiffInfo
->
ignoreNegative
)
&&
(
pData
[
i
]
<
0
))
{
continue
;
}
if
(
pDiffInfo
->
valueAssigned
)
{
// initial value is not set yet
*
pOutput
=
(
float
)(
pData
[
i
]
-
pDiffInfo
->
d64Prev
);
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
if
(
pDiffInfo
->
valueAssigned
)
{
float
diff
=
(
float
)(
pData
[
i
]
-
pDiffInfo
->
d64Prev
);
if
(
diff
>=
0
||
!
pDiffInfo
->
ignoreNegative
)
{
*
pOutput
=
(
float
)(
pData
[
i
]
-
pDiffInfo
->
d64Prev
);
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
}
}
pDiffInfo
->
d64Prev
=
pData
[
i
];
pDiffInfo
->
valueAssigned
=
true
;
notNullElems
++
;
}
break
;
}
case
TSDB_DATA_TYPE_SMALLINT
:
{
int16_t
*
pData
=
(
int16_t
*
)
data
;
int16_t
*
pOutput
=
(
int16_t
*
)
pCtx
->
pOutput
;
...
...
@@ -3747,20 +3751,20 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
if
((
pDiffInfo
->
ignoreNegative
)
&&
(
pData
[
i
]
<
0
))
{
continue
;
}
if
(
pDiffInfo
->
valueAssigned
)
{
// initial value is not set yet
*
pOutput
=
(
int16_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
);
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
if
(
pDiffInfo
->
valueAssigned
)
{
int16_t
diff
=
(
int16_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
);
if
(
diff
>=
0
||
!
pDiffInfo
->
ignoreNegative
)
{
*
pOutput
=
(
int16_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
);
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
}
}
pDiffInfo
->
i64Prev
=
pData
[
i
];
pDiffInfo
->
valueAssigned
=
true
;
notNullElems
++
;
}
break
;
}
...
...
@@ -3773,23 +3777,24 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
hasNull
&&
isNull
((
char
*
)
&
pData
[
i
],
pCtx
->
inputType
))
{
continue
;
}
if
((
pDiffInfo
->
ignoreNegative
)
&&
(
pData
[
i
]
<
0
))
{
continue
;
}
if
(
pDiffInfo
->
valueAssigned
)
{
// initial value is not set yet
*
pOutput
=
(
int8_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
);
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
if
(
pDiffInfo
->
valueAssigned
)
{
int8_t
diff
=
(
int8_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
);
if
(
diff
>=
0
||
!
pDiffInfo
->
ignoreNegative
)
{
*
pOutput
=
(
int8_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
);
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
}
}
pDiffInfo
->
i64Prev
=
pData
[
i
];
pDiffInfo
->
valueAssigned
=
true
;
notNullElems
++
;
}
break
;
}
default:
qError
(
"error input type"
);
}
...
...
@@ -3808,7 +3813,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
aAggs
[
TSDB_FUNC_TAGPRJ
].
xFunction
(
tagCtx
);
}
}
int32_t
forwardStep
=
(
isFirstBlock
)
?
notNullElems
-
1
:
notNullElems
;
int32_t
forwardStep
=
(
isFirstBlock
)
?
notNullElems
:
notNullElems
;
GET_RES_INFO
(
pCtx
)
->
numOfRes
+=
forwardStep
;
}
...
...
tests/develop-test/2-query/diff_funcs.py
浏览文件 @
51756b83
...
...
@@ -144,13 +144,15 @@ class TDTestCase:
tdSql
.
checkData
(
2
,
1
,
1.79769e+308
)
tdSql
.
query
(
'select diff(c4,1) from tb1;'
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
4
))
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
checkData
(
2
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
2
,
1
,
2147483643
)
tdSql
.
checkData
(
3
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
3
,
1
,
2
)
tdSql
.
query
(
'select diff(c4) from tb1;'
)
tdSql
.
checkRows
(
4
)
...
...
@@ -168,13 +170,15 @@ class TDTestCase:
tdSql
.
error
(
'select diff(13) from tb1;'
)
tdSql
.
query
(
'select diff(c4,1) from tb1;'
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
4
))
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
checkData
(
2
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
2
,
1
,
2147483643
)
tdSql
.
checkData
(
3
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
3
,
1
,
2
)
tdSql
.
query
(
'select diff(c2) from tb1;'
)
tdSql
.
checkRows
(
4
)
...
...
@@ -277,7 +281,7 @@ class TDTestCase:
tdSql
.
error
(
'select diff(c4,1) from stb1 group by c1;'
)
tdSql
.
query
(
'select diff(c4,1) from stb1 group by tbname;'
)
tdSql
.
checkRows
(
9
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
0
,
2
,
'tb1'
)
...
...
@@ -287,24 +291,27 @@ class TDTestCase:
tdSql
.
checkData
(
2
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
2
,
1
,
2147483643
)
tdSql
.
checkData
(
2
,
2
,
'tb1'
)
tdSql
.
checkData
(
3
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
1
))
tdSql
.
checkData
(
3
,
1
,
1
)
tdSql
.
checkData
(
3
,
2
,
'tb
2
'
)
tdSql
.
checkData
(
4
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
4
,
1
,
0
)
tdSql
.
checkData
(
3
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
3
,
1
,
2
)
tdSql
.
checkData
(
3
,
2
,
'tb
1
'
)
tdSql
.
checkData
(
4
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
1
))
tdSql
.
checkData
(
4
,
1
,
1
)
tdSql
.
checkData
(
4
,
2
,
'tb2'
)
tdSql
.
checkData
(
5
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
3
))
tdSql
.
checkData
(
5
,
1
,
2
)
tdSql
.
checkData
(
5
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
5
,
1
,
0
)
tdSql
.
checkData
(
5
,
2
,
'tb2'
)
tdSql
.
checkData
(
6
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
4
))
tdSql
.
checkData
(
6
,
1
,
1
)
tdSql
.
checkData
(
6
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
3
))
tdSql
.
checkData
(
6
,
1
,
2
)
tdSql
.
checkData
(
6
,
2
,
'tb2'
)
tdSql
.
checkData
(
7
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
7
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
4
))
tdSql
.
checkData
(
7
,
1
,
1
)
tdSql
.
checkData
(
7
,
2
,
'tb2'
)
tdSql
.
checkData
(
8
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
8
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
8
,
1
,
1
)
tdSql
.
checkData
(
8
,
2
,
'tb2'
)
tdSql
.
checkData
(
9
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
9
,
1
,
1
)
tdSql
.
checkData
(
9
,
2
,
'tb2'
)
tdSql
.
error
(
'select diff(c4,1) from tb1 order by c2;'
)
...
...
@@ -365,7 +372,7 @@ class TDTestCase:
tdSql
.
error
(
'select diff(c4,1),c1,c2 from tb1;'
)
tdSql
.
query
(
'select diff(c4,1),t1,ts,tbname,_C0,_c0 from tb1;'
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
0
,
2
,
1
)
...
...
@@ -387,17 +394,26 @@ class TDTestCase:
tdSql
.
checkData
(
2
,
4
,
'tb1'
)
tdSql
.
checkData
(
2
,
5
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
2
,
6
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
3
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
3
,
1
,
2
)
tdSql
.
checkData
(
3
,
2
,
1
)
tdSql
.
checkData
(
3
,
3
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
3
,
4
,
'tb1'
)
tdSql
.
checkData
(
3
,
5
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
3
,
6
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
error
(
'select diff(c4,1),floor(c3) from tb1;'
)
tdSql
.
error
(
'select diff(c4,1),diff(c4,1) from tb1;'
)
tdSql
.
query
(
'select diff(c4,1) from tb1 where c2 is not null and c3 is not null;'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
4
))
tdSql
.
checkData
(
0
,
1
,
3
)
tdSql
.
checkData
(
1
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
1
,
1
,
2147483643
)
tdSql
.
checkData
(
2
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
2
,
1
,
2
)
tdSql
.
query
(
'select diff(c2) from tb1 order by ts desc;'
)
tdSql
.
checkRows
(
4
)
...
...
@@ -411,18 +427,10 @@ class TDTestCase:
tdSql
.
checkData
(
3
,
1
,
-
1
)
tdSql
.
query
(
'select diff(c4,1) from tb1 order by ts desc;'
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
4
))
tdSql
.
checkData
(
0
,
1
,
-
2147483643
)
tdSql
.
checkData
(
1
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
1
,
1
,
-
2
)
tdSql
.
checkData
(
2
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
))
tdSql
.
checkData
(
2
,
1
,
-
1
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
'select diff(c4,1) from tb1 order by ts desc limit 3 offset 2;'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
))
tdSql
.
checkData
(
0
,
1
,
-
1
)
tdSql
.
checkRows
(
0
)
tdSql
.
error
(
'select diff(c2) from stb1;'
)
...
...
@@ -674,13 +682,15 @@ class TDTestCase:
tdSql
.
checkData
(
2
,
1
,
1.79769e+308
)
tdSql
.
query
(
'select diff(c4,1) from tb1;'
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
4
))
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
checkData
(
2
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
2
,
1
,
2147483643
)
tdSql
.
checkData
(
3
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
3
,
1
,
2
)
tdSql
.
query
(
'select diff(c4) from tb1;'
)
tdSql
.
checkRows
(
4
)
...
...
@@ -698,13 +708,15 @@ class TDTestCase:
tdSql
.
error
(
'select diff(13) from tb1;'
)
tdSql
.
query
(
'select diff(c4,1) from tb1;'
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
4
))
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
checkData
(
2
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
2
,
1
,
2147483643
)
tdSql
.
checkData
(
3
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
3
,
1
,
2
)
tdSql
.
query
(
'select diff(c2) from tb1;'
)
tdSql
.
checkRows
(
4
)
...
...
@@ -807,7 +819,7 @@ class TDTestCase:
tdSql
.
error
(
'select diff(c4,1) from stb1 group by c1;'
)
tdSql
.
query
(
'select diff(c4,1) from stb1 group by tbname;'
)
tdSql
.
checkRows
(
9
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
0
,
2
,
'tb1'
)
...
...
@@ -817,24 +829,27 @@ class TDTestCase:
tdSql
.
checkData
(
2
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
2
,
1
,
2147483643
)
tdSql
.
checkData
(
2
,
2
,
'tb1'
)
tdSql
.
checkData
(
3
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
1
))
tdSql
.
checkData
(
3
,
1
,
1
)
tdSql
.
checkData
(
3
,
2
,
'tb
2
'
)
tdSql
.
checkData
(
4
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
4
,
1
,
0
)
tdSql
.
checkData
(
3
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
3
,
1
,
2
)
tdSql
.
checkData
(
3
,
2
,
'tb
1
'
)
tdSql
.
checkData
(
4
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
1
))
tdSql
.
checkData
(
4
,
1
,
1
)
tdSql
.
checkData
(
4
,
2
,
'tb2'
)
tdSql
.
checkData
(
5
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
3
))
tdSql
.
checkData
(
5
,
1
,
2
)
tdSql
.
checkData
(
5
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
5
,
1
,
0
)
tdSql
.
checkData
(
5
,
2
,
'tb2'
)
tdSql
.
checkData
(
6
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
4
))
tdSql
.
checkData
(
6
,
1
,
1
)
tdSql
.
checkData
(
6
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
3
))
tdSql
.
checkData
(
6
,
1
,
2
)
tdSql
.
checkData
(
6
,
2
,
'tb2'
)
tdSql
.
checkData
(
7
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
7
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
4
))
tdSql
.
checkData
(
7
,
1
,
1
)
tdSql
.
checkData
(
7
,
2
,
'tb2'
)
tdSql
.
checkData
(
8
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
8
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
8
,
1
,
1
)
tdSql
.
checkData
(
8
,
2
,
'tb2'
)
tdSql
.
checkData
(
9
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
9
,
1
,
1
)
tdSql
.
checkData
(
9
,
2
,
'tb2'
)
tdSql
.
error
(
'select diff(c4,1) from tb1 order by c2;'
)
...
...
@@ -895,7 +910,7 @@ class TDTestCase:
tdSql
.
error
(
'select diff(c4,1),c1,c2 from tb1;'
)
tdSql
.
query
(
'select diff(c4,1),t1,ts,tbname,_C0,_c0 from tb1;'
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
0
,
2
,
1
)
...
...
@@ -917,17 +932,26 @@ class TDTestCase:
tdSql
.
checkData
(
2
,
4
,
'tb1'
)
tdSql
.
checkData
(
2
,
5
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
2
,
6
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
3
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
3
,
1
,
2
)
tdSql
.
checkData
(
3
,
2
,
1
)
tdSql
.
checkData
(
3
,
3
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
3
,
4
,
'tb1'
)
tdSql
.
checkData
(
3
,
5
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
3
,
6
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
error
(
'select diff(c4,1),floor(c3) from tb1;'
)
tdSql
.
error
(
'select diff(c4,1),diff(c4,1) from tb1;'
)
tdSql
.
query
(
'select diff(c4,1) from tb1 where c2 is not null and c3 is not null;'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
4
))
tdSql
.
checkData
(
0
,
1
,
3
)
tdSql
.
checkData
(
1
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
5
))
tdSql
.
checkData
(
1
,
1
,
2147483643
)
tdSql
.
checkData
(
2
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
6
))
tdSql
.
checkData
(
2
,
1
,
2
)
tdSql
.
query
(
'select diff(c2) from tb1 order by ts desc;'
)
tdSql
.
checkRows
(
4
)
...
...
@@ -941,18 +965,10 @@ class TDTestCase:
tdSql
.
checkData
(
3
,
1
,
-
1
)
tdSql
.
query
(
'select diff(c4,1) from tb1 order by ts desc;'
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
4
))
tdSql
.
checkData
(
0
,
1
,
-
2147483643
)
tdSql
.
checkData
(
1
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
,
2
))
tdSql
.
checkData
(
1
,
1
,
-
2
)
tdSql
.
checkData
(
2
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
))
tdSql
.
checkData
(
2
,
1
,
-
1
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
'select diff(c4,1) from tb1 order by ts desc limit 3 offset 2;'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
datetime
.
datetime
(
2021
,
11
,
11
,
9
,
0
))
tdSql
.
checkData
(
0
,
1
,
-
1
)
tdSql
.
checkRows
(
0
)
tdSql
.
error
(
'select diff(c2) from stb1;'
)
...
...
tests/develop-test/2-query/diff_ignore_negative.py
浏览文件 @
51756b83
...
...
@@ -78,13 +78,13 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
0
,
2
,
'ct1'
)
tdSql
.
checkData
(
1
,
0
,
datetime
.
datetime
(
2022
,
1
,
20
,
15
,
10
,
22
,
4000
))
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
checkData
(
1
,
1
,
8
)
tdSql
.
checkData
(
1
,
2
,
'ct1'
)
tdSql
.
checkData
(
2
,
0
,
datetime
.
datetime
(
2022
,
1
,
20
,
15
,
10
,
22
,
2000
))
tdSql
.
checkData
(
2
,
1
,
11
)
tdSql
.
checkData
(
2
,
2
,
'ct2'
)
tdSql
.
checkData
(
3
,
0
,
datetime
.
datetime
(
2022
,
1
,
20
,
15
,
10
,
22
,
4000
))
tdSql
.
checkData
(
3
,
1
,
22
)
tdSql
.
checkData
(
3
,
1
,
88
)
tdSql
.
checkData
(
3
,
2
,
'ct2'
)
tdSql
.
query
(
'select diff(c2) from st group by tbname'
)
...
...
@@ -135,13 +135,13 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
1
,
2.0
)
tdSql
.
checkData
(
0
,
2
,
'ct1'
)
tdSql
.
checkData
(
1
,
0
,
datetime
.
datetime
(
2022
,
1
,
20
,
15
,
10
,
22
,
4000
))
tdSql
.
checkData
(
1
,
1
,
4.0
)
tdSql
.
checkData
(
1
,
1
,
1
4.0
)
tdSql
.
checkData
(
1
,
2
,
'ct1'
)
tdSql
.
checkData
(
2
,
0
,
datetime
.
datetime
(
2022
,
1
,
20
,
15
,
10
,
22
,
2000
))
tdSql
.
checkData
(
2
,
1
,
22.0
)
tdSql
.
checkData
(
2
,
2
,
'ct2'
)
tdSql
.
checkData
(
3
,
0
,
datetime
.
datetime
(
2022
,
1
,
20
,
15
,
10
,
22
,
4000
))
tdSql
.
checkData
(
3
,
1
,
4
4.0
)
tdSql
.
checkData
(
3
,
1
,
15
4.0
)
tdSql
.
checkData
(
3
,
2
,
'ct2'
)
tdSql
.
execute
(
'drop database diffneg'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录