Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
拾光师
TDengine
提交
010c30af
T
TDengine
项目概览
拾光师
/
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,发现更多精彩内容 >>
提交
010c30af
编写于
9月 17, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1477]
上级
6ea7e4ee
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
162 addition
and
21 deletion
+162
-21
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+20
-13
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+9
-1
tests/script/general/parser/first_last_query.sim
tests/script/general/parser/first_last_query.sim
+133
-7
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
010c30af
...
@@ -711,13 +711,16 @@ static int32_t firstDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY en
...
@@ -711,13 +711,16 @@ static int32_t firstDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY en
if
(
pCtx
->
aOutputBuf
==
NULL
)
{
if
(
pCtx
->
aOutputBuf
==
NULL
)
{
return
BLK_DATA_ALL_NEEDED
;
return
BLK_DATA_ALL_NEEDED
;
}
}
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)
(
pCtx
->
aOutputBuf
+
pCtx
->
inputBytes
);
return
BLK_DATA_ALL_NEEDED
;
if
(
pInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
// TODO pCtx->aOutputBuf is the previous windowRes output buffer, not current unloaded block. so the following filter
return
BLK_DATA_ALL_NEEDED
;
// is invalid
}
else
{
// data in current block is not earlier than current result
// SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
return
(
pInfo
->
ts
<=
start
)
?
BLK_DATA_NO_NEEDED
:
BLK_DATA_ALL_NEEDED
;
// if (pInfo->hasResult != DATA_SET_FLAG) {
}
// return BLK_DATA_ALL_NEEDED;
// } else { // data in current block is not earlier than current result
// return (pInfo->ts <= start) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
// }
}
}
static
int32_t
lastDistFuncRequired
(
SQLFunctionCtx
*
pCtx
,
TSKEY
start
,
TSKEY
end
,
int32_t
colId
)
{
static
int32_t
lastDistFuncRequired
(
SQLFunctionCtx
*
pCtx
,
TSKEY
start
,
TSKEY
end
,
int32_t
colId
)
{
...
@@ -730,12 +733,16 @@ static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end
...
@@ -730,12 +733,16 @@ static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end
return
BLK_DATA_ALL_NEEDED
;
return
BLK_DATA_ALL_NEEDED
;
}
}
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)
(
pCtx
->
aOutputBuf
+
pCtx
->
inputBytes
);
return
BLK_DATA_ALL_NEEDED
;
if
(
pInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
// TODO pCtx->aOutputBuf is the previous windowRes output buffer, not current unloaded block. so the following filter
return
BLK_DATA_ALL_NEEDED
;
// is invalid
}
else
{
return
(
pInfo
->
ts
>
end
)
?
BLK_DATA_NO_NEEDED
:
BLK_DATA_ALL_NEEDED
;
// SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
}
// if (pInfo->hasResult != DATA_SET_FLAG) {
// return BLK_DATA_ALL_NEEDED;
// } else {
// return (pInfo->ts > end) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
// }
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
...
...
src/query/src/qExecutor.c
浏览文件 @
010c30af
...
@@ -784,6 +784,8 @@ static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, bool closed
...
@@ -784,6 +784,8 @@ static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, bool closed
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
SQLFunctionCtx
*
pCtx
=
pRuntimeEnv
->
pCtx
;
SQLFunctionCtx
*
pCtx
=
pRuntimeEnv
->
pCtx
;
bool
hasPrev
=
pCtx
[
0
].
preAggVals
.
isSet
;
if
(
IS_MASTER_SCAN
(
pRuntimeEnv
)
||
closed
)
{
if
(
IS_MASTER_SCAN
(
pRuntimeEnv
)
||
closed
)
{
for
(
int32_t
k
=
0
;
k
<
pQuery
->
numOfOutput
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
pQuery
->
numOfOutput
;
++
k
)
{
pCtx
[
k
].
nStartQueryTimestamp
=
pWin
->
skey
;
pCtx
[
k
].
nStartQueryTimestamp
=
pWin
->
skey
;
...
@@ -796,11 +798,17 @@ static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, bool closed
...
@@ -796,11 +798,17 @@ static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, bool closed
}
}
// not a whole block involved in query processing, statistics data can not be used
// not a whole block involved in query processing, statistics data can not be used
pCtx
[
k
].
preAggVals
.
isSet
=
(
forwardStep
==
numOfTotal
);
// NOTE: the original value of isSet have been changed here
if
(
pCtx
[
k
].
preAggVals
.
isSet
&&
forwardStep
<
numOfTotal
)
{
pCtx
[
k
].
preAggVals
.
isSet
=
false
;
}
if
(
functionNeedToExecute
(
pRuntimeEnv
,
&
pCtx
[
k
],
functionId
))
{
if
(
functionNeedToExecute
(
pRuntimeEnv
,
&
pCtx
[
k
],
functionId
))
{
aAggs
[
functionId
].
xFunction
(
&
pCtx
[
k
]);
aAggs
[
functionId
].
xFunction
(
&
pCtx
[
k
]);
}
}
// restore it
pCtx
[
k
].
preAggVals
.
isSet
=
hasPrev
;
}
}
}
}
}
}
...
...
tests/script/general/parser/first_last_query.sim
浏览文件 @
010c30af
...
@@ -65,22 +65,23 @@ endi
...
@@ -65,22 +65,23 @@ endi
if $data00 != @18-09-18 01:40:00.000@ then
if $data00 != @18-09-18 01:40:00.000@ then
return -1
return -1
endi
endi
#if $data01 != NULL then
if $data01 != 999 then
if $data01 != 999 then
return -1
return -1
endi
endi
#if $data02 != NULL then
if $data02 != 999 then
if $data02 != 999 then
return -1
return -1
endi
endi
#if $data03 != NULL then
if $data03 != 999.00000 then
if $data03 != 999.00000 then
return -1
return -1
endi
endi
#if $data04 != NULL then
if $data04 != 999.000000000 then
if $data04 != 999.000000000 then
return -1
return -1
endi
endi
#if $data05 != NULL then
#if $data05 != NULL then
if $data05 != 999 then
if $data05 != 999 then
return -1
return -1
...
@@ -127,7 +128,7 @@ if $data01 != 0 then
...
@@ -127,7 +128,7 @@ if $data01 != 0 then
return -1
return -1
endi
endi
#
add check for out of range first/last query
print =============>
add check for out of range first/last query
sql select first(ts),last(ts) from first_tb4 where ts>'2018-9-18 1:40:01';
sql select first(ts),last(ts) from first_tb4 where ts>'2018-9-18 1:40:01';
if $row != 0 then
if $row != 0 then
return -1
return -1
...
@@ -136,4 +137,129 @@ endi
...
@@ -136,4 +137,129 @@ endi
sql select first(ts),last(ts) from first_tb4 where ts<'2018-9-17 8:50:0';
sql select first(ts),last(ts) from first_tb4 where ts<'2018-9-17 8:50:0';
if $row != 0 then
if $row != 0 then
return -1
return -1
endi
#first/last mix up query
#select first(size),last(size) from stest interval(1d) group by tbname;
print =====================>td-1477
sql create table stest(ts timestamp,size INT,filenum INT) tags (appname binary(500),tenant binary(500));
sql insert into test1 using stest tags('test1','aaa') values ('2020-09-04 16:53:54.003',210,3);
sql insert into test2 using stest tags('test1','aaa') values ('2020-09-04 16:53:56.003',210,3);
sql insert into test11 using stest tags('test11','bbb') values ('2020-09-04 16:53:57.003',210,3);
sql insert into test12 using stest tags('test11','bbb') values ('2020-09-04 16:53:58.003',210,3);
sql insert into test21 using stest tags('test21','ccc') values ('2020-09-04 16:53:59.003',210,3);
sql insert into test22 using stest tags('test21','ccc') values ('2020-09-04 16:54:54.003',210,3);
sql select sum(size) from stest group by appname;
if $rows != 3 then
return -1
endi
if $data00 != 420 then
return -1
endi
if $data10 != 420 then
return -1
endi
if $data20 != 420 then
return -1
endi
if $data01 != @test1@ then
return -1
endi
if $data11 != @test11@ then
return -1
endi
if $data21 != @test21@ then
return -1
endi
sql select sum(size) from stest interval(1d) group by appname;
if $rows != 3 then
return -1
endi
#2020-09-04 00:00:00.000 | 420 | test1 |
#2020-09-04 00:00:00.000 | 420 | test11 |
#2020-09-04 00:00:00.000 | 420 | test21 |
if $data00 != @20-09-04 00:00:00.000@ then
return -1
endi
if $data10 != @20-09-04 00:00:00.000@ then
return -1
endi
if $data20 != @20-09-04 00:00:00.000@ then
return -1
endi
if $data01 != 420 then
print expect 420 , actual $data01
return -1
endi
if $data11 != 420 then
return -1
endi
if $data21 != 420 then
return -1
endi
if $data02 != @test1@ then
return -1
endi
if $data12 != @test11@ then
return -1
endi
if $data22 != @test21@ then
return -1
endi
print ===================>td-1477, one table has only one block occurs this bug.
sql select first(size),count(*),LAST(SIZE) from stest where tbname in ('test1', 'test2') interval(1d) group by tbname;
if $rows != 2 then
return -1
endi
if $data00 != @20-09-04 00:00:00.000@ then
return -1
endi
if $data01 != 210 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data03 != 210 then
return -1
endi
if $data04 != @test1@ then
return -1
endi
if $data10 != @20-09-04 00:00:00.000@ then
return -1
endi
if $data11 != 210 then
return -1
endi
if $data12 != 1 then
return -1
endi
if $data13 != 210 then
return -1
endi
if $data14 != @test11@ then
return -1
endi
endi
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录