Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
0d7a58f0
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0d7a58f0
编写于
6月 02, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-255] add test cases, fix compiler error.
上级
41befca4
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
127 addition
and
20 deletion
+127
-20
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+9
-20
tests/script/general/parser/function.sim
tests/script/general/parser/function.sim
+118
-0
未找到文件。
src/query/src/qAggMain.c
浏览文件 @
0d7a58f0
...
...
@@ -153,9 +153,9 @@ typedef struct STSCompInfo {
typedef
struct
SRateInfo
{
int64_t
CorrectionValue
;
int64_t
firstValue
;
double
firstValue
;
TSKEY
firstKey
;
int64_t
lastValue
;
double
lastValue
;
TSKEY
lastKey
;
int8_t
hasResult
;
// flag to denote has value
bool
isIRate
;
// true for IRate functions, false for Rate functions
...
...
@@ -4484,8 +4484,7 @@ static double do_calc_rate(const SRateInfo* pRateInfo, int64_t tickPerSec) {
return
0
;
}
int64_t
diff
=
0
;
double
diff
=
0
;
if
(
pRateInfo
->
isIRate
)
{
// If the previous value of the last is greater than the last value, only keep the last point instead of the delta
// value between two values.
...
...
@@ -4551,8 +4550,6 @@ static void rate_function(SQLFunctionCtx *pCtx) {
if
((
INT64_MIN
==
pRateInfo
->
firstValue
)
||
(
INT64_MIN
==
pRateInfo
->
firstKey
))
{
pRateInfo
->
firstValue
=
v
;
pRateInfo
->
firstKey
=
primaryKey
[
i
];
qDebug
(
"firstValue:%"
PRId64
" firstKey:%"
PRId64
,
pRateInfo
->
firstValue
,
pRateInfo
->
firstKey
);
}
if
(
INT64_MIN
==
pRateInfo
->
lastValue
)
{
...
...
@@ -4564,7 +4561,6 @@ static void rate_function(SQLFunctionCtx *pCtx) {
pRateInfo
->
lastValue
=
v
;
pRateInfo
->
lastKey
=
primaryKey
[
i
];
qDebug
(
"lastValue:%"
PRId64
" lastKey:%"
PRId64
,
pRateInfo
->
lastValue
,
pRateInfo
->
lastKey
);
}
if
(
!
pCtx
->
hasNull
)
{
...
...
@@ -4612,8 +4608,6 @@ static void rate_function_f(SQLFunctionCtx *pCtx, int32_t index) {
pRateInfo
->
lastValue
=
v
;
pRateInfo
->
lastKey
=
primaryKey
[
index
];
qDebug
(
"====%p rate_function_f() index:%d lastValue:%"
PRId64
" lastKey:%"
PRId64
" CorrectionValue:%"
PRId64
,
pCtx
,
index
,
pRateInfo
->
lastValue
,
pRateInfo
->
lastKey
,
pRateInfo
->
CorrectionValue
);
SET_VAL
(
pCtx
,
1
,
1
);
// set has result flag
...
...
@@ -4632,10 +4626,6 @@ static void rate_func_copy(SQLFunctionCtx *pCtx) {
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
memcpy
(
GET_ROWCELL_INTERBUF
(
pResInfo
),
pCtx
->
pInput
,
(
size_t
)
pCtx
->
inputBytes
);
pResInfo
->
hasResult
=
((
SRateInfo
*
)
pCtx
->
pInput
)
->
hasResult
;
SRateInfo
*
pRateInfo
=
(
SRateInfo
*
)
pCtx
->
pInput
;
qDebug
(
"%p rate_func_merge() firstKey:%"
PRId64
" lastKey:%"
PRId64
" firstValue:%"
PRId64
" lastValue:%"
PRId64
" CorrectionValue:%"
PRId64
" hasResult:%d"
,
pCtx
,
pRateInfo
->
firstKey
,
pRateInfo
->
lastKey
,
pRateInfo
->
firstValue
,
pRateInfo
->
lastValue
,
pRateInfo
->
CorrectionValue
,
pRateInfo
->
hasResult
);
}
static
void
rate_finalizer
(
SQLFunctionCtx
*
pCtx
)
{
...
...
@@ -4671,8 +4661,8 @@ static void irate_function(SQLFunctionCtx *pCtx) {
notNullElems
++
;
int64_t
v
=
0
;
GET_TYPED_DATA
(
v
,
int64_t
,
pCtx
->
inputType
,
pData
);
double
v
=
0
;
GET_TYPED_DATA
(
v
,
double
,
pCtx
->
inputType
,
pData
);
if
((
INT64_MIN
==
pRateInfo
->
lastKey
)
||
primaryKey
[
i
]
>
pRateInfo
->
lastKey
)
{
pRateInfo
->
lastValue
=
v
;
...
...
@@ -4720,8 +4710,7 @@ static void irate_function_f(SQLFunctionCtx *pCtx, int32_t index) {
pRateInfo
->
lastValue
=
v
;
pRateInfo
->
lastKey
=
primaryKey
[
index
];
qDebug
(
"====%p irate_function_f() index:%d lastValue:%"
PRId64
" lastKey:%"
PRId64
" firstValue:%"
PRId64
" firstKey:%"
PRId64
,
pCtx
,
index
,
pRateInfo
->
lastValue
,
pRateInfo
->
lastKey
,
pRateInfo
->
firstValue
,
pRateInfo
->
firstKey
);
// qDebug("====%p irate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->firstValue , pRateInfo->firstKey);
SET_VAL
(
pCtx
,
1
,
1
);
// set has result flag
...
...
@@ -4899,10 +4888,10 @@ void blockinfo_func_finalizer(SQLFunctionCtx* pCtx) {
int32_t
functionCompatList
[]
=
{
// count, sum, avg, min, max, stddev, percentile, apercentile, first, last
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
// last_row,top, bottom, spread, twa, leastsqr, ts, ts_dummy, tag_dummy, ts_
z
// last_row,top, bottom, spread, twa, leastsqr, ts, ts_dummy, tag_dummy, ts_
comp
4
,
-
1
,
-
1
,
1
,
1
,
1
,
1
,
1
,
1
,
-
1
,
// tag, colprj, tagprj, arithmetic, diff, first_dist, last_dist, interp rate irate
1
,
1
,
1
,
1
,
-
1
,
1
,
1
,
5
,
1
,
1
,
// tag, colprj, tagprj, arithmetic, diff, first_dist, last_dist,
stddev_dst,
interp rate irate
1
,
1
,
1
,
1
,
-
1
,
1
,
1
,
1
,
5
,
1
,
1
,
// tid_tag, blk_info
6
,
7
};
...
...
tests/script/general/parser/function.sim
浏览文件 @
0d7a58f0
...
...
@@ -814,3 +814,121 @@ if $data00 != 1 then
endi
print ====================> TODO stddev + normal column filter
print ====================> irate
sql select irate(k) from t1
if $rows != 1 then
return -1
endi
if $data00 != 0.000027778 then
return -1
endi
sql select irate(k) from t1 where ts>='2015-8-18 00:30:00.000'
if $rows != 1 then
return -1
endi
if $data00 != 0.000000000 then
print expect 0.000000000, actual $data00
return -1
endi
sql select irate(k) from t1 where ts>='2015-8-18 00:06:00.000' and ts<='2015-8-18 00:12:000';
if $rows != 1 then
return -1
endi
if $data00 != 0.005633334 then
return -1
endi
sql select irate(k) from t1 interval(10a)
if $rows != 6 then
return -1
endi
if $data01 != 0.000000000 then
return -1
endi
if $data11 != 0.000000000 then
return -1
endi
if $data51 != 0.000000000 then
return -1
endi
sql select count(*),irate(k) from t1 interval(10m)
if $rows != 4 then
return -1
endi
if $data00 != @15-08-18 00:00:00.000@ then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data02 != 0.000144445 then
return -1
endi
if $data10 != @15-08-18 00:10:00.000@ then
return -1
endi
if $data11 != 2 then
return -1
endi
if $data12 != 0.000272222 then
return -1
endi
if $data20 != @15-08-18 00:20:00.000@ then
return -1
endi
if $data21 != 1 then
return -1
endi
if $data22 != 0.000000000 then
return -1
endi
if $data30 != @15-08-18 00:30:00.000@ then
return -1
endi
if $data31 != 1 then
return -1
endi
if $data32 != 0.000000000 then
return -1
endi
sql select count(*),irate(k) from t1 interval(10m) order by ts desc
if $rows != 4 then
return -1
endi
if $data30 != @15-08-18 00:00:00.000@ then
return -1
endi
if $data31 != 2 then
return -1
endi
if $data32 != 0.000144445 then
return -1
endi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录