Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1cba5686
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1cba5686
编写于
11月 11, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): report error if certain function query stable has duplicate
timestamps TD-19892
上级
a63e79e3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
39 addition
and
12 deletion
+39
-12
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+5
-1
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
+32
-9
未找到文件。
source/libs/executor/src/executorimpl.c
浏览文件 @
1cba5686
...
...
@@ -653,7 +653,11 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
pfCtx
->
pDstBlock
=
pResult
;
}
numOfRows
=
pfCtx
->
fpSet
.
process
(
pfCtx
);
int32_t
code
=
pfCtx
->
fpSet
.
process
(
pfCtx
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
numOfRows
=
pResInfo
->
numOfRes
;
}
else
if
(
fmIsAggFunc
(
pfCtx
->
functionId
))
{
// selective value output should be set during corresponding function execution
if
(
fmIsSelectValueFunc
(
pfCtx
->
functionId
))
{
...
...
source/libs/function/src/builtins.c
浏览文件 @
1cba5686
...
...
@@ -2640,8 +2640,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.
name
=
"diff"
,
.
type
=
FUNCTION_TYPE_DIFF
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_
KEEP_ORDER_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
|
FUNC_MGT_CUMULATIVE_FUNC
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_
IMPLICIT_TS_FUNC
|
FUNC_MGT_
KEEP_ORDER_FUNC
|
FUNC_MGT_
FORBID_STREAM_FUNC
|
FUNC_MGT_CUMULATIVE_FUNC
,
.
translateFunc
=
translateDiff
,
.
getEnvFunc
=
getDiffFuncEnv
,
.
initFunc
=
diffFunctionSetup
,
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
1cba5686
...
...
@@ -3325,6 +3325,7 @@ bool diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
SDiffInfo
*
pDiffInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
pDiffInfo
->
hasPrev
=
false
;
pDiffInfo
->
prev
.
i64
=
0
;
pDiffInfo
->
prevTs
=
-
1
;
if
(
pCtx
->
numOfParams
>
1
)
{
pDiffInfo
->
ignoreNegative
=
pCtx
->
param
[
1
].
param
.
i
;
// TODO set correct param
}
else
{
...
...
@@ -3335,7 +3336,7 @@ bool diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
return
true
;
}
static
void
doSetPrevVal
(
SDiffInfo
*
pDiffInfo
,
int32_t
type
,
const
char
*
pv
)
{
static
void
doSetPrevVal
(
SDiffInfo
*
pDiffInfo
,
int32_t
type
,
const
char
*
pv
,
int64_t
ts
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
pDiffInfo
->
prev
.
i64
=
*
(
bool
*
)
pv
?
1
:
0
;
...
...
@@ -3362,11 +3363,13 @@ static void doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv) {
default:
ASSERT
(
0
);
}
pDiffInfo
->
prevTs
=
ts
;
}
static
void
doHandleDiff
(
SDiffInfo
*
pDiffInfo
,
int32_t
type
,
const
char
*
pv
,
SColumnInfoData
*
pOutput
,
int32_t
pos
,
int32_t
order
)
{
int32_t
order
,
int64_t
ts
)
{
int32_t
factor
=
(
order
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
pDiffInfo
->
prevTs
=
ts
;
switch
(
type
)
{
case
TSDB_DATA_TYPE_INT
:
{
int32_t
v
=
*
(
int32_t
*
)
pv
;
...
...
@@ -3450,6 +3453,8 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
TSKEY
*
tsList
=
(
int64_t
*
)
pInput
->
pPTS
->
pData
;
int32_t
numOfElems
=
0
;
int32_t
startOffset
=
pCtx
->
offset
;
...
...
@@ -3471,7 +3476,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
char
*
pv
=
colDataGetData
(
pInputCol
,
i
);
if
(
pDiffInfo
->
hasPrev
)
{
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
);
if
(
tsList
[
i
]
==
pDiffInfo
->
prevTs
)
{
return
TSDB_CODE_FUNC_DUP_TIMESTAMP
;
}
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
,
tsList
[
i
]);
// handle selectivity
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
appendSelectivityValue
(
pCtx
,
i
,
pos
);
...
...
@@ -3479,7 +3487,7 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
numOfElems
++
;
}
else
{
doSetPrevVal
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
);
doSetPrevVal
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
tsList
[
i
]
);
}
pDiffInfo
->
hasPrev
=
true
;
...
...
@@ -3501,7 +3509,10 @@ 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
(
tsList
[
i
]
==
pDiffInfo
->
prevTs
)
{
return
TSDB_CODE_FUNC_DUP_TIMESTAMP
;
}
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
,
tsList
[
i
]);
// handle selectivity
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
appendSelectivityValue
(
pCtx
,
i
,
pos
);
...
...
@@ -3509,15 +3520,15 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
numOfElems
++
;
}
else
{
doSetPrevVal
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
);
doSetPrevVal
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
tsList
[
i
]
);
}
pDiffInfo
->
hasPrev
=
true
;
}
}
// initial value is not set yet
return
numOfElems
;
pResInfo
->
numOfRes
=
numOfElems
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
getTopBotInfoSize
(
int64_t
numOfItems
)
{
return
sizeof
(
STopBotRes
)
+
numOfItems
*
sizeof
(
STopBotResItem
);
}
...
...
@@ -6137,6 +6148,9 @@ int32_t derivativeFunction(SqlFunctionCtx* pCtx) {
if
(
!
pDerivInfo
->
valueSet
)
{
// initial value is not set yet
pDerivInfo
->
valueSet
=
true
;
}
else
{
if
(
tsList
[
i
]
==
pDerivInfo
->
prevTs
)
{
return
TSDB_CODE_FUNC_DUP_TIMESTAMP
;
}
double
r
=
((
v
-
pDerivInfo
->
prevValue
)
*
pDerivInfo
->
tsWindow
)
/
(
tsList
[
i
]
-
pDerivInfo
->
prevTs
);
if
(
pDerivInfo
->
ignoreNegative
&&
r
<
0
)
{
}
else
{
...
...
@@ -6175,6 +6189,9 @@ int32_t derivativeFunction(SqlFunctionCtx* pCtx) {
if
(
!
pDerivInfo
->
valueSet
)
{
// initial value is not set yet
pDerivInfo
->
valueSet
=
true
;
}
else
{
if
(
tsList
[
i
]
==
pDerivInfo
->
prevTs
)
{
return
TSDB_CODE_FUNC_DUP_TIMESTAMP
;
}
double
r
=
((
pDerivInfo
->
prevValue
-
v
)
*
pDerivInfo
->
tsWindow
)
/
(
pDerivInfo
->
prevTs
-
tsList
[
i
]);
if
(
pDerivInfo
->
ignoreNegative
&&
r
<
0
)
{
}
else
{
...
...
@@ -6202,7 +6219,9 @@ int32_t derivativeFunction(SqlFunctionCtx* pCtx) {
}
}
return
numOfElems
;
pResInfo
->
numOfRes
=
numOfElems
;
return
TSDB_CODE_SUCCESS
;
}
bool
getIrateFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
...
...
@@ -6267,11 +6286,15 @@ int32_t irateFunction(SqlFunctionCtx* pCtx) {
pRateInfo
->
lastKey
=
tsList
[
i
];
continue
;
}
else
if
(
tsList
[
i
]
==
pRateInfo
->
lastKey
)
{
return
TSDB_CODE_FUNC_DUP_TIMESTAMP
;
}
if
((
INT64_MIN
==
pRateInfo
->
firstKey
)
||
tsList
[
i
]
>
pRateInfo
->
firstKey
)
{
pRateInfo
->
firstValue
=
v
;
pRateInfo
->
firstKey
=
tsList
[
i
];
}
else
if
(
tsList
[
i
]
==
pRateInfo
->
firstKey
)
{
return
TSDB_CODE_FUNC_DUP_TIMESTAMP
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录