Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
535816bc
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
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,发现更多精彩内容 >>
提交
535816bc
编写于
9月 24, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1596]
上级
0eb138cd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
73 addition
and
10 deletion
+73
-10
src/os/src/detail/osTime.c
src/os/src/detail/osTime.c
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+23
-9
tests/script/general/parser/topbot.sim
tests/script/general/parser/topbot.sim
+49
-0
未找到文件。
src/os/src/detail/osTime.c
浏览文件 @
535816bc
...
...
@@ -481,7 +481,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
start
=
(
int64_t
)(
mktime
(
&
tm
)
*
TSDB_TICK_PER_SECOND
(
precision
));
}
else
{
int64_t
delta
=
t
-
pInterval
->
interval
;
int32_t
factor
=
delta
>
0
?
1
:
-
1
;
int32_t
factor
=
(
delta
>=
0
)
?
1
:
-
1
;
start
=
(
delta
/
pInterval
->
sliding
+
factor
)
*
pInterval
->
sliding
;
...
...
src/query/src/qExecutor.c
浏览文件 @
535816bc
...
...
@@ -2225,10 +2225,11 @@ static bool overlapWithTimeWindow(SQuery* pQuery, SDataBlockInfo* pBlockInfo) {
return
false
;
}
int32_t
loadDataBlockOnDemand
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
void
*
pQueryHandle
,
SDataBlockInfo
*
pBlockInfo
,
SDataStatis
**
pStatis
,
SArray
**
pDataBlock
,
uint32_t
*
status
)
{
int32_t
loadDataBlockOnDemand
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SWindowResInfo
*
pWindowResInfo
,
void
*
pQueryHandle
,
SDataBlockInfo
*
pBlockInfo
,
SDataStatis
**
pStatis
,
SArray
**
pDataBlock
,
uint32_t
*
status
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
*
status
=
0
;
*
status
=
BLK_DATA_NO_NEEDED
;
if
(
pQuery
->
numOfFilterCols
>
0
||
pRuntimeEnv
->
pTSBuf
>
0
)
{
*
status
=
BLK_DATA_ALL_NEEDED
;
}
else
{
// check if this data block is required to load
...
...
@@ -2240,12 +2241,26 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, void* pQueryHandle,
}
if
((
*
status
)
!=
BLK_DATA_ALL_NEEDED
)
{
// the pCtx[i] result is belonged to previous time window since the outputBuf has not been set yet,
// the filter result may be incorrect. So in case of interval query, we need to set the correct time output buffer
if
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
))
{
bool
hasTimeWindow
=
false
;
bool
masterScan
=
IS_MASTER_SCAN
(
pRuntimeEnv
);
TSKEY
k
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
pBlockInfo
->
window
.
skey
:
pBlockInfo
->
window
.
ekey
;
STimeWindow
win
=
getActiveTimeWindow
(
pWindowResInfo
,
k
,
pQuery
);
if
(
setWindowOutputBufByKey
(
pRuntimeEnv
,
pWindowResInfo
,
pBlockInfo
->
tid
,
&
win
,
masterScan
,
&
hasTimeWindow
)
!=
TSDB_CODE_SUCCESS
)
{
// todo handle error in set result for timewindow
}
}
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
SSqlFuncMsg
*
pSqlFunc
=
&
pQuery
->
pSelectExpr
[
i
].
base
;
int32_t
functionId
=
pSqlFunc
->
functionId
;
int32_t
colId
=
pSqlFunc
->
colInfo
.
colId
;
(
*
status
)
|=
aAggs
[
functionId
].
dataReqFunc
(
&
pRuntimeEnv
->
pCtx
[
i
],
pBlockInfo
->
window
.
skey
,
pBlockInfo
->
window
.
ekey
,
colId
);
if
(((
*
status
)
&
BLK_DATA_ALL_NEEDED
)
==
BLK_DATA_ALL_NEEDED
)
{
break
;
...
...
@@ -2476,7 +2491,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
SArray
*
pDataBlock
=
NULL
;
uint32_t
status
=
0
;
int32_t
ret
=
loadDataBlockOnDemand
(
pRuntimeEnv
,
pQueryHandle
,
&
blockInfo
,
&
pStatis
,
&
pDataBlock
,
&
status
);
int32_t
ret
=
loadDataBlockOnDemand
(
pRuntimeEnv
,
&
pRuntimeEnv
->
windowResInfo
,
pQueryHandle
,
&
blockInfo
,
&
pStatis
,
&
pDataBlock
,
&
status
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
break
;
}
...
...
@@ -4667,18 +4682,17 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) {
setEnvForEachBlock
(
pQInfo
,
*
pTableQueryInfo
,
&
blockInfo
);
}
SDataStatis
*
pStatis
=
NULL
;
SArray
*
pDataBlock
=
NULL
;
uint32_t
status
=
0
;
SDataStatis
*
pStatis
=
NULL
;
SArray
*
pDataBlock
=
NULL
;
int32_t
ret
=
loadDataBlockOnDemand
(
pRuntimeEnv
,
pQueryHandle
,
&
blockInfo
,
&
pStatis
,
&
pDataBlock
,
&
status
);
int32_t
ret
=
loadDataBlockOnDemand
(
pRuntimeEnv
,
&
pQuery
->
current
->
windowResInfo
,
pQueryHandle
,
&
blockInfo
,
&
pStatis
,
&
pDataBlock
,
&
status
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
break
;
}
if
(
status
==
BLK_DATA_DISCARD
)
{
pQuery
->
current
->
lastKey
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
blockInfo
.
window
.
ekey
+
step
:
blockInfo
.
window
.
skey
+
step
;
pQuery
->
current
->
lastKey
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
blockInfo
.
window
.
ekey
+
step
:
blockInfo
.
window
.
skey
+
step
;
continue
;
}
...
...
tests/script/general/parser/topbot.sim
浏览文件 @
535816bc
...
...
@@ -213,4 +213,53 @@ if $data01 != 5195.000000000 then
return -1
endi
print =======================>td-1596
sql create table t2(ts timestamp, k int)
sql insert into t2 values('2020-1-2 1:1:1', 1);
sql insert into t2 values('2020-2-2 1:1:1', 1);
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
sql connect
sleep 1000
sql use db
sql select count(*), first(ts), last(ts) from t2 interval(1d);
if $rows != 2 then
return -1
endi
if $data00 != @20-01-02 00:00:00.000@ then
print expect 20-01-02 00:00:00.000, actual: $data00
return -1
endi
if $data10 != @20-02-02 00:00:00.000@ then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data11 != 1 then
return -1
endi
if $data02 != @20-01-02 01:01:01.000@ then
return -1
endi
if $data12 != @20-02-02 01:01:01.000@ then
return -1
endi
if $data03 != @20-01-02 01:01:01.000@ then
return -1
endi
if $data13 != @20-02-02 01:01:01.000@ then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录