Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
327c2150
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看板
提交
327c2150
编写于
3月 08, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-11216]<feature>: Time window related keywords
上级
71e5094f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
14 deletion
+22
-14
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+2
-3
src/inc/taosdef.h
src/inc/taosdef.h
+2
-0
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+11
-3
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+6
-7
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
327c2150
...
...
@@ -2478,7 +2478,7 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
}
//for tbname and other pseudo columns
if
(
index
.
columnIndex
<=
TSDB_TBNAME_COLUMN_INDEX
&&
index
.
columnIndex
>=
TSDB_MIN_VALID_COLUMN_INDEX
)
{
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
||
TSDB_COL_IS_TSWIN_COL
(
index
.
columnIndex
)
)
{
if
(
outerQuery
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
index
.
tableIndex
);
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
...
...
src/client/src/tscUtil.c
浏览文件 @
327c2150
...
...
@@ -2551,8 +2551,7 @@ SExprInfo* tscExprCreate(STableMetaInfo* pTableMetaInfo, int16_t functionId, SCo
p
->
colInfo
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
;
p
->
colBytes
=
s
->
bytes
;
p
->
colType
=
s
->
type
;
}
else
if
(
pColIndex
->
columnIndex
<
TSDB_TBNAME_COLUMN_INDEX
&&
pColIndex
->
columnIndex
>=
TSDB_MIN_VALID_COLUMN_INDEX
)
{
}
else
if
(
TSDB_COL_IS_TSWIN_COL
(
pColIndex
->
columnIndex
))
{
SSchema
*
s
=
tGetTimeWindowColumnSchema
(
pColIndex
->
columnIndex
);
p
->
colInfo
.
colId
=
s
->
colId
;
p
->
colBytes
=
s
->
bytes
;
...
...
@@ -3079,7 +3078,7 @@ bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId) {
return
false
;
}
if
(
(
colId
<=
TSDB_TBNAME_COLUMN_INDEX
&&
colId
>=
TSDB_MIN_VALID_COLUMN_INDEX
)
||
if
(
colId
==
TSDB_TBNAME_COLUMN_INDEX
||
TSDB_COL_IS_TSWIN_COL
(
colId
)
||
colId
<=
TSDB_UD_COLUMN_INDEX
)
{
return
true
;
}
...
...
src/inc/taosdef.h
浏览文件 @
327c2150
...
...
@@ -282,6 +282,8 @@ do { \
#define TSDB_TSWIN_DURATION_COLUMN_INDEX (-4)
#define TSDB_MIN_VALID_COLUMN_INDEX (-4)
#define TSDB_COL_IS_TSWIN_COL(_i) ((_i) <= TSDB_TSWIN_START_COLUMN_INDEX && (_i) >= TSDB_TSWIN_DURATION_COLUMN_INDEX)
#define TSDB_UD_COLUMN_INDEX (-1000)
#define TSDB_RES_COL_ID (-5000)
...
...
src/query/src/qAggMain.c
浏览文件 @
327c2150
...
...
@@ -5662,6 +5662,14 @@ static void wduration_function(SQLFunctionCtx *pCtx) {
*
(
int64_t
*
)(
pCtx
->
pOutput
)
=
duration
;
}
static
void
tswin_function_finalizer
(
SQLFunctionCtx
*
pCtx
)
{
SET_VAL
(
pCtx
,
pCtx
->
size
,
1
);
if
(
pCtx
->
stableQuery
)
{
*
(
int64_t
*
)(
pCtx
->
pOutput
)
=
*
(
int64_t
*
)
pCtx
->
pInput
;
}
doFinalizer
(
pCtx
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
/*
* function compatible list.
...
...
@@ -6201,7 +6209,7 @@ SAggFunctionInfo aAggs[TSDB_FUNC_MAX_NUM] = {{
TSDB_BASE_FUNC_SO
|
TSDB_FUNCSTATE_SELECTIVITY
,
function_setup
,
wstart_function
,
noop1
,
tswin_function_finalizer
,
noop1
,
dataBlockRequired
,
},
...
...
@@ -6213,7 +6221,7 @@ SAggFunctionInfo aAggs[TSDB_FUNC_MAX_NUM] = {{
TSDB_BASE_FUNC_SO
|
TSDB_FUNCSTATE_SELECTIVITY
,
function_setup
,
wstop_function
,
noop1
,
tswin_function_finalizer
,
noop1
,
dataBlockRequired
,
},
...
...
@@ -6225,7 +6233,7 @@ SAggFunctionInfo aAggs[TSDB_FUNC_MAX_NUM] = {{
TSDB_BASE_FUNC_SO
|
TSDB_FUNCSTATE_SELECTIVITY
,
function_setup
,
wduration_function
,
noop1
,
tswin_function_finalizer
,
noop1
,
dataBlockRequired
,
}
...
...
src/query/src/qExecutor.c
浏览文件 @
327c2150
...
...
@@ -462,7 +462,7 @@ static bool isProjQuery(SQueryAttr *pQueryAttr) {
static
bool
hasNull
(
SColIndex
*
pColIndex
,
SDataStatis
*
pStatis
)
{
if
(
TSDB_COL_IS_TAG
(
pColIndex
->
flag
)
||
TSDB_COL_IS_UD_COL
(
pColIndex
->
flag
)
||
pColIndex
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
||
pColIndex
->
colId
<
TSDB_TBNAME_COLUMN
_INDEX
)
{
TSDB_COL_IS_TSWIN_COL
(
pColIndex
->
colId
)
||
pColIndex
->
colId
==
PRIMARYKEY_TIMESTAMP_COL
_INDEX
)
{
return
false
;
}
...
...
@@ -1192,7 +1192,7 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx,
setArithParams
((
SScalarExprSupport
*
)
pCtx
[
i
].
param
[
1
].
pz
,
&
pOperator
->
pExpr
[
i
],
pBlock
);
}
else
{
SColIndex
*
pCol
=
&
pOperator
->
pExpr
[
i
].
base
.
colInfo
;
if
((
TSDB_COL_IS_NORMAL_COL
(
pCol
->
flag
)
&&
pCol
->
colId
>=
0
)
||
(
pCtx
[
i
].
functionId
==
TSDB_FUNC_BLKINFO
)
||
if
((
TSDB_COL_IS_NORMAL_COL
(
pCol
->
flag
)
&&
!
TSDB_COL_IS_TSWIN_COL
(
pCol
->
colId
)
)
||
(
pCtx
[
i
].
functionId
==
TSDB_FUNC_BLKINFO
)
||
(
TSDB_COL_IS_TAG
(
pCol
->
flag
)
&&
pOperator
->
pRuntimeEnv
->
scanFlag
==
MERGE_STAGE
))
{
SColIndex
*
pColIndex
=
&
pOperator
->
pExpr
[
i
].
base
.
colInfo
;
SColumnInfoData
*
p
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pColIndex
->
colIndex
);
...
...
@@ -1844,7 +1844,7 @@ static bool functionNeedToExecute(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx
void
setBlockStatisInfo
(
SQLFunctionCtx
*
pCtx
,
SSDataBlock
*
pSDataBlock
,
SColIndex
*
pColIndex
)
{
SDataStatis
*
pStatis
=
NULL
;
if
(
pSDataBlock
->
pBlockStatis
!=
NULL
&&
TSDB_COL_IS_NORMAL_COL
(
pColIndex
->
flag
)
&&
pColIndex
->
colId
>=
0
)
{
if
(
pSDataBlock
->
pBlockStatis
!=
NULL
&&
TSDB_COL_IS_NORMAL_COL
(
pColIndex
->
flag
)
&&
!
TSDB_COL_IS_TSWIN_COL
(
pColIndex
->
colId
)
)
{
pStatis
=
&
pSDataBlock
->
pBlockStatis
[
pColIndex
->
colIndex
];
pCtx
->
preAggVals
.
statis
=
*
pStatis
;
...
...
@@ -8391,8 +8391,8 @@ static int32_t getColumnIndexInSource(SQueriedTableInfo *pTableInfo, SSqlExpr *p
int32_t
j
=
0
;
if
(
TSDB_COL_IS_TAG
(
pExpr
->
colInfo
.
flag
))
{
if
(
pExpr
->
colInfo
.
colId
<=
TSDB_TBNAME_COLUMN_INDEX
&&
pExpr
->
colInfo
.
colId
>=
TSDB_MIN_VALID_COLUMN_INDEX
)
{
if
(
pExpr
->
colInfo
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
||
TSDB_COL_IS_TSWIN_COL
(
pExpr
->
colInfo
.
colId
)
)
{
return
pExpr
->
colInfo
.
colId
;
}
...
...
@@ -9176,8 +9176,7 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp
SSchema
*
s
=
tGetTbnameColumnSchema
();
type
=
s
->
type
;
bytes
=
s
->
bytes
;
}
else
if
(
pExprs
[
i
].
base
.
colInfo
.
colId
<
TSDB_TBNAME_COLUMN_INDEX
&&
pExprs
[
i
].
base
.
colInfo
.
colId
>=
TSDB_MIN_VALID_COLUMN_INDEX
&&
}
else
if
(
TSDB_COL_IS_TSWIN_COL
(
pExprs
[
i
].
base
.
colInfo
.
colId
)
&&
(
pExprs
[
i
].
base
.
functionId
>=
TSDB_FUNC_WSTART
||
pExprs
[
i
].
base
.
functionId
<=
TSDB_FUNC_WDURATION
))
{
SSchema
*
s
=
tGetTimeWindowColumnSchema
(
pExprs
[
i
].
base
.
colInfo
.
colId
);
type
=
s
->
type
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录