Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1036259a
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看板
提交
1036259a
编写于
6月 01, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): fix error in fill.
上级
706e3502
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
69 addition
and
22 deletion
+69
-22
source/common/src/ttime.c
source/common/src/ttime.c
+1
-0
source/libs/executor/src/filloperator.c
source/libs/executor/src/filloperator.c
+65
-22
tests/script/tsim/parser/function.sim
tests/script/tsim/parser/function.sim
+3
-0
未找到文件。
source/common/src/ttime.c
浏览文件 @
1036259a
...
...
@@ -738,6 +738,7 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char
ekey
=
skey
;
skey
=
tmp
;
}
if
(
unit
!=
'n'
&&
unit
!=
'y'
)
{
return
(
int32_t
)((
ekey
-
skey
)
/
interval
);
}
...
...
source/libs/executor/src/filloperator.c
浏览文件 @
1036259a
...
...
@@ -61,6 +61,7 @@ typedef struct SFillOperatorInfo {
SExprSupp
noFillExprSupp
;
}
SFillOperatorInfo
;
static
void
revisedFillStartKey
(
SFillOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
);
static
void
destroyFillOperatorInfo
(
void
*
param
);
static
void
doApplyScalarCalculation
(
SOperatorInfo
*
pOperator
,
SSDataBlock
*
pBlock
,
int32_t
order
,
int32_t
scanFlag
);
...
...
@@ -72,14 +73,16 @@ static void doHandleRemainBlockForNewGroupImpl(SOperatorInfo* pOperator, SFillOp
int32_t
order
=
TSDB_ORDER_ASC
;
int32_t
scanFlag
=
MAIN_SCAN
;
getTableScanInfo
(
pOperator
,
&
order
,
&
scanFlag
,
false
);
int64_t
ekey
=
pInfo
->
existNewGroupBlock
->
info
.
window
.
ekey
;
taosResetFillInfo
(
pInfo
->
pFillInfo
,
getFillInfoStart
(
pInfo
->
pFillInfo
));
blockDataCleanup
(
pInfo
->
pRes
);
doApplyScalarCalculation
(
pOperator
,
pInfo
->
existNewGroupBlock
,
order
,
scanFlag
);
taosFillSetStartInfo
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
->
info
.
rows
,
ekey
);
revisedFillStartKey
(
pInfo
,
pInfo
->
existNewGroupBlock
);
int64_t
ts
=
(
order
==
TSDB_ORDER_ASC
)
?
pInfo
->
existNewGroupBlock
->
info
.
window
.
ekey
:
pInfo
->
existNewGroupBlock
->
info
.
window
.
skey
;
taosFillSetStartInfo
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
->
info
.
rows
,
ts
);
taosFillSetInputDataBlock
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
);
int32_t
numOfResultRows
=
pResultInfo
->
capacity
-
pResBlock
->
info
.
rows
;
...
...
@@ -119,6 +122,55 @@ void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int
pInfo
->
pRes
->
info
.
id
.
groupId
=
pBlock
->
info
.
id
.
groupId
;
}
// todo refactor: decide the start key according to the query time range.
static
void
revisedFillStartKey
(
SFillOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
)
{
int32_t
order
=
pInfo
->
pFillInfo
->
order
;
if
(
order
==
TSDB_ORDER_ASC
)
{
int64_t
skey
=
pBlock
->
info
.
window
.
skey
;
if
(
skey
<
pInfo
->
pFillInfo
->
start
)
{
// the start key may be smaller than the
ASSERT
(
taosFillNotStarted
(
pInfo
->
pFillInfo
));
taosFillUpdateStartTimestampInfo
(
pInfo
->
pFillInfo
,
skey
);
}
else
if
(
pInfo
->
pFillInfo
->
start
<
skey
)
{
int64_t
t
=
skey
;
SInterval
*
pInterval
=
&
pInfo
->
pFillInfo
->
interval
;
while
(
1
)
{
int64_t
prev
=
taosTimeAdd
(
t
,
-
pInterval
->
sliding
,
pInterval
->
slidingUnit
,
pInterval
->
precision
);
if
(
prev
<
pInfo
->
pFillInfo
->
start
)
{
t
=
prev
;
break
;
}
t
=
prev
;
}
// todo time window chosen problem: t or prev value?
taosFillUpdateStartTimestampInfo
(
pInfo
->
pFillInfo
,
t
);
}
}
else
{
int64_t
ekey
=
pBlock
->
info
.
window
.
ekey
;
if
(
ekey
>
pInfo
->
pFillInfo
->
start
)
{
ASSERT
(
taosFillNotStarted
(
pInfo
->
pFillInfo
));
taosFillUpdateStartTimestampInfo
(
pInfo
->
pFillInfo
,
ekey
);
}
else
if
(
ekey
<
pInfo
->
pFillInfo
->
start
)
{
int64_t
t
=
ekey
;
SInterval
*
pInterval
=
&
pInfo
->
pFillInfo
->
interval
;
while
(
1
)
{
int64_t
prev
=
taosTimeAdd
(
t
,
pInterval
->
sliding
,
pInterval
->
slidingUnit
,
pInterval
->
precision
);
if
(
prev
<
pInfo
->
pFillInfo
->
start
)
{
t
=
prev
;
break
;
}
t
=
prev
;
}
// todo time window chosen problem: t or prev value?
taosFillUpdateStartTimestampInfo
(
pInfo
->
pFillInfo
,
t
);
}
}
}
static
SSDataBlock
*
doFillImpl
(
SOperatorInfo
*
pOperator
)
{
SFillOperatorInfo
*
pInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
...
...
@@ -164,28 +216,16 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
blockDataEnsureCapacity
(
pInfo
->
pFinalRes
,
pBlock
->
info
.
rows
);
doApplyScalarCalculation
(
pOperator
,
pBlock
,
order
,
scanFlag
);
if
(
pInfo
->
curGroupId
==
0
||
pInfo
->
curGroupId
==
pInfo
->
pRes
->
info
.
id
.
groupId
)
{
if
(
pInfo
->
curGroupId
==
0
||
(
pInfo
->
curGroupId
==
pInfo
->
pRes
->
info
.
id
.
groupId
))
{
if
(
pInfo
->
curGroupId
==
0
)
{
revisedFillStartKey
(
pInfo
,
pBlock
);
}
pInfo
->
curGroupId
=
pInfo
->
pRes
->
info
.
id
.
groupId
;
// the first data block
pInfo
->
totalInputRows
+=
pInfo
->
pRes
->
info
.
rows
;
if
(
order
==
TSDB_ORDER_ASC
)
{
int64_t
skey
=
pBlock
->
info
.
window
.
skey
;
if
(
skey
<
pInfo
->
pFillInfo
->
start
)
{
// the start key may be smaller than the
ASSERT
(
taosFillNotStarted
(
pInfo
->
pFillInfo
));
taosFillUpdateStartTimestampInfo
(
pInfo
->
pFillInfo
,
skey
);
}
taosFillSetStartInfo
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
->
info
.
rows
,
pBlock
->
info
.
window
.
ekey
);
}
else
{
int64_t
ekey
=
pBlock
->
info
.
window
.
ekey
;
if
(
ekey
>
pInfo
->
pFillInfo
->
start
)
{
ASSERT
(
taosFillNotStarted
(
pInfo
->
pFillInfo
));
taosFillUpdateStartTimestampInfo
(
pInfo
->
pFillInfo
,
ekey
);
}
taosFillSetStartInfo
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
->
info
.
rows
,
pBlock
->
info
.
window
.
skey
);
}
int64_t
ts
=
(
order
==
TSDB_ORDER_ASC
)
?
pBlock
->
info
.
window
.
ekey
:
pBlock
->
info
.
window
.
skey
;
taosFillSetStartInfo
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
->
info
.
rows
,
ts
);
taosFillSetInputDataBlock
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
);
}
else
if
(
pInfo
->
curGroupId
!=
pBlock
->
info
.
id
.
groupId
)
{
// the new group data block
pInfo
->
existNewGroupBlock
=
pBlock
;
...
...
@@ -276,6 +316,9 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
SFillColInfo
*
pColInfo
=
createFillColInfo
(
pExpr
,
numOfCols
,
pNotFillExpr
,
numOfNotFillCols
,
pValNode
);
int64_t
startKey
=
(
order
==
TSDB_ORDER_ASC
)
?
win
.
skey
:
win
.
ekey
;
// STimeWindow w = {0};
// getInitialStartTimeWindow(pInterval, startKey, &w, order == TSDB_ORDER_ASC);
pInfo
->
pFillInfo
=
taosCreateFillInfo
(
startKey
,
numOfCols
,
numOfNotFillCols
,
capacity
,
pInterval
,
fillType
,
pColInfo
,
pInfo
->
primaryTsCol
,
order
,
id
);
...
...
tests/script/tsim/parser/function.sim
浏览文件 @
1036259a
...
...
@@ -954,11 +954,14 @@ endi
print =========================>TD-5190
sql select _wstart, stddev(f1) from st1 where ts>'2021-07-01 1:1:1' and ts<'2021-07-30 00:00:00' interval(1d) fill(NULL);
if $rows != 29 then
print expect 29, actual: $rows
return -1
endi
if $data00 != @21-07-01 00:00:00.000@ then
return -1
endi
if $data01 != NULL then
return -1
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录