Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ddce7da2
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看板
未验证
提交
ddce7da2
编写于
6月 17, 2022
作者:
M
Minglei Jin
提交者:
GitHub
6月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13903 from taosdata/fix/TS-1612
enh: optimize diff_function and remove assert
上级
16edfadd
ec5135c9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
18 deletion
+28
-18
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+8
-17
tests/pytest/functions/data.tar.gz
tests/pytest/functions/data.tar.gz
+0
-0
tests/pytest/functions/function_diff.py
tests/pytest/functions/function_diff.py
+20
-1
未找到文件。
src/query/src/qAggMain.c
浏览文件 @
ddce7da2
...
...
@@ -3645,7 +3645,6 @@ static void diff_function(SQLFunctionCtx *pCtx) {
SDiffFuncInfo
*
pDiffInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
void
*
data
=
GET_INPUT_DATA_LIST
(
pCtx
);
bool
isFirstBlock
=
(
pDiffInfo
->
valueAssigned
==
false
);
int32_t
notNullElems
=
0
;
...
...
@@ -3668,7 +3667,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pDiffInfo
->
valueAssigned
)
{
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
*
pOutput
=
diff
;
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
...
...
@@ -3694,7 +3693,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pDiffInfo
->
valueAssigned
)
{
int64_t
diff
=
pData
[
i
]
-
pDiffInfo
->
i64Prev
;
if
(
diff
>=
0
||
!
pDiffInfo
->
ignoreNegative
)
{
*
pOutput
=
pData
[
i
]
-
pDiffInfo
->
i64Prev
;
// direct previous may be null
*
pOutput
=
diff
;
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
...
...
@@ -3720,7 +3719,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
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
SET_DOUBLE_VAL
(
pOutput
,
diff
);
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
...
...
@@ -3746,7 +3745,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pDiffInfo
->
valueAssigned
)
{
float
diff
=
(
float
)(
pData
[
i
]
-
pDiffInfo
->
d64Prev
);
if
(
diff
>=
0
||
!
pDiffInfo
->
ignoreNegative
)
{
*
pOutput
=
(
float
)(
pData
[
i
]
-
pDiffInfo
->
d64Prev
)
;
*
pOutput
=
diff
;
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
...
...
@@ -3772,7 +3771,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pDiffInfo
->
valueAssigned
)
{
int16_t
diff
=
(
int16_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
);
if
(
diff
>=
0
||
!
pDiffInfo
->
ignoreNegative
)
{
*
pOutput
=
(
int16_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
)
;
*
pOutput
=
diff
;
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
...
...
@@ -3798,7 +3797,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pDiffInfo
->
valueAssigned
)
{
int8_t
diff
=
(
int8_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
);
if
(
diff
>=
0
||
!
pDiffInfo
->
ignoreNegative
)
{
*
pOutput
=
(
int8_t
)(
pData
[
i
]
-
pDiffInfo
->
i64Prev
)
;
*
pOutput
=
diff
;
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
pOutput
+=
1
;
pTimestamp
+=
1
;
...
...
@@ -3816,23 +3815,15 @@ static void diff_function(SQLFunctionCtx *pCtx) {
qError
(
"error input type"
);
}
// initial value is not set yet
if
(
!
pDiffInfo
->
valueAssigned
||
notNullElems
<=
0
)
{
/*
* 1. current block and blocks before are full of null
* 2. current block may be null value
*/
assert
(
pCtx
->
hasNull
);
}
else
{
if
(
notNullElems
>
0
)
{
for
(
int
t
=
0
;
t
<
pCtx
->
tagInfo
.
numOfTagCols
;
++
t
)
{
SQLFunctionCtx
*
tagCtx
=
pCtx
->
tagInfo
.
pTagCtxList
[
t
];
if
(
tagCtx
->
functionId
==
TSDB_FUNC_TAG_DUMMY
)
{
aAggs
[
TSDB_FUNC_TAGPRJ
].
xFunction
(
tagCtx
);
}
}
int32_t
forwardStep
=
(
isFirstBlock
)
?
notNullElems
:
notNullElems
;
GET_RES_INFO
(
pCtx
)
->
numOfRes
+=
forwardStep
;
GET_RES_INFO
(
pCtx
)
->
numOfRes
+=
notNullElems
;
}
}
...
...
tests/pytest/functions/data.tar.gz
0 → 100644
浏览文件 @
ddce7da2
文件已添加
tests/pytest/functions/function_diff.py
浏览文件 @
ddce7da2
...
...
@@ -16,6 +16,7 @@ import taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.dnodes
import
*
import
numpy
as
np
...
...
@@ -156,7 +157,25 @@ class TDTestCase:
tdSql
.
error
(
"select diff(col) from st group by dev"
)
tdSql
.
error
(
"select diff(col) from st group by col"
)
# TS-1612
os
.
system
(
"tar -zxf %s/functions/data.tar.gz"
%
os
.
getcwd
())
tdSql
.
execute
(
"create database radb"
)
tdSql
.
execute
(
"use radb"
)
tdSql
.
execute
(
"CREATE TABLE `vehicle_automode` (`time` TIMESTAMP,`auto_ctl_odom` INT) TAGS (`mac_address` BINARY(30))"
)
tdSql
.
execute
(
"CREATE TABLE `va_00545a230327` USING `vehicle_automode` TAGS ('00545a230327')"
)
tdSql
.
execute
(
"insert into va_00545a230327 file 'data/va_00545a230327.csv' "
)
tdSql
.
query
(
"select * from vehicle_automode"
)
rows
=
tdSql
.
queryRows
tdSql
.
query
(
"select diff(auto_ctl_odom,1) as aco from radb.vehicle_automode GROUP BY tbname"
)
tdSql
.
checkRows
(
rows
-
1
)
os
.
system
(
"rm -rf data"
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
tdSql
.
query
(
"select diff(auto_ctl_odom,1) as aco from radb.vehicle_automode GROUP BY tbname"
)
tdSql
.
checkRows
(
rows
-
1
)
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录