Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c5de6896
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看板
提交
c5de6896
编写于
3月 11, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-11216]<feature>: Time window related keywords add
_qstart/_qstop/_qduration
上级
96389bba
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
17 deletion
+29
-17
src/query/inc/qAggMain.h
src/query/inc/qAggMain.h
+1
-0
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+12
-6
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+16
-11
未找到文件。
src/query/inc/qAggMain.h
浏览文件 @
c5de6896
...
...
@@ -215,6 +215,7 @@ typedef struct SQLFunctionCtx {
SHashObj
**
pUniqueSet
;
// for unique function
SHashObj
**
pModeSet
;
// for mode function
STimeWindow
qWindow
;
// for _qstart/_qstop/_qduration column
int32_t
allocRows
;
// rows allocated for output buffer
}
SQLFunctionCtx
;
typedef
struct
SAggFunctionInfo
{
...
...
src/query/src/qAggMain.c
浏览文件 @
c5de6896
...
...
@@ -5811,9 +5811,11 @@ static void window_start_function(SQLFunctionCtx *pCtx) {
SET_VAL
(
pCtx
,
pCtx
->
size
,
1
);
*
(
int64_t
*
)(
pCtx
->
pOutput
)
=
pCtx
->
startTs
;
}
else
{
//TSDB_FUNC_QSTART
INC_INIT_VAL
(
pCtx
,
pCtx
->
size
);
int32_t
size
=
MIN
(
pCtx
->
size
,
pCtx
->
allocRows
);
//size cannot exceeds allocated rows
SET_VAL
(
pCtx
,
pCtx
->
size
,
size
);
//INC_INIT_VAL(pCtx, size);
char
*
output
=
pCtx
->
pOutput
;
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
if
(
pCtx
->
qWindow
.
skey
==
INT64_MIN
)
{
*
(
TKEY
*
)
output
=
TSDB_DATA_TIMESTAMP_NULL
;
}
else
{
...
...
@@ -5829,9 +5831,11 @@ static void window_stop_function(SQLFunctionCtx *pCtx) {
SET_VAL
(
pCtx
,
pCtx
->
size
,
1
);
*
(
int64_t
*
)(
pCtx
->
pOutput
)
=
pCtx
->
endTs
;
}
else
{
//TSDB_FUNC_QSTOP
INC_INIT_VAL
(
pCtx
,
pCtx
->
size
);
int32_t
size
=
MIN
(
pCtx
->
size
,
pCtx
->
allocRows
);
//size cannot exceeds allocated rows
SET_VAL
(
pCtx
,
pCtx
->
size
,
size
);
//INC_INIT_VAL(pCtx, size);
char
*
output
=
pCtx
->
pOutput
;
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
if
(
pCtx
->
qWindow
.
ekey
==
INT64_MAX
)
{
*
(
TKEY
*
)
output
=
TSDB_DATA_TIMESTAMP_NULL
;
}
else
{
...
...
@@ -5852,13 +5856,15 @@ static void window_duration_function(SQLFunctionCtx *pCtx) {
}
*
(
int64_t
*
)(
pCtx
->
pOutput
)
=
duration
;
}
else
{
//TSDB_FUNC_QDURATION
INC_INIT_VAL
(
pCtx
,
pCtx
->
size
);
int32_t
size
=
MIN
(
pCtx
->
size
,
pCtx
->
allocRows
);
//size cannot exceeds allocated rows
SET_VAL
(
pCtx
,
pCtx
->
size
,
size
);
//INC_INIT_VAL(pCtx, size);
duration
=
pCtx
->
qWindow
.
ekey
-
pCtx
->
qWindow
.
skey
;
if
(
duration
<
0
)
{
duration
=
-
duration
;
}
char
*
output
=
pCtx
->
pOutput
;
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
if
(
pCtx
->
qWindow
.
skey
==
INT64_MIN
||
pCtx
->
qWindow
.
ekey
==
INT64_MAX
)
{
*
(
int64_t
*
)
output
=
TSDB_DATA_BIGINT_NULL
;
}
else
{
...
...
src/query/src/qExecutor.c
浏览文件 @
c5de6896
...
...
@@ -1908,7 +1908,7 @@ static int32_t setCtxTagColumnInfo(SQLFunctionCtx *pCtx, int32_t numOfOutput) {
}
static
SQLFunctionCtx
*
createSQLFunctionCtx
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
int32_t
**
rowCellInfoOffset
)
{
int32_t
**
rowCellInfoOffset
,
int32_t
numOfRows
)
{
SQueryAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
SQLFunctionCtx
*
pFuncCtx
=
(
SQLFunctionCtx
*
)
calloc
(
numOfOutput
,
sizeof
(
SQLFunctionCtx
));
...
...
@@ -1959,6 +1959,7 @@ static SQLFunctionCtx* createSQLFunctionCtx(SQueryRuntimeEnv* pRuntimeEnv, SExpr
pCtx
->
startTs
=
INT64_MIN
;
pCtx
->
qWindow
=
pQueryAttr
->
window
;
pCtx
->
allocRows
=
numOfRows
;
pCtx
->
numOfParams
=
pSqlExpr
->
numOfParams
;
for
(
int32_t
j
=
0
;
j
<
pCtx
->
numOfParams
;
++
j
)
{
...
...
@@ -5643,7 +5644,8 @@ SOperatorInfo* createGlobalAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv,
pInfo
->
bufCapacity
=
200
;
// TD-10899
pInfo
->
udfInfo
=
pUdfInfo
;
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pInfo
->
bufCapacity
*
pInfo
->
resultRowFactor
);
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
,
pInfo
->
bufCapacity
*
pInfo
->
resultRowFactor
);
pInfo
->
orderColumnList
=
getOrderCheckColumns
(
pRuntimeEnv
->
pQueryAttr
);
pInfo
->
groupColumnList
=
getResultGroupCheckColumns
(
pRuntimeEnv
->
pQueryAttr
);
...
...
@@ -7284,7 +7286,7 @@ SOperatorInfo* createAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOpera
int32_t
numOfRows
=
(
int32_t
)(
getRowNumForMultioutput
(
pQueryAttr
,
pQueryAttr
->
topBotQuery
,
pQueryAttr
->
stableQuery
));
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
numOfRows
);
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
,
numOfRows
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
,
TSDB_DATA_TYPE_INT
);
...
...
@@ -7456,7 +7458,7 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SO
size_t
tableGroup
=
GET_NUM_OF_TABLEGROUP
(
pRuntimeEnv
);
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
(
int32_t
)
tableGroup
);
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
,
(
int32_t
)
tableGroup
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
(
int32_t
)
tableGroup
,
TSDB_DATA_TYPE_INT
);
if
(
pInfo
->
binfo
.
pRes
==
NULL
||
pInfo
->
binfo
.
pCtx
==
NULL
||
pInfo
->
binfo
.
resultRowInfo
.
pResult
==
NULL
)
{
...
...
@@ -7501,7 +7503,7 @@ SOperatorInfo* createProjectOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperato
SOptrBasicInfo
*
pBInfo
=
&
pInfo
->
binfo
;
pBInfo
->
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pInfo
->
bufCapacity
);
pBInfo
->
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pBInfo
->
rowCellInfoOffset
);
pBInfo
->
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pBInfo
->
rowCellInfoOffset
,
pInfo
->
bufCapacity
);
initResultRowInfo
(
&
pBInfo
->
resultRowInfo
,
8
,
TSDB_DATA_TYPE_INT
);
...
...
@@ -7636,7 +7638,7 @@ SOperatorInfo* createTimeIntervalOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOp
return
NULL
;
}
pInfo
->
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
rowCellInfoOffset
);
pInfo
->
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
rowCellInfoOffset
,
pRuntimeEnv
->
resultInfo
.
capacity
);
pInfo
->
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pRuntimeEnv
->
resultInfo
.
capacity
);
initResultRowInfo
(
&
pInfo
->
resultRowInfo
,
8
,
TSDB_DATA_TYPE_INT
);
...
...
@@ -7686,7 +7688,7 @@ SOperatorInfo* createTimeEveryOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOpera
SOptrBasicInfo
*
pBInfo
=
&
pInfo
->
binfo
;
pBInfo
->
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pInfo
->
bufCapacity
);
pBInfo
->
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pBInfo
->
rowCellInfoOffset
);
pBInfo
->
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pBInfo
->
rowCellInfoOffset
,
pInfo
->
bufCapacity
);
if
(
pQueryAttr
->
needReverseScan
)
{
pInfo
->
rangeStart
=
taosHashInit
(
256
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_TIMESTAMP
),
false
,
false
);
...
...
@@ -7738,7 +7740,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOpe
pInfo
->
colIndex
=
-
1
;
pInfo
->
reptScan
=
false
;
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
,
pRuntimeEnv
->
resultInfo
.
capacity
);
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pRuntimeEnv
->
resultInfo
.
capacity
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
,
TSDB_DATA_TYPE_INT
);
...
...
@@ -7778,7 +7781,8 @@ SOperatorInfo* createSWindowOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperato
return
NULL
;
}
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
,
pRuntimeEnv
->
resultInfo
.
capacity
);
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pRuntimeEnv
->
resultInfo
.
capacity
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
,
TSDB_DATA_TYPE_INT
);
...
...
@@ -7820,7 +7824,7 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(SQueryRuntimeEnv* pRunti
return
NULL
;
}
pInfo
->
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
rowCellInfoOffset
);
pInfo
->
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
rowCellInfoOffset
,
pRuntimeEnv
->
resultInfo
.
capacity
);
pInfo
->
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pRuntimeEnv
->
resultInfo
.
capacity
);
initResultRowInfo
(
&
pInfo
->
resultRowInfo
,
8
,
TSDB_DATA_TYPE_INT
);
...
...
@@ -7863,7 +7867,8 @@ SOperatorInfo* createGroupbyOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperato
}
pInfo
->
colIndex
=
-
1
;
// group by column index
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
,
pRuntimeEnv
->
resultInfo
.
capacity
);
SQueryAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录