Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
b364ae65
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
未验证
提交
b364ae65
编写于
6月 18, 2021
作者:
H
Haojun Liao
提交者:
GitHub
6月 18, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6519 from taosdata/feature/query
[td-4739]<fix>: fix bug in derivative.
上级
155b4a66
bd1b2a84
变更
16
显示空白变更内容
内联
并排
Showing
16 changed file
with
148 addition
and
106 deletion
+148
-106
src/balance/src/bnMain.c
src/balance/src/bnMain.c
+1
-0
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+2
-0
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+5
-5
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+66
-75
src/client/src/tscSub.c
src/client/src/tscSub.c
+15
-9
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+4
-4
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+17
-0
src/connector/jdbc/CMakeLists.txt
src/connector/jdbc/CMakeLists.txt
+1
-1
src/dnode/inc/dnodeCfg.h
src/dnode/inc/dnodeCfg.h
+1
-0
src/dnode/src/dnodeCfg.c
src/dnode/src/dnodeCfg.c
+22
-0
src/dnode/src/dnodeVnodes.c
src/dnode/src/dnodeVnodes.c
+1
-0
src/query/inc/qTableMeta.h
src/query/inc/qTableMeta.h
+0
-1
src/query/inc/sql.y
src/query/inc/sql.y
+1
-1
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+1
-10
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+2
-0
tests/script/general/parser/function.sim
tests/script/general/parser/function.sim
+9
-0
未找到文件。
src/balance/src/bnMain.c
浏览文件 @
b364ae65
...
...
@@ -367,6 +367,7 @@ static bool bnMonitorBalance() {
for
(
int32_t
dest
=
0
;
dest
<
src
;
dest
++
)
{
SDnodeObj
*
pDestDnode
=
tsBnDnodes
.
list
[
dest
];
if
(
bnCheckDnodeInVgroup
(
pDestDnode
,
pVgroup
))
continue
;
if
(
taosGetTimestampMs
()
-
pDestDnode
->
createdTime
<
2000
)
continue
;
float
destScore
=
bnTryCalcDnodeScore
(
pDestDnode
,
1
);
if
(
srcScore
+
0
.
0001
<
destScore
)
continue
;
...
...
src/client/inc/tscUtil.h
浏览文件 @
b364ae65
...
...
@@ -123,6 +123,8 @@ int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, i
*/
bool
tscIsPointInterpQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsTWAQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsIrateQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsSessionWindowQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsSecondStageQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tsIsArithmeticQueryOnAggResult
(
SQueryInfo
*
pQueryInfo
);
...
...
src/client/src/tscPrepare.c
浏览文件 @
b364ae65
src/client/src/tscSQLParser.c
浏览文件 @
b364ae65
...
...
@@ -423,18 +423,6 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
if
(
pInfo
->
pMiscInfo
->
tableType
==
TSDB_SUPER_TABLE
)
{
//// code = tscGetTableMeta(pSql, pTableMetaInfo);
//// if (code != TSDB_CODE_SUCCESS) {
//// return code;
//// }
//
// if (!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
// return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
// }
}
}
else
if
(
pInfo
->
type
==
TSDB_SQL_DROP_DNODE
)
{
if
(
pzName
->
type
==
TK_STRING
)
{
pzName
->
n
=
strdequote
(
pzName
->
z
);
...
...
@@ -772,8 +760,9 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd
->
active
=
pCmd
->
pQueryInfo
;
pCmd
->
command
=
pCmd
->
pQueryInfo
->
command
;
if
(
pTableMetaInfo
->
pTableMeta
!=
NULL
)
{
pSql
->
res
.
precision
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
).
precision
;
STableMetaInfo
*
pTableMetaInfo1
=
tscGetMetaInfo
(
pCmd
->
active
,
0
);
if
(
pTableMetaInfo1
->
pTableMeta
!=
NULL
)
{
pSql
->
res
.
precision
=
tscGetTableInfo
(
pTableMetaInfo1
->
pTableMeta
).
precision
;
}
return
TSDB_CODE_SUCCESS
;
// do not build query message here
...
...
@@ -2026,8 +2015,10 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
SSchema
colSchema
=
*
tGetTbnameColumnSchema
();
getColumnName
(
pItem
,
colSchema
.
name
,
colSchema
.
name
,
sizeof
(
colSchema
.
name
)
-
1
);
char
name
[
TSDB_COL_NAME_LEN
]
=
{
0
};
getColumnName
(
pItem
,
name
,
colSchema
.
name
,
sizeof
(
colSchema
.
name
)
-
1
);
tstrncpy
(
colSchema
.
name
,
name
,
TSDB_COL_NAME_LEN
);
/*SExprInfo* pExpr = */
tscAddFuncInSelectClause
(
pQueryInfo
,
startPos
,
TSDB_FUNC_TAGPRJ
,
&
index
,
&
colSchema
,
TSDB_COL_TAG
,
getNewResColId
(
pCmd
));
}
else
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
index
.
tableIndex
);
...
...
@@ -3066,8 +3057,8 @@ void tscRestoreFuncForSTableQuery(SQueryInfo* pQueryInfo) {
}
bool
hasUnsupportFunctionsForSTableQuery
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
)
{
const
char
*
msg1
=
"TWA/Diff not allowed to apply to super table directly"
;
const
char
*
msg2
=
"TWA/Diff only support group by tbname for super table query"
;
const
char
*
msg1
=
"TWA/Diff
/Derivative/Irate
not allowed to apply to super table directly"
;
const
char
*
msg2
=
"TWA/Diff
/Derivative/Irate
only support group by tbname for super table query"
;
const
char
*
msg3
=
"function not support for super table query"
;
// filter sql function not supported by metric query yet.
...
...
@@ -3080,7 +3071,7 @@ bool hasUnsupportFunctionsForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo)
}
}
if
(
tscIsTWAQuery
(
pQueryInfo
)
||
tscIsDiffDerivQuery
(
pQueryInfo
))
{
if
(
tscIsTWAQuery
(
pQueryInfo
)
||
tscIsDiffDerivQuery
(
pQueryInfo
)
||
tscIsIrateQuery
(
pQueryInfo
)
)
{
if
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
==
0
)
{
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
true
;
...
...
@@ -7791,7 +7782,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
}
}
// todo derivat
e fun
tion requires ts column exists in subquery
// todo derivat
ive func
tion requires ts column exists in subquery
STableMeta
*
pTableMeta
=
tscGetMetaInfo
(
pQueryInfo
,
0
)
->
pTableMeta
;
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
0
);
...
...
src/client/src/tscSub.c
浏览文件 @
b364ae65
...
...
@@ -283,6 +283,7 @@ static int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
SArray
*
tables
=
getTableList
(
pSql
);
if
(
tables
==
NULL
)
{
pSub
->
lastSyncTime
=
0
;
//force to get table list next time
return
0
;
}
size_t
numOfTables
=
taosArrayGetSize
(
tables
);
...
...
@@ -489,7 +490,15 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) {
SSub
*
pSub
=
(
SSub
*
)
tsub
;
if
(
pSub
==
NULL
)
return
NULL
;
if
(
pSub
->
pSql
->
cmd
.
command
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
)
{
if
(
pSub
->
pTimer
==
NULL
)
{
int64_t
duration
=
taosGetTimestampMs
()
-
pSub
->
lastConsumeTime
;
if
(
duration
<
(
int64_t
)(
pSub
->
interval
))
{
tscDebug
(
"subscription consume too frequently, blocking..."
);
taosMsleep
(
pSub
->
interval
-
(
int32_t
)
duration
);
}
}
if
(
pSub
->
pSql
->
cmd
.
command
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
)
{
//may reach here when retireve stable vgroup failed
SSqlObj
*
pSql
=
recreateSqlObj
(
pSub
);
if
(
pSql
==
NULL
)
{
return
NULL
;
...
...
@@ -503,6 +512,11 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) {
pSub
->
pSql
=
pSql
;
pSql
->
pSubscription
=
pSub
;
// no table list now, force to update it
tscDebug
(
"begin table synchronization"
);
if
(
!
tscUpdateSubscription
(
pSub
->
taos
,
pSub
))
return
NULL
;
tscDebug
(
"table synchronization completed"
);
}
tscSaveSubscriptionProgress
(
pSub
);
...
...
@@ -527,14 +541,6 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) {
tscDebug
(
"subscribe:%s set next round subscribe skey:%"
PRId64
,
pSub
->
topic
,
pQueryInfo
->
window
.
skey
);
}
if
(
pSub
->
pTimer
==
NULL
)
{
int64_t
duration
=
taosGetTimestampMs
()
-
pSub
->
lastConsumeTime
;
if
(
duration
<
(
int64_t
)(
pSub
->
interval
))
{
tscDebug
(
"subscription consume too frequently, blocking..."
);
taosMsleep
(
pSub
->
interval
-
(
int32_t
)
duration
);
}
}
size_t
size
=
taosArrayGetSize
(
pSub
->
progress
)
*
sizeof
(
STableIdInfo
);
size
+=
sizeof
(
SQueryTableMsg
)
+
4096
;
int
code
=
tscAllocPayload
(
&
pSql
->
cmd
,
(
int
)
size
);
...
...
src/client/src/tscSubquery.c
浏览文件 @
b364ae65
src/client/src/tscUtil.c
浏览文件 @
b364ae65
...
...
@@ -460,6 +460,22 @@ bool tscIsTWAQuery(SQueryInfo* pQueryInfo) {
return
false
;
}
bool
tscIsIrateQuery
(
SQueryInfo
*
pQueryInfo
)
{
size_t
numOfExprs
=
tscNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
if
(
pExpr
==
NULL
)
{
continue
;
}
if
(
pExpr
->
base
.
functionId
==
TSDB_FUNC_IRATE
)
{
return
true
;
}
}
return
false
;
}
bool
tscIsSessionWindowQuery
(
SQueryInfo
*
pQueryInfo
)
{
return
pQueryInfo
->
sessionWindow
.
gap
>
0
;
}
...
...
@@ -3477,6 +3493,7 @@ static void tscSubqueryRetrieveCallback(void* param, TAOS_RES* tres, int code) {
if
(
pSql
->
res
.
code
==
TSDB_CODE_SUCCESS
)
{
(
*
pSql
->
fp
)(
pParentSql
->
param
,
pParentSql
,
pParentSql
->
res
.
numOfRows
);
}
else
{
pParentSql
->
res
.
code
=
pSql
->
res
.
code
;
tscAsyncResultOnError
(
pParentSql
);
}
}
...
...
src/connector/jdbc/CMakeLists.txt
浏览文件 @
b364ae65
src/dnode/inc/dnodeCfg.h
浏览文件 @
b364ae65
...
...
@@ -27,6 +27,7 @@ void dnodeUpdateCfg(SDnodeCfg *cfg);
int32_t
dnodeGetDnodeId
();
void
dnodeGetClusterId
(
char
*
clusterId
);
void
dnodeGetCfg
(
int32_t
*
dnodeId
,
char
*
clusterId
);
void
dnodeSetDropped
();
#ifdef __cplusplus
}
...
...
src/dnode/src/dnodeCfg.c
浏览文件 @
b364ae65
...
...
@@ -21,6 +21,7 @@
static
SDnodeCfg
tsCfg
=
{
0
};
static
pthread_mutex_t
tsCfgMutex
;
static
int32_t
tsDnodeDropped
;
static
int32_t
dnodeReadCfg
();
static
int32_t
dnodeWriteCfg
();
...
...
@@ -34,6 +35,10 @@ int32_t dnodeInitCfg() {
if
(
ret
==
0
)
{
dInfo
(
"dnode cfg is initialized"
);
}
if
(
tsDnodeDropped
)
{
dInfo
(
"dnode is dropped, exiting"
);
return
-
1
;
}
return
ret
;
}
...
...
@@ -44,6 +49,14 @@ void dnodeUpdateCfg(SDnodeCfg *cfg) {
dnodeResetCfg
(
cfg
);
}
void
dnodeSetDropped
()
{
pthread_mutex_lock
(
&
tsCfgMutex
);
tsDnodeDropped
=
1
;
dnodeWriteCfg
();
pthread_mutex_unlock
(
&
tsCfgMutex
);
}
int32_t
dnodeGetDnodeId
()
{
int32_t
dnodeId
=
0
;
pthread_mutex_lock
(
&
tsCfgMutex
);
...
...
@@ -119,6 +132,14 @@ static int32_t dnodeReadCfg() {
}
cfg
.
dnodeId
=
(
int32_t
)
dnodeId
->
valueint
;
cJSON
*
dnodeDropped
=
cJSON_GetObjectItem
(
root
,
"dnodeDropped"
);
if
(
!
dnodeDropped
||
dnodeDropped
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s, dnodeDropped not found"
,
file
);
//goto PARSE_CFG_OVER;
}
else
{
tsDnodeDropped
=
(
int32_t
)
dnodeDropped
->
valueint
;
}
cJSON
*
clusterId
=
cJSON_GetObjectItem
(
root
,
"clusterId"
);
if
(
!
clusterId
||
clusterId
->
type
!=
cJSON_String
)
{
dError
(
"failed to read %s, clusterId not found"
,
file
);
...
...
@@ -154,6 +175,7 @@ static int32_t dnodeWriteCfg() {
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodeId
\"
: %d,
\n
"
,
tsCfg
.
dnodeId
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dnodeDropped
\"
: %d,
\n
"
,
tsDnodeDropped
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
clusterId
\"
:
\"
%s
\"\n
"
,
tsCfg
.
clusterId
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"}
\n
"
);
...
...
src/dnode/src/dnodeVnodes.c
浏览文件 @
b364ae65
...
...
@@ -202,6 +202,7 @@ static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
char
clusterId
[
TSDB_CLUSTER_ID_LEN
];
dnodeGetClusterId
(
clusterId
);
if
(
clusterId
[
0
]
!=
'\0'
)
{
dnodeSetDropped
();
dError
(
"exit zombie dropped dnode"
);
exit
(
EXIT_FAILURE
);
}
...
...
src/query/inc/qTableMeta.h
浏览文件 @
b364ae65
...
...
@@ -138,7 +138,6 @@ typedef struct SQueryInfo {
bool
hasFilter
;
bool
onlyTagQuery
;
bool
orderProjectQuery
;
// bool diffQuery;
bool
stateWindow
;
}
SQueryInfo
;
...
...
src/query/inc/sql.y
浏览文件 @
b364ae65
src/query/src/qAggMain.c
浏览文件 @
b364ae65
...
...
@@ -3613,16 +3613,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
qError
(
"error input type"
);
}
// initial value is not set yet, all data block are null
if
(
!
pDerivInfo
->
valueSet
||
notNullElems
<=
0
)
{
/*
* 1. current block and blocks before are full of null
* 2. current block may be null value
*/
assert
(
pCtx
->
hasNull
);
}
else
{
GET_RES_INFO
(
pCtx
)
->
numOfRes
+=
notNullElems
;
}
}
#define DIFF_IMPL(ctx, d, type) \
...
...
src/query/src/qExecutor.c
浏览文件 @
b364ae65
...
...
@@ -1312,6 +1312,8 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
}
}
// todo opt perf
for
(
int32_t
k
=
0
;
k
<
pOperator
->
numOfOutput
;
++
k
)
{
pInfo
->
binfo
.
pCtx
[
k
].
size
=
1
;
int32_t
functionId
=
pInfo
->
binfo
.
pCtx
[
k
].
functionId
;
...
...
tests/script/general/parser/function.sim
浏览文件 @
b364ae65
...
...
@@ -817,6 +817,9 @@ print ====================> TODO stddev + normal column filter
print ====================> irate
sql_error select irate(f1) from st1;
sql select irate(f1) from st1 group by tbname;
sql select irate(k) from t1
if $rows != 1 then
return -1
...
...
@@ -1073,6 +1076,12 @@ sql insert into t0 values('2020-1-1 1:3:9', 9);
sql insert into t0 values('2020-1-1 1:4:10', 10);
sql insert into t1 values('2020-1-1 1:1:2', 2);
print ===========================>td-4739
sql select diff(val) from (select derivative(k, 1s, 0) val from t1);
if $rows != 0 then
return -1
endi
sql insert into t1 values('2020-1-1 1:1:4', 20);
sql insert into t1 values('2020-1-1 1:1:6', 200);
sql insert into t1 values('2020-1-1 1:1:8', 2000);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录