Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
129c9251
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看板
提交
129c9251
编写于
7月 01, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: csum/diff/mavg support subquery
上级
e235c983
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
29 deletion
+14
-29
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+2
-2
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+12
-27
未找到文件。
source/libs/function/src/builtins.c
浏览文件 @
129c9251
...
...
@@ -1944,7 +1944,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.
name
=
"irate"
,
.
type
=
FUNCTION_TYPE_IRATE
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_TIMELINE_FUNC
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_IMPLICIT_TS_FUNC
,
.
translateFunc
=
translateIrate
,
.
getEnvFunc
=
getIrateFuncEnv
,
.
initFunc
=
irateFuncSetup
,
...
...
@@ -2151,7 +2151,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.
name
=
"stateduration"
,
.
type
=
FUNCTION_TYPE_STATE_DURATION
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
|
FUNC_MGT_FORBID_WINDOW_FUNC
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_
IMPLICIT_TS_FUNC
|
FUNC_MGT_
FORBID_STREAM_FUNC
|
FUNC_MGT_FORBID_WINDOW_FUNC
,
.
translateFunc
=
translateStateDuration
,
.
getEnvFunc
=
getStateFuncEnv
,
.
initFunc
=
functionSetup
,
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
129c9251
...
...
@@ -80,7 +80,7 @@ typedef struct STopBotRes {
typedef
struct
SFirstLastRes
{
bool
hasResult
;
bool
isNull
;
//used for last_row function only
bool
isNull
;
//
used for last_row function only
int32_t
bytes
;
char
buf
[];
}
SFirstLastRes
;
...
...
@@ -2802,7 +2802,7 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
}
*
(
TSKEY
*
)(
pInfo
->
buf
)
=
cts
;
numOfElems
++
;
//handle selectivity
//
handle selectivity
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
STuplePos
*
pTuplePos
=
(
STuplePos
*
)(
pInfo
->
buf
+
bytes
+
sizeof
(
TSKEY
));
if
(
!
pInfo
->
hasResult
)
{
...
...
@@ -2812,7 +2812,7 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
}
}
pInfo
->
hasResult
=
true
;
//DO_UPDATE_TAG_COLUMNS(pCtx, ts);
//
DO_UPDATE_TAG_COLUMNS(pCtx, ts);
pResInfo
->
numOfRes
=
1
;
}
break
;
...
...
@@ -2834,7 +2834,7 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
}
*
(
TSKEY
*
)(
pInfo
->
buf
)
=
cts
;
numOfElems
++
;
//handle selectivity
//
handle selectivity
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
STuplePos
*
pTuplePos
=
(
STuplePos
*
)(
pInfo
->
buf
+
bytes
+
sizeof
(
TSKEY
));
if
(
!
pInfo
->
hasResult
)
{
...
...
@@ -2845,7 +2845,7 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
}
pInfo
->
hasResult
=
true
;
pResInfo
->
numOfRes
=
1
;
//DO_UPDATE_TAG_COLUMNS(pCtx, ts);
//
DO_UPDATE_TAG_COLUMNS(pCtx, ts);
}
break
;
}
...
...
@@ -2855,7 +2855,6 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
lastRowFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
int32_t
slotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
...
...
@@ -2864,14 +2863,13 @@ int32_t lastRowFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
SFirstLastRes
*
pRes
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
colDataAppend
(
pCol
,
pBlock
->
info
.
rows
,
pRes
->
buf
+
sizeof
(
TSKEY
),
pRes
->
isNull
);
//handle selectivity
//
handle selectivity
STuplePos
*
pTuplePos
=
(
STuplePos
*
)(
pRes
->
buf
+
pRes
->
bytes
+
sizeof
(
TSKEY
));
setSelectivityValue
(
pCtx
,
pBlock
,
pTuplePos
,
pBlock
->
info
.
rows
);
return
pResInfo
->
numOfRes
;
}
bool
getDiffFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
)
{
pEnv
->
calcMemSize
=
sizeof
(
SDiffInfo
);
return
true
;
...
...
@@ -2885,7 +2883,11 @@ bool diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
SDiffInfo
*
pDiffInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
pDiffInfo
->
hasPrev
=
false
;
pDiffInfo
->
prev
.
i64
=
0
;
pDiffInfo
->
ignoreNegative
=
pCtx
->
param
[
1
].
param
.
i
;
// TODO set correct param
if
(
pCtx
->
numOfParams
>
1
)
{
pDiffInfo
->
ignoreNegative
=
pCtx
->
param
[
1
].
param
.
i
;
// TODO set correct param
}
else
{
pDiffInfo
->
ignoreNegative
=
false
;
}
pDiffInfo
->
includeNull
=
false
;
pDiffInfo
->
firstOutput
=
false
;
return
true
;
...
...
@@ -3000,10 +3002,8 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
SColumnInfoData
*
pTsOutput
=
pCtx
->
pTsOutput
;
int32_t
numOfElems
=
0
;
TSKEY
*
tsList
=
(
int64_t
*
)
pInput
->
pPTS
->
pData
;
int32_t
startOffset
=
pCtx
->
offset
;
SColumnInfoData
*
pOutput
=
(
SColumnInfoData
*
)
pCtx
->
pOutput
;
...
...
@@ -3015,9 +3015,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
pDiffInfo
->
includeNull
)
{
colDataSetNull_f
(
pOutput
->
nullbitmap
,
pos
);
if
(
tsList
!=
NULL
)
{
colDataAppendInt64
(
pTsOutput
,
pos
,
&
tsList
[
i
]);
}
numOfElems
+=
1
;
}
...
...
@@ -3028,9 +3025,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
if
(
pDiffInfo
->
hasPrev
)
{
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
);
if
(
pTsOutput
!=
NULL
)
{
colDataAppendInt64
(
pTsOutput
,
pos
,
&
tsList
[
i
]);
}
numOfElems
++
;
}
else
{
...
...
@@ -3046,9 +3040,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
pDiffInfo
->
includeNull
)
{
colDataSetNull_f
(
pOutput
->
nullbitmap
,
pos
);
if
(
tsList
!=
NULL
)
{
colDataAppendInt64
(
pTsOutput
,
pos
,
&
tsList
[
i
]);
}
numOfElems
+=
1
;
}
...
...
@@ -3060,9 +3051,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
// there is a row of previous data block to be handled in the first place.
if
(
pDiffInfo
->
hasPrev
)
{
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
);
if
(
pTsOutput
!=
NULL
)
{
colDataAppendInt64
(
pTsOutput
,
pos
,
&
pDiffInfo
->
prevTs
);
}
numOfElems
++
;
}
else
{
...
...
@@ -3070,9 +3058,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
}
pDiffInfo
->
hasPrev
=
true
;
if
(
pTsOutput
!=
NULL
)
{
pDiffInfo
->
prevTs
=
tsList
[
i
];
}
}
}
...
...
@@ -3573,7 +3558,7 @@ bool elapsedFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo
pInfo
->
min
=
MAX_TS_KEY
;
pInfo
->
max
=
0
;
if
(
pCtx
->
numOfParams
>
2
)
{
if
(
pCtx
->
numOfParams
>
1
)
{
pInfo
->
timeUnit
=
pCtx
->
param
[
1
].
param
.
i
;
}
else
{
pInfo
->
timeUnit
=
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录