Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
df58a9bb
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看板
提交
df58a9bb
编写于
7月 20, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): handle fraction of ts in add ts offset.
上级
facf3c86
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
19 addition
and
15 deletion
+19
-15
source/common/src/ttime.c
source/common/src/ttime.c
+4
-2
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-1
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+2
-2
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+9
-8
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+2
-2
tests/script/tsim/query/interval-offset.sim
tests/script/tsim/query/interval-offset.sim
+1
-0
未找到文件。
source/common/src/ttime.c
浏览文件 @
df58a9bb
...
...
@@ -700,6 +700,8 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
numOfMonth
*=
12
;
}
int64_t
fraction
=
t
%
TSDB_TICK_PER_SECOND
(
precision
);
struct
tm
tm
;
time_t
tt
=
(
time_t
)(
t
/
TSDB_TICK_PER_SECOND
(
precision
));
taosLocalTime
(
&
tt
,
&
tm
);
...
...
@@ -707,7 +709,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
tm
.
tm_year
=
mon
/
12
;
tm
.
tm_mon
=
mon
%
12
;
return
(
int64_t
)(
taosMktime
(
&
tm
)
*
TSDB_TICK_PER_SECOND
(
precision
));
return
(
int64_t
)(
taosMktime
(
&
tm
)
*
TSDB_TICK_PER_SECOND
(
precision
)
+
fraction
);
}
int64_t
taosTimeSub
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
)
{
...
...
@@ -851,7 +853,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
newEnd
=
taosTimeAdd
(
newEnd
,
-
pInterval
->
sliding
,
pInterval
->
slidingUnit
,
precision
);
}
start
=
taosTimeAdd
(
end
,
-
pInterval
->
interval
+
1
,
pInterval
->
intervalUnit
,
precision
)
;
start
=
taosTimeAdd
(
end
,
-
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
+
1
;
}
}
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
df58a9bb
...
...
@@ -797,7 +797,7 @@ void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWin
int32_t
extractDataBlockFromFetchRsp
(
SSDataBlock
*
pRes
,
SLoadRemoteDataInfo
*
pLoadInfo
,
int32_t
numOfRows
,
char
*
pData
,
int32_t
compLen
,
int32_t
numOfOutput
,
int64_t
startTs
,
uint64_t
*
total
,
SArray
*
pColList
);
void
getAlignQueryTimeWindow
(
SInterval
*
pInterval
,
int32_t
precision
,
int64_t
key
,
STimeWindow
*
win
);
STimeWindow
getAlignQueryTimeWindow
(
SInterval
*
pInterval
,
int32_t
precision
,
int64_t
key
);
STimeWindow
getFirstQualifiedTimeWindow
(
int64_t
ts
,
STimeWindow
*
pWindow
,
SInterval
*
pInterval
,
int32_t
order
);
int32_t
getTableScanInfo
(
SOperatorInfo
*
pOperator
,
int32_t
*
order
,
int32_t
*
scanFlag
);
...
...
source/libs/executor/src/executil.c
浏览文件 @
df58a9bb
...
...
@@ -824,10 +824,10 @@ int32_t convertFillType(int32_t mode) {
static
void
getInitialStartTimeWindow
(
SInterval
*
pInterval
,
TSKEY
ts
,
STimeWindow
*
w
,
bool
ascQuery
)
{
if
(
ascQuery
)
{
getAlignQueryTimeWindow
(
pInterval
,
pInterval
->
precision
,
ts
,
w
);
*
w
=
getAlignQueryTimeWindow
(
pInterval
,
pInterval
->
precision
,
ts
);
}
else
{
// the start position of the first time window in the endpoint that spreads beyond the queried last timestamp
getAlignQueryTimeWindow
(
pInterval
,
pInterval
->
precision
,
ts
,
w
);
*
w
=
getAlignQueryTimeWindow
(
pInterval
,
pInterval
->
precision
,
ts
);
int64_t
key
=
w
->
skey
;
while
(
key
<
ts
)
{
// moving towards end
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
df58a9bb
...
...
@@ -834,18 +834,20 @@ bool isTaskKilled(SExecTaskInfo* pTaskInfo) {
void
setTaskKilled
(
SExecTaskInfo
*
pTaskInfo
)
{
pTaskInfo
->
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
}
/////////////////////////////////////////////////////////////////////////////////////////////
// todo refactor : return window
void
getAlignQueryTimeWindow
(
SInterval
*
pInterval
,
int32_t
precision
,
int64_t
key
,
STimeWindow
*
win
)
{
win
->
skey
=
taosTimeTruncate
(
key
,
pInterval
,
precision
);
STimeWindow
getAlignQueryTimeWindow
(
SInterval
*
pInterval
,
int32_t
precision
,
int64_t
key
)
{
STimeWindow
win
=
{
0
};
win
.
skey
=
taosTimeTruncate
(
key
,
pInterval
,
precision
);
/*
* if the realSkey > INT64_MAX - pInterval->interval, the query duration between
* realSkey and realEkey must be less than one interval.Therefore, no need to adjust the query ranges.
*/
win
->
ekey
=
taosTimeAdd
(
win
->
skey
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
-
1
;
if
(
win
->
ekey
<
win
->
skey
)
{
win
->
ekey
=
INT64_MAX
;
win
.
ekey
=
taosTimeAdd
(
win
.
skey
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
-
1
;
if
(
win
.
ekey
<
win
.
skey
)
{
win
.
ekey
=
INT64_MAX
;
}
return
win
;
}
#if 0
...
...
@@ -4042,8 +4044,7 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
STimeWindow
win
,
int32_t
capacity
,
const
char
*
id
,
SInterval
*
pInterval
,
int32_t
fillType
)
{
SFillColInfo
*
pColInfo
=
createFillColInfo
(
pExpr
,
numOfCols
,
pValNode
);
STimeWindow
w
=
TSWINDOW_INITIALIZER
;
getAlignQueryTimeWindow
(
pInterval
,
pInterval
->
precision
,
win
.
skey
,
&
w
);
STimeWindow
w
=
getAlignQueryTimeWindow
(
pInterval
,
pInterval
->
precision
,
win
.
skey
);
w
=
getFirstQualifiedTimeWindow
(
win
.
skey
,
&
w
,
pInterval
,
TSDB_ORDER_ASC
);
int32_t
order
=
TSDB_ORDER_ASC
;
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
df58a9bb
...
...
@@ -125,7 +125,7 @@ static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockIn
}
if
(
order
==
TSDB_ORDER_ASC
)
{
getAlignQueryTimeWindow
(
pInterval
,
pInterval
->
precision
,
pBlockInfo
->
window
.
skey
,
&
w
);
w
=
getAlignQueryTimeWindow
(
pInterval
,
pInterval
->
precision
,
pBlockInfo
->
window
.
skey
);
assert
(
w
.
ekey
>=
pBlockInfo
->
window
.
skey
);
if
(
w
.
ekey
<
pBlockInfo
->
window
.
ekey
)
{
...
...
@@ -144,7 +144,7 @@ static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockIn
}
}
}
else
{
getAlignQueryTimeWindow
(
pInterval
,
pInterval
->
precision
,
pBlockInfo
->
window
.
ekey
,
&
w
);
w
=
getAlignQueryTimeWindow
(
pInterval
,
pInterval
->
precision
,
pBlockInfo
->
window
.
ekey
);
assert
(
w
.
skey
<=
pBlockInfo
->
window
.
ekey
);
if
(
w
.
skey
>
pBlockInfo
->
window
.
skey
)
{
...
...
tests/script/tsim/query/interval-offset.sim
浏览文件 @
df58a9bb
...
...
@@ -185,6 +185,7 @@ print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows3: $data30 $data31 $data32 $data33 $data34
if $rows != 4 then
print expect 4, actual: $rows
return -1
endi
if $data00 != @21-12-08 00:00:00.000@ then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录