Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tonvia
TDengine
提交
7c36f3de
T
TDengine
项目概览
Tonvia
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7c36f3de
编写于
8月 16, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6046]<fix> fix ts,derivative() output error for top/bottom/diff/derivative
上级
4b9c461c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
4 deletion
+26
-4
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+3
-2
src/query/inc/qAggMain.h
src/query/inc/qAggMain.h
+1
-0
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+14
-0
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+8
-2
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
7c36f3de
...
...
@@ -2872,7 +2872,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
const
int32_t
TS_COLUMN_INDEX
=
PRIMARYKEY_TIMESTAMP_COL_INDEX
;
SColumnList
ids
=
createColumnList
(
1
,
index
.
tableIndex
,
TS_COLUMN_INDEX
);
insertResultField
(
pQueryInfo
,
TS_COLUMN_INDEX
,
&
ids
,
TSDB_KEYSIZE
,
TSDB_DATA_TYPE_TIMESTAMP
,
insertResultField
(
pQueryInfo
,
colIndex
,
&
ids
,
TSDB_KEYSIZE
,
TSDB_DATA_TYPE_TIMESTAMP
,
aAggs
[
TSDB_FUNC_TS
].
name
,
pExpr
);
colIndex
+=
1
;
// the first column is ts
...
...
@@ -7052,7 +7052,8 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) {
continue
;
}
if
(
functionId
==
TSDB_FUNC_DERIVATIVE
){
// to avoid ts function id was modufied below
if
(
functionId
==
TSDB_FUNC_DERIVATIVE
||
functionId
==
TSDB_FUNC_DIFF
||
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
){
// to avoid ts function id was modufied below
tagTsColExists
=
false
;
}
...
...
src/query/inc/qAggMain.h
浏览文件 @
7c36f3de
...
...
@@ -186,6 +186,7 @@ typedef struct SQLFunctionCtx {
tVariant
param
[
4
];
// input parameter, e.g., top(k, 20), the number of results for top query is kept in param
int64_t
*
ptsList
;
// corresponding timestamp array list
void
*
ptsOutputBuf
;
// corresponding output buffer for timestamp of each result, e.g., top/bottom*/
void
*
ptsOriOutputBuf
;
SQLPreAggVal
preAggVals
;
tVariant
tag
;
...
...
src/query/src/qAggMain.c
浏览文件 @
7c36f3de
...
...
@@ -2789,6 +2789,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
int32_t
i
=
(
pCtx
->
order
==
TSDB_ORDER_ASC
)
?
0
:
pCtx
->
size
-
1
;
TSKEY
*
pTimestamp
=
pCtx
->
ptsOutputBuf
;
TSKEY
*
pTimestampOri
=
pCtx
->
ptsOriOutputBuf
;
TSKEY
*
tsList
=
GET_TS_LIST
(
pCtx
);
double
*
pOutput
=
(
double
*
)
pCtx
->
pOutput
;
...
...
@@ -2808,6 +2809,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
}
else
{
*
pTimestamp
=
tsList
[
i
];
if
(
pTimestampOri
)
{
*
pTimestampOri
=
tsList
[
i
];
pTimestampOri
+=
1
;}
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
...
...
@@ -2835,6 +2837,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
}
else
{
*
pTimestamp
=
tsList
[
i
];
if
(
pTimestampOri
)
{
*
pTimestampOri
=
tsList
[
i
];
pTimestampOri
+=
1
;}
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
...
...
@@ -2861,6 +2864,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
}
else
{
*
pTimestamp
=
tsList
[
i
];
if
(
pTimestampOri
)
{
*
pTimestampOri
=
tsList
[
i
];
pTimestampOri
+=
1
;}
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
...
...
@@ -2888,6 +2892,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
}
else
{
*
pTimestamp
=
tsList
[
i
];
if
(
pTimestampOri
)
{
*
pTimestampOri
=
tsList
[
i
];
pTimestampOri
+=
1
;}
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
...
...
@@ -2914,6 +2919,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
}
else
{
*
pTimestamp
=
tsList
[
i
];
if
(
pTimestampOri
)
{
*
pTimestampOri
=
tsList
[
i
];
pTimestampOri
+=
1
;}
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
...
...
@@ -2940,6 +2946,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
if
(
pDerivInfo
->
ignoreNegative
&&
*
pOutput
<
0
)
{
}
else
{
*
pTimestamp
=
tsList
[
i
];
if
(
pTimestampOri
)
{
*
pTimestampOri
=
tsList
[
i
];
pTimestampOri
+=
1
;}
pOutput
+=
1
;
pTimestamp
+=
1
;
...
...
@@ -2982,6 +2989,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
int32_t
i
=
(
pCtx
->
order
==
TSDB_ORDER_ASC
)
?
0
:
pCtx
->
size
-
1
;
TSKEY
*
pTimestamp
=
pCtx
->
ptsOutputBuf
;
TSKEY
*
pTimestampOri
=
pCtx
->
ptsOriOutputBuf
;
TSKEY
*
tsList
=
GET_TS_LIST
(
pCtx
);
switch
(
pCtx
->
inputType
)
{
...
...
@@ -2997,6 +3005,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
*
pOutput
=
(
int32_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
if
(
pTimestampOri
)
{
*
pTimestampOri
=
*
pTimestamp
;
pTimestampOri
+=
1
;}
pOutput
+=
1
;
pTimestamp
+=
1
;
}
...
...
@@ -3019,6 +3028,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
*
pOutput
=
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
;
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
if
(
pTimestampOri
)
{
*
pTimestampOri
=
*
pTimestamp
;
pTimestampOri
+=
1
;}
pOutput
+=
1
;
pTimestamp
+=
1
;
}
...
...
@@ -3041,6 +3051,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
SET_DOUBLE_VAL
(
pOutput
,
pData
[
i
]
-
pCtx
->
param
[
1
].
dKey
);
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
if
(
pTimestampOri
)
{
*
pTimestampOri
=
*
pTimestamp
;
pTimestampOri
+=
1
;}
pOutput
+=
1
;
pTimestamp
+=
1
;
}
...
...
@@ -3063,6 +3074,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
*
pOutput
=
(
float
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
dKey
);
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
if
(
pTimestampOri
)
{
*
pTimestampOri
=
*
pTimestamp
;
pTimestampOri
+=
1
;}
pOutput
+=
1
;
pTimestamp
+=
1
;
}
...
...
@@ -3085,6 +3097,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
*
pOutput
=
(
int16_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
if
(
pTimestampOri
)
{
*
pTimestampOri
=
*
pTimestamp
;
pTimestampOri
+=
1
;}
pOutput
+=
1
;
pTimestamp
+=
1
;
}
...
...
@@ -3108,6 +3121,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
param
[
1
].
nType
!=
INITIAL_VALUE_NOT_ASSIGNED
)
{
// initial value is not set yet
*
pOutput
=
(
int8_t
)(
pData
[
i
]
-
pCtx
->
param
[
1
].
i64
);
// direct previous may be null
*
pTimestamp
=
(
tsList
!=
NULL
)
?
tsList
[
i
]
:
0
;
if
(
pTimestampOri
)
{
*
pTimestampOri
=
*
pTimestamp
;
pTimestampOri
+=
1
;}
pOutput
+=
1
;
pTimestamp
+=
1
;
}
...
...
src/query/src/qExecutor.c
浏览文件 @
7c36f3de
...
...
@@ -3615,14 +3615,20 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOf
}
}
char
*
tsbuf
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
pDataBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
pBInfo
->
pCtx
[
i
].
pOutput
=
pColInfo
->
pData
+
pColInfo
->
info
.
bytes
*
pDataBlock
->
info
.
rows
;
// re-estabilish output buffer pointer.
int32_t
functionId
=
pBInfo
->
pCtx
[
i
].
functionId
;
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_DIFF
||
functionId
==
TSDB_FUNC_DERIVATIVE
)
{
if
(
i
>
0
)
pBInfo
->
pCtx
[
i
].
ptsOutputBuf
=
pBInfo
->
pCtx
[
i
-
1
].
pOutput
;
if
(
functionId
==
TSDB_FUNC_PRJ
&&
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
){
tsbuf
=
pBInfo
->
pCtx
[
i
].
pOutput
;
}
else
if
((
i
>
0
)
&&
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_DIFF
||
functionId
==
TSDB_FUNC_DERIVATIVE
))
{
pBInfo
->
pCtx
[
i
].
ptsOutputBuf
=
pBInfo
->
pCtx
[
i
-
1
].
pOutput
;
pBInfo
->
pCtx
[
i
].
ptsOriOutputBuf
=
tsbuf
;
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录