Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
87efc517
T
TDengine
项目概览
loser646
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
87efc517
编写于
2月 12, 2020
作者:
L
lihui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TBASE-1462]
上级
5b4c77e3
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
642 addition
and
28 deletion
+642
-28
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+579
-16
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+30
-5
src/inc/tsqlfunction.h
src/inc/tsqlfunction.h
+9
-2
src/system/detail/inc/vnodeQueryImpl.h
src/system/detail/inc/vnodeQueryImpl.h
+1
-0
src/system/detail/src/vnodeQueryImpl.c
src/system/detail/src/vnodeQueryImpl.c
+20
-3
src/system/detail/src/vnodeQueryProcess.c
src/system/detail/src/vnodeQueryProcess.c
+2
-2
src/util/src/ttokenizer.c
src/util/src/ttokenizer.c
+1
-0
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
87efc517
此差异已折叠。
点击以展开。
src/client/src/tscSQLParser.c
浏览文件 @
87efc517
...
...
@@ -1122,7 +1122,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
if
(
addProjectionExprAndResultField
(
pQueryInfo
,
pItem
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_SQL
;
}
}
else
if
(
pItem
->
pNode
->
nSQLOptr
>=
TK_COUNT
&&
pItem
->
pNode
->
nSQLOptr
<=
TK_
LAST_ROW
)
{
}
else
if
(
pItem
->
pNode
->
nSQLOptr
>=
TK_COUNT
&&
pItem
->
pNode
->
nSQLOptr
<=
TK_
AVG_IRATE
)
{
// sql function in selection clause, append sql function info in pSqlCmd structure sequentially
if
(
addExprAndResultField
(
pQueryInfo
,
outputIndex
,
pItem
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_SQL
;
...
...
@@ -1504,6 +1504,12 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
}
case
TK_SUM
:
case
TK_AVG
:
case
TK_RATE
:
case
TK_IRATE
:
case
TK_SUM_RATE
:
case
TK_SUM_IRATE
:
case
TK_AVG_RATE
:
case
TK_AVG_IRATE
:
case
TK_TWA
:
case
TK_MIN
:
case
TK_MAX
:
...
...
@@ -1956,6 +1962,24 @@ int32_t changeFunctionID(int32_t optr, int16_t* functionId) {
case
TK_AVG
:
*
functionId
=
TSDB_FUNC_AVG
;
break
;
case
TK_RATE
:
*
functionId
=
TSDB_FUNC_RATE
;
break
;
case
TK_IRATE
:
*
functionId
=
TSDB_FUNC_IRATE
;
break
;
case
TK_SUM_RATE
:
*
functionId
=
TSDB_FUNC_SUM_RATE
;
break
;
case
TK_SUM_IRATE
:
*
functionId
=
TSDB_FUNC_SUM_IRATE
;
break
;
case
TK_AVG_RATE
:
*
functionId
=
TSDB_FUNC_AVG_RATE
;
break
;
case
TK_AVG_IRATE
:
*
functionId
=
TSDB_FUNC_AVG_IRATE
;
break
;
case
TK_MIN
:
*
functionId
=
TSDB_FUNC_MIN
;
break
;
...
...
@@ -2149,7 +2173,8 @@ int32_t tscTansformSQLFunctionForSTableQuery(SQueryInfo* pQueryInfo) {
int16_t
functionId
=
aAggs
[
pExpr
->
functionId
].
stableFuncId
;
if
((
functionId
>=
TSDB_FUNC_SUM
&&
functionId
<=
TSDB_FUNC_TWA
)
||
(
functionId
>=
TSDB_FUNC_FIRST_DST
&&
functionId
<=
TSDB_FUNC_LAST_DST
))
{
(
functionId
>=
TSDB_FUNC_FIRST_DST
&&
functionId
<=
TSDB_FUNC_LAST_DST
)
||
(
functionId
>=
TSDB_FUNC_RATE
&&
functionId
<=
TSDB_FUNC_AVG_IRATE
))
{
if
(
getResultDataInfo
(
pField
->
type
,
pField
->
bytes
,
functionId
,
pExpr
->
param
[
0
].
i64Key
,
&
type
,
&
bytes
,
&
intermediateBytes
,
0
,
true
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_SQL
;
...
...
@@ -2912,7 +2937,7 @@ static int32_t validateSQLExpr(tSQLExpr* pExpr, SQueryInfo* pQueryInfo, SColumnL
pList
->
ids
[
pList
->
num
++
]
=
index
;
}
else
if
(
pExpr
->
nSQLOptr
==
TK_FLOAT
&&
(
isnan
(
pExpr
->
val
.
dKey
)
||
isinf
(
pExpr
->
val
.
dKey
)))
{
return
TSDB_CODE_INVALID_SQL
;
}
else
if
(
pExpr
->
nSQLOptr
>=
TK_MIN
&&
pExpr
->
nSQLOptr
<=
TK_
LAST_ROW
)
{
}
else
if
(
pExpr
->
nSQLOptr
>=
TK_MIN
&&
pExpr
->
nSQLOptr
<=
TK_
AVG_IRATE
)
{
return
TSDB_CODE_INVALID_SQL
;
}
...
...
@@ -2966,8 +2991,8 @@ static bool isValidExpr(tSQLExpr* pLeft, tSQLExpr* pRight, int32_t optr) {
*
* However, columnA < 4+12 is valid
*/
if
((
pLeft
->
nSQLOptr
>=
TK_COUNT
&&
pLeft
->
nSQLOptr
<=
TK_
LAST_ROW
)
||
(
pRight
->
nSQLOptr
>=
TK_COUNT
&&
pRight
->
nSQLOptr
<=
TK_
LAST_ROW
)
||
if
((
pLeft
->
nSQLOptr
>=
TK_COUNT
&&
pLeft
->
nSQLOptr
<=
TK_
AVG_IRATE
)
||
(
pRight
->
nSQLOptr
>=
TK_COUNT
&&
pRight
->
nSQLOptr
<=
TK_
AVG_IRATE
)
||
(
pLeft
->
nSQLOptr
>=
TK_BOOL
&&
pLeft
->
nSQLOptr
<=
TK_BINARY
&&
pRight
->
nSQLOptr
>=
TK_BOOL
&&
pRight
->
nSQLOptr
<=
TK_BINARY
))
{
return
false
;
...
...
src/inc/tsqlfunction.h
浏览文件 @
87efc517
...
...
@@ -60,6 +60,13 @@ extern "C" {
#define TSDB_FUNC_LAST_DST 26
#define TSDB_FUNC_INTERP 27
#define TSDB_FUNC_RATE 28
#define TSDB_FUNC_IRATE 29
#define TSDB_FUNC_SUM_RATE 30
#define TSDB_FUNC_SUM_IRATE 31
#define TSDB_FUNC_AVG_RATE 32
#define TSDB_FUNC_AVG_IRATE 33
#define TSDB_FUNCSTATE_SO 0x1U // single output
#define TSDB_FUNCSTATE_MO 0x2U // dynamic number of output, not multinumber of output e.g., TOP/BOTTOM
#define TSDB_FUNCSTATE_STREAM 0x4U // function avail for stream
...
...
@@ -287,10 +294,10 @@ typedef struct STwaInfo {
}
STwaInfo
;
/* global sql function array */
extern
struct
SQLAggFuncElem
aAggs
[
28
];
extern
struct
SQLAggFuncElem
aAggs
[];
/* compatible check array list */
extern
int32_t
funcCompatDefList
[
28
];
extern
int32_t
funcCompatDefList
[];
void
getStatistics
(
char
*
priData
,
char
*
data
,
int32_t
size
,
int32_t
numOfRow
,
int32_t
type
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int32_t
*
numOfNull
);
...
...
src/system/detail/inc/vnodeQueryImpl.h
浏览文件 @
87efc517
...
...
@@ -126,6 +126,7 @@ static FORCE_INLINE SMeterObj* getMeterObj(void* hashHandle, int32_t sid) {
bool
isQueryKilled
(
SQuery
*
pQuery
);
bool
isFixedOutputQuery
(
SQuery
*
pQuery
);
bool
isPointInterpoQuery
(
SQuery
*
pQuery
);
bool
isSumAvgRateQuery
(
SQuery
*
pQuery
);
bool
isTopBottomQuery
(
SQuery
*
pQuery
);
bool
isFirstLastRowQuery
(
SQuery
*
pQuery
);
bool
isTSCompQuery
(
SQuery
*
pQuery
);
...
...
src/system/detail/src/vnodeQueryImpl.c
浏览文件 @
87efc517
...
...
@@ -2438,8 +2438,9 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, int64_t startQueryTimes
// store the first&last timestamp into the intermediate buffer [1], the true
// value may be null but timestamp will never be null
pCtx
->
ptsList
=
(
int64_t
*
)(
primaryColumnData
+
startOffset
*
TSDB_KEYSIZE
);
}
else
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_TWA
||
functionId
==
TSDB_FUNC_DIFF
)
{
}
else
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_TWA
||
functionId
==
TSDB_FUNC_DIFF
||
(
functionId
>=
TSDB_FUNC_RATE
&&
functionId
<=
TSDB_FUNC_AVG_IRATE
))
{
/*
* leastsquares function needs two columns of input, currently, the x value of linear equation is set to
* timestamp column, and the y-value is the column specified in pQuery->pSelectExpr[i].colIdxInBuffer
...
...
@@ -2723,6 +2724,22 @@ bool isPointInterpoQuery(SQuery *pQuery) {
}
// TODO REFACTOR:MERGE WITH CLIENT-SIDE FUNCTION
bool
isSumAvgRateQuery
(
SQuery
*
pQuery
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutputCols
;
++
i
)
{
int32_t
functionId
=
pQuery
->
pSelectExpr
[
i
].
pBase
.
functionId
;
if
(
functionId
==
TSDB_FUNC_TS
)
{
continue
;
}
if
(
functionId
==
TSDB_FUNC_SUM_RATE
||
functionId
==
TSDB_FUNC_SUM_IRATE
||
functionId
==
TSDB_FUNC_AVG_RATE
||
functionId
==
TSDB_FUNC_AVG_IRATE
)
{
return
true
;
}
}
return
false
;
}
bool
isTopBottomQuery
(
SQuery
*
pQuery
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutputCols
;
++
i
)
{
int32_t
functionId
=
pQuery
->
pSelectExpr
[
i
].
pBase
.
functionId
;
...
...
@@ -4584,7 +4601,7 @@ int32_t vnodeMultiMeterQueryPrepare(SQInfo *pQInfo, SQuery *pQuery, void *param)
initSlidingWindowInfo
(
&
pRuntimeEnv
->
swindowResInfo
,
4096
,
type
,
pQuery
->
rowSize
,
pSupporter
->
pResult
);
}
if
(
pQuery
->
nAggTimeInterval
!=
0
)
{
if
(
pQuery
->
nAggTimeInterval
!=
0
||
isSumAvgRateQuery
(
pQuery
)
)
{
// one page for each table at least
ret
=
createResultBuf
(
&
pRuntimeEnv
->
pResultBuf
,
pSupporter
->
numOfMeters
,
pQuery
->
rowSize
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
...
...
src/system/detail/src/vnodeQueryProcess.c
浏览文件 @
87efc517
...
...
@@ -398,7 +398,7 @@ static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo
restoreIntervalQueryRange
(
pRuntimeEnv
,
pMeterQueryInfo
);
if
(
pQuery
->
nAggTimeInterval
==
0
)
{
// normal query
if
(
pQuery
->
nAggTimeInterval
==
0
&&
!
isSumAvgRateQuery
(
pQuery
)
)
{
// normal query
if
((
pQuery
->
lastKey
>
pQuery
->
ekey
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
(
pQuery
->
lastKey
<
pQuery
->
ekey
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
qTrace
(
...
...
@@ -964,7 +964,7 @@ static void vnodeMultiMeterQueryProcessor(SQInfo *pQInfo) {
return
;
}
if
(
pQuery
->
nAggTimeInterval
>
0
)
{
if
(
pQuery
->
nAggTimeInterval
>
0
||
isSumAvgRateQuery
(
pQuery
)
)
{
assert
(
pSupporter
->
subgroupIdx
==
0
&&
pSupporter
->
numOfGroupResultPages
==
0
);
if
(
mergeMetersResultToOneGroups
(
pSupporter
)
==
TSDB_CODE_SUCCESS
)
{
...
...
src/util/src/ttokenizer.c
浏览文件 @
87efc517
...
...
@@ -231,6 +231,7 @@ static SKeyword keywordTable[] = {
{
"RATE"
,
TK_RATE
},
{
"IRATE"
,
TK_IRATE
},
{
"SUM_RATE"
,
TK_SUM_RATE
},
{
"SUM_IRATE"
,
TK_SUM_IRATE
},
{
"AVG_RATE"
,
TK_AVG_RATE
},
{
"AVG_IRATE"
,
TK_AVG_IRATE
},
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录