Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e6febe45
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,发现更多精彩内容 >>
未验证
提交
e6febe45
编写于
7月 20, 2022
作者:
H
Haojun Liao
提交者:
GitHub
7月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15180 from taosdata/feature/3_liaohj
fix(query): fix time window generating bug.
上级
8a9e729d
fc7887e6
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
98 addition
and
95 deletion
+98
-95
include/common/ttime.h
include/common/ttime.h
+0
-1
source/common/src/ttime.c
source/common/src/ttime.c
+10
-31
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+4
-4
source/libs/executor/src/cachescanoperator.c
source/libs/executor/src/cachescanoperator.c
+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
+18
-17
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+1
-1
source/libs/executor/src/joinoperator.c
source/libs/executor/src/joinoperator.c
+1
-1
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+5
-5
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+38
-18
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+10
-10
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+1
-1
tests/script/tsim/query/interval-offset.sim
tests/script/tsim/query/interval-offset.sim
+1
-0
tests/script/tsim/scalar/scalar.sim
tests/script/tsim/scalar/scalar.sim
+6
-3
未找到文件。
include/common/ttime.h
浏览文件 @
e6febe45
...
...
@@ -73,7 +73,6 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
}
int64_t
taosTimeAdd
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
);
int64_t
taosTimeSub
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
);
int64_t
taosTimeTruncate
(
int64_t
t
,
const
SInterval
*
pInterval
,
int32_t
precision
);
int32_t
taosTimeCountInterval
(
int64_t
skey
,
int64_t
ekey
,
int64_t
interval
,
char
unit
,
int32_t
precision
);
...
...
source/common/src/ttime.c
浏览文件 @
e6febe45
...
...
@@ -700,42 +700,18 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
numOfMonth
*=
12
;
}
struct
tm
tm
;
time_t
tt
=
(
time_t
)(
t
/
TSDB_TICK_PER_SECOND
(
precision
));
taosLocalTime
(
&
tt
,
&
tm
);
int32_t
mon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
+
(
int32_t
)
numOfMonth
;
tm
.
tm_year
=
mon
/
12
;
tm
.
tm_mon
=
mon
%
12
;
return
(
int64_t
)(
taosMktime
(
&
tm
)
*
TSDB_TICK_PER_SECOND
(
precision
));
}
int64_t
taosTimeSub
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
)
{
if
(
duration
==
0
)
{
return
t
;
}
if
(
unit
!=
'n'
&&
unit
!=
'y'
)
{
return
t
-
duration
;
}
// The following code handles the y/n time duration
int64_t
numOfMonth
=
duration
;
if
(
unit
==
'y'
)
{
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
);
int32_t
mon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
-
(
int32_t
)
numOfMonth
;
int32_t
mon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
+
(
int32_t
)
numOfMonth
;
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
);
}
int32_t
taosTimeCountInterval
(
int64_t
skey
,
int64_t
ekey
,
int64_t
interval
,
char
unit
,
int32_t
precision
)
{
if
(
ekey
<
skey
)
{
int64_t
tmp
=
ekey
;
...
...
@@ -844,11 +820,14 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
}
else
{
// try to move current window to the left-hande-side, due to the offset effect.
int64_t
end
=
taosTimeAdd
(
start
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
-
1
;
ASSERT
(
end
>=
t
);
end
=
taosTimeAdd
(
end
,
-
pInterval
->
sliding
,
pInterval
->
slidingUnit
,
precision
);
if
(
end
>=
t
)
{
start
=
taosTimeAdd
(
start
,
-
pInterval
->
sliding
,
pInterval
->
slidingUnit
,
precision
);
int64_t
newEnd
=
end
;
while
(
newEnd
>=
t
)
{
end
=
newEnd
;
newEnd
=
taosTimeAdd
(
newEnd
,
-
pInterval
->
sliding
,
pInterval
->
slidingUnit
,
precision
);
}
start
=
taosTimeAdd
(
end
,
-
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
+
1
;
}
}
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
e6febe45
...
...
@@ -744,8 +744,8 @@ typedef struct SSortOperatorInfo {
int64_t
startTs
;
// sort start time
uint64_t
sortElapsed
;
// sort elapsed time, time to flush to disk not included.
SNode
*
pCondition
;
SLimitInfo
limitInfo
;
SNode
*
pCondition
;
}
SSortOperatorInfo
;
typedef
struct
STagFilterOperatorInfo
{
...
...
@@ -785,7 +785,7 @@ int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr);
void
cleanupExprSupp
(
SExprSupp
*
pSup
);
int32_t
initAggInfo
(
SExprSupp
*
pSup
,
SAggSupporter
*
pAggSup
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
size_t
keyBufSize
,
const
char
*
pkey
);
void
initResultSizeInfo
(
S
OperatorInfo
*
pOperator
,
int32_t
numOfRows
);
void
initResultSizeInfo
(
S
ResultInfo
*
pResultInfo
,
int32_t
numOfRows
);
void
doBuildResultDatablock
(
SOperatorInfo
*
pOperator
,
SOptrBasicInfo
*
pbInfo
,
SGroupResInfo
*
pGroupResInfo
,
SDiskbasedBuf
*
pBuf
);
int32_t
handleLimitOffset
(
SOperatorInfo
*
pOperator
,
SLimitInfo
*
pLimitInfo
,
SSDataBlock
*
pBlock
,
bool
holdDataInBuf
);
bool
hasLimitOffsetInfo
(
SLimitInfo
*
pLimitInfo
);
...
...
@@ -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/cachescanoperator.c
浏览文件 @
e6febe45
...
...
@@ -50,7 +50,7 @@ SOperatorInfo* createLastrowScanOperator(SLastRowScanPhysiNode* pScanNode, SRead
STableListInfo
*
pTableList
=
&
pTaskInfo
->
tableqinfoList
;
initResultSizeInfo
(
pOperator
,
1024
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
1024
);
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
pInfo
->
pUidList
=
taosArrayInit
(
4
,
sizeof
(
int64_t
));
...
...
source/libs/executor/src/executil.c
浏览文件 @
e6febe45
...
...
@@ -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
浏览文件 @
e6febe45
...
...
@@ -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
...
...
@@ -3603,13 +3605,13 @@ int32_t initAggInfo(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInf
return
TSDB_CODE_SUCCESS
;
}
void
initResultSizeInfo
(
S
OperatorInfo
*
pOperator
,
int32_t
numOfRows
)
{
void
initResultSizeInfo
(
S
ResultInfo
*
pResultInfo
,
int32_t
numOfRows
)
{
ASSERT
(
numOfRows
!=
0
);
p
Operator
->
resultInfo
.
capacity
=
numOfRows
;
p
Operator
->
resultInfo
.
threshold
=
numOfRows
*
0
.
75
;
p
ResultInfo
->
capacity
=
numOfRows
;
p
ResultInfo
->
threshold
=
numOfRows
*
0
.
75
;
if
(
p
Operator
->
resultInfo
.
threshold
==
0
)
{
p
Operator
->
resultInfo
.
threshold
=
numOfRows
;
if
(
p
ResultInfo
->
threshold
==
0
)
{
p
ResultInfo
->
threshold
=
numOfRows
;
}
}
...
...
@@ -3672,7 +3674,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
int32_t
numOfRows
=
1024
;
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
initResultSizeInfo
(
pOperator
,
numOfRows
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
numOfRows
);
int32_t
code
=
initAggInfo
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
...
...
@@ -3827,7 +3829,7 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
if
(
numOfRows
*
pResBlock
->
info
.
rowSize
>
TWOMB
)
{
numOfRows
=
TWOMB
/
pResBlock
->
info
.
rowSize
;
}
initResultSizeInfo
(
pOperator
,
numOfRows
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
numOfRows
);
initAggInfo
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initBasicInfo
(
&
pInfo
->
binfo
,
pResBlock
);
...
...
@@ -4005,7 +4007,7 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
numOfRows
=
TWOMB
/
pResBlock
->
info
.
rowSize
;
}
initResultSizeInfo
(
pOperator
,
numOfRows
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
numOfRows
);
initAggInfo
(
pSup
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfExpr
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initBasicInfo
(
&
pInfo
->
binfo
,
pResBlock
);
...
...
@@ -4044,8 +4046,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
;
...
...
@@ -4082,7 +4083,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
int32_t
type
=
convertFillType
(
pPhyFillNode
->
mode
);
SResultInfo
*
pResultInfo
=
&
pOperator
->
resultInfo
;
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
pInfo
->
primaryTsCol
=
((
SColumnNode
*
)
pPhyFillNode
->
pWStartTs
)
->
slotId
;
int32_t
numOfOutputCols
=
0
;
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
e6febe45
...
...
@@ -406,7 +406,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
goto
_error
;
}
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
initAggInfo
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
pInfo
->
groupKeyLen
,
pTaskInfo
->
id
.
str
);
initBasicInfo
(
&
pInfo
->
binfo
,
pResultBlock
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
...
...
source/libs/executor/src/joinoperator.c
浏览文件 @
e6febe45
...
...
@@ -41,7 +41,7 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
int32_t
numOfCols
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pJoinNode
->
pTargets
,
NULL
,
&
numOfCols
);
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
pInfo
->
pRes
=
pResBlock
;
pOperator
->
name
=
"MergeJoinOperator"
;
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
e6febe45
...
...
@@ -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
)
{
...
...
@@ -2324,7 +2324,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
pInfo
->
pCondition
=
pScanNode
->
node
.
pConditions
;
pInfo
->
scanCols
=
colList
;
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
tNameAssign
(
&
pInfo
->
name
,
&
pScanNode
->
tableName
);
const
char
*
name
=
tNameGetTableName
(
&
pInfo
->
name
);
...
...
@@ -2554,7 +2554,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
pOperator
->
info
=
pInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
pOperator
->
fpSet
=
...
...
@@ -3099,7 +3099,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
pOperator
->
info
=
pInfo
;
pOperator
->
exprSupp
.
numOfExprs
=
numOfCols
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
initResultSizeInfo
(
pOperator
,
1024
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
1024
);
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doTableMergeScan
,
NULL
,
NULL
,
destroyTableMergeScanOperatorInfo
,
NULL
,
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
e6febe45
...
...
@@ -26,7 +26,7 @@ static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput);
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSortPhysiNode
*
pSortNode
,
SExecTaskInfo
*
pTaskInfo
)
{
SSortOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
/* || rowSize > 100 * 1024 * 1024*/
)
{
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
goto
_error
;
}
...
...
@@ -41,13 +41,15 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
extractColMatchInfo
(
pSortNode
->
pTargets
,
pDescNode
,
&
numOfOutputCols
,
COL_MATCH_FROM_SLOT_ID
);
pOperator
->
exprSupp
.
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pOperator
->
exprSupp
.
rowEntryInfoOffset
);
pInfo
->
binfo
.
pRes
=
pResBlock
;
initResultSizeInfo
(
pOperator
,
1024
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
1024
);
pInfo
->
pSortInfo
=
createSortInfo
(
pSortNode
->
pSortKeys
);
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
pSortInfo
=
createSortInfo
(
pSortNode
->
pSortKeys
);
pInfo
->
pCondition
=
pSortNode
->
node
.
pConditions
;
pInfo
->
pColMatchInfo
=
pColMatchColInfo
;
initLimitInfo
(
pSortNode
->
node
.
pLimit
,
pSortNode
->
node
.
pSlimit
,
&
pInfo
->
limitInfo
);
pOperator
->
name
=
"SortOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SORT
;
pOperator
->
blocking
=
true
;
...
...
@@ -208,26 +210,44 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) {
SSDataBlock
*
pBlock
=
NULL
;
while
(
1
)
{
pBlock
=
getSortedBlockData
(
pInfo
->
pSortHandle
,
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
,
pInfo
->
pColMatchInfo
,
pInfo
);
if
(
pBlock
!=
NULL
)
{
doFilter
(
pInfo
->
pCondition
,
pBlock
);
}
pInfo
->
pColMatchInfo
,
pInfo
);
if
(
pBlock
==
NULL
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
return
NULL
;
}
if
(
blockDataGetNumOfRows
(
pBlock
)
>
0
)
{
break
;
doFilter
(
pInfo
->
pCondition
,
pBlock
);
if
(
blockDataGetNumOfRows
(
pBlock
)
==
0
)
{
continue
;
}
}
if
(
pBlock
!=
NULL
)
{
pOperator
->
resultInfo
.
totalRows
+=
pBlock
->
info
.
rows
;
// todo add the limit/offset info
if
(
pInfo
->
limitInfo
.
remainOffset
>
0
)
{
if
(
pInfo
->
limitInfo
.
remainOffset
>=
blockDataGetNumOfRows
(
pBlock
))
{
pInfo
->
limitInfo
.
remainOffset
-=
pBlock
->
info
.
rows
;
continue
;
}
blockDataTrimFirstNRows
(
pBlock
,
pInfo
->
limitInfo
.
remainOffset
);
pInfo
->
limitInfo
.
remainOffset
=
0
;
}
if
(
pInfo
->
limitInfo
.
limit
.
limit
>
0
&&
pInfo
->
limitInfo
.
limit
.
limit
<=
pInfo
->
limitInfo
.
numOfOutputRows
+
blockDataGetNumOfRows
(
pBlock
))
{
int32_t
remain
=
pInfo
->
limitInfo
.
limit
.
limit
-
pInfo
->
limitInfo
.
numOfOutputRows
;
blockDataKeepFirstNRows
(
pBlock
,
remain
);
}
size_t
numOfRows
=
blockDataGetNumOfRows
(
pBlock
);
pInfo
->
limitInfo
.
numOfOutputRows
+=
numOfRows
;
pOperator
->
resultInfo
.
totalRows
+=
numOfRows
;
if
(
numOfRows
>
0
)
{
break
;
}
}
return
pBlock
;
return
blockDataGetNumOfRows
(
pBlock
)
>
0
?
pBlock
:
NULL
;
}
void
destroyOrderOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
...
...
@@ -479,7 +499,7 @@ SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSort
pOperator
->
exprSupp
.
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pOperator
->
exprSupp
.
rowEntryInfoOffset
);
pInfo
->
binfo
.
pRes
=
pResBlock
;
initResultSizeInfo
(
pOperator
,
1024
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
1024
);
pInfo
->
pSortInfo
=
createSortInfo
(
pSortPhyNode
->
pSortKeys
);
;
...
...
@@ -711,7 +731,7 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size
extractColMatchInfo
(
pMergePhyNode
->
pTargets
,
pDescNode
,
&
numOfOutputCols
,
COL_MATCH_FROM_SLOT_ID
);
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
0
);
SSDataBlock
*
pInputBlock
=
createResDataBlock
(
pChildNode
->
pOutputDataBlockDesc
);
initResultSizeInfo
(
pOperator
,
1024
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
1024
);
pInfo
->
groupSort
=
pMergePhyNode
->
groupSort
;
pInfo
->
binfo
.
pRes
=
pResBlock
;
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
e6febe45
...
...
@@ -1768,7 +1768,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
SExprSupp
*
pSup
=
&
pOperator
->
exprSupp
;
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
int32_t
code
=
initAggInfo
(
pSup
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initBasicInfo
(
&
pInfo
->
binfo
,
pResBlock
);
...
...
@@ -1849,7 +1849,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
int32_t
numOfRows
=
4096
;
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
initResultSizeInfo
(
pOperator
,
numOfRows
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
numOfRows
);
int32_t
code
=
initAggInfo
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initBasicInfo
(
&
pInfo
->
binfo
,
pResBlock
);
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pInfo
->
win
);
...
...
@@ -2309,7 +2309,7 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode
pInfo
->
tsCol
=
extractColumnFromColumnNode
((
SColumnNode
*
)
pInterpPhyNode
->
pTimeSeries
);
pInfo
->
fillType
=
convertFillType
(
pInterpPhyNode
->
fillMode
);
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
pInfo
->
pFillColInfo
=
createFillColInfo
(
pExprInfo
,
numOfExprs
,
(
SNodeListNode
*
)
pInterpPhyNode
->
pFillValues
);
pInfo
->
pRes
=
createResDataBlock
(
pPhyNode
->
pOutputDataBlockDesc
);
...
...
@@ -2357,7 +2357,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
initAggInfo
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExpr
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initBasicInfo
(
&
pInfo
->
binfo
,
pResBlock
);
...
...
@@ -2405,7 +2405,7 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
}
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
int32_t
code
=
initAggInfo
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -2981,7 +2981,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
ASSERT
(
pInfo
->
twAggSup
.
calTrigger
!=
STREAM_TRIGGER_MAX_DELAY
);
pInfo
->
primaryTsIndex
=
((
SColumnNode
*
)
pIntervalPhyNode
->
window
.
pTspk
)
->
slotId
;
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
if
(
pIntervalPhyNode
->
window
.
pExprs
!=
NULL
)
{
int32_t
numOfScalar
=
0
;
SExprInfo
*
pScalarExprInfo
=
createExprInfo
(
pIntervalPhyNode
->
window
.
pExprs
,
NULL
,
&
numOfScalar
);
...
...
@@ -3157,7 +3157,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
goto
_error
;
}
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
if
(
pSessionNode
->
window
.
pExprs
!=
NULL
)
{
int32_t
numOfScalar
=
0
;
SExprInfo
*
pScalarExprInfo
=
createExprInfo
(
pSessionNode
->
window
.
pExprs
,
NULL
,
&
numOfScalar
);
...
...
@@ -4421,7 +4421,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
SExprInfo
*
pExprInfo
=
createExprInfo
(
pStateNode
->
window
.
pFuncs
,
NULL
,
&
numOfCols
);
pInfo
->
stateCol
=
extractColumnFromColumnNode
(
pColNode
);
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
if
(
pStateNode
->
window
.
pExprs
!=
NULL
)
{
int32_t
numOfScalar
=
0
;
SExprInfo
*
pScalarExprInfo
=
createExprInfo
(
pStateNode
->
window
.
pExprs
,
NULL
,
&
numOfScalar
);
...
...
@@ -4671,7 +4671,7 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
iaInfo
->
primaryTsIndex
=
primaryTsSlotId
;
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
int32_t
code
=
initAggInfo
(
&
pOperator
->
exprSupp
,
&
iaInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
...
...
@@ -4977,7 +4977,7 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI
SExprSupp
*
pExprSupp
=
&
pOperator
->
exprSupp
;
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
int32_t
code
=
initAggInfo
(
pExprSupp
,
&
iaInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initBasicInfo
(
&
iaInfo
->
binfo
,
pResBlock
);
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
e6febe45
...
...
@@ -1195,7 +1195,7 @@ static void vectorMathTsSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pR
colDataAppendNULL
(
pOutputCol
,
i
);
continue
;
// TODO set null or ignore
}
*
output
=
taosTime
Sub
(
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
),
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
0
),
*
output
=
taosTime
Add
(
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
),
-
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
0
),
pRightCol
->
info
.
scale
,
pRightCol
->
info
.
precision
);
}
...
...
tests/script/tsim/query/interval-offset.sim
浏览文件 @
e6febe45
...
...
@@ -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
...
...
tests/script/tsim/scalar/scalar.sim
浏览文件 @
e6febe45
...
...
@@ -43,7 +43,8 @@ sql select cast(1 as timestamp)+1n;
if $rows != 1 then
return -1
endi
if $data00 != @70-02-01 08:00:00.000@ then
if $data00 != @70-02-01 08:00:00.001@ then
print expect 70-02-01 08:00:00.001, actual: $data00
return -1
endi
...
...
@@ -52,11 +53,13 @@ if $rows != 1 then
return -1
endi
sql select cast(1 as timestamp)-1y;
# there is an *bug* in print timestamp that smaller than 0, so let's try value that is greater than 0.
sql select cast(1 as timestamp)+1y;
if $rows != 1 then
return -1
endi
if $data00 != @69-01-01 08:00:00.000@ then
if $data00 != @71-01-01 08:00:00.001@ then
print expect 71-01-01 08:00:00.001 , actual: $data00
return -1
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录