Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a4cd6bfb
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看板
未验证
提交
a4cd6bfb
编写于
6月 10, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
6月 10, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13678 from taosdata/feature/3.0_debug_wxy
fix: a problem of interval distributed split
上级
ae5ad540
bc32629c
变更
16
展开全部
隐藏空白更改
内联
并排
Showing
16 changed file
with
2434 addition
and
2322 deletion
+2434
-2322
include/common/tmsg.h
include/common/tmsg.h
+17
-10
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
include/common/ttokendef.h
include/common/ttokendef.h
+62
-61
source/common/src/tmsg.c
source/common/src/tmsg.c
+29
-4
source/libs/function/src/functionMgt.c
source/libs/function/src/functionMgt.c
+17
-2
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+7
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-1
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+3
-0
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+1
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+11
-3
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2236
-2233
source/libs/parser/test/parInitialCTest.cpp
source/libs/parser/test/parInitialCTest.cpp
+3
-1
source/libs/parser/test/parShowToUse.cpp
source/libs/parser/test/parShowToUse.cpp
+19
-2
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+24
-3
source/libs/planner/test/planIntervalTest.cpp
source/libs/planner/test/planIntervalTest.cpp
+2
-0
source/libs/planner/test/planSTableTest.cpp
source/libs/planner/test/planSTableTest.cpp
+1
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
a4cd6bfb
...
...
@@ -1341,6 +1341,13 @@ typedef struct {
int32_t
tSerializeSRedistributeVgroupReq
(
void
*
buf
,
int32_t
bufLen
,
SRedistributeVgroupReq
*
pReq
);
int32_t
tDeserializeSRedistributeVgroupReq
(
void
*
buf
,
int32_t
bufLen
,
SRedistributeVgroupReq
*
pReq
);
typedef
struct
{
int32_t
vgId
;
}
SSplitVgroupReq
;
int32_t
tSerializeSSplitVgroupReq
(
void
*
buf
,
int32_t
bufLen
,
SSplitVgroupReq
*
pReq
);
int32_t
tDeserializeSSplitVgroupReq
(
void
*
buf
,
int32_t
bufLen
,
SSplitVgroupReq
*
pReq
);
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
char
spi
;
...
...
@@ -2494,15 +2501,15 @@ int32_t tSerializeSTableIndexReq(void* buf, int32_t bufLen, STableIndexReq* pReq
int32_t
tDeserializeSTableIndexReq
(
void
*
buf
,
int32_t
bufLen
,
STableIndexReq
*
pReq
);
typedef
struct
{
int8_t
intervalUnit
;
int8_t
slidingUnit
;
int64_t
interval
;
int64_t
offset
;
int64_t
sliding
;
int64_t
dstTbUid
;
int32_t
dstVgId
;
// for stream
SEpSet
epSet
;
char
*
expr
;
int8_t
intervalUnit
;
int8_t
slidingUnit
;
int64_t
interval
;
int64_t
offset
;
int64_t
sliding
;
int64_t
dstTbUid
;
int32_t
dstVgId
;
// for stream
SEpSet
epSet
;
char
*
expr
;
}
STableIndexInfo
;
typedef
struct
{
...
...
@@ -2511,7 +2518,7 @@ typedef struct {
int32_t
tSerializeSTableIndexRsp
(
void
*
buf
,
int32_t
bufLen
,
const
STableIndexRsp
*
pRsp
);
int32_t
tDeserializeSTableIndexRsp
(
void
*
buf
,
int32_t
bufLen
,
STableIndexRsp
*
pRsp
);
void
tFreeSTableIndexInfo
(
void
*
pInfo
);
void
tFreeSTableIndexInfo
(
void
*
pInfo
);
typedef
struct
{
int8_t
mqMsgType
;
...
...
include/common/tmsgdef.h
浏览文件 @
a4cd6bfb
...
...
@@ -157,6 +157,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_MND_BALANCE_VGROUP
,
"balance-vgroup"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MERGE_VGROUP
,
"merge-vgroup"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_REDISTRIBUTE_VGROUP
,
"redistribute-vgroup"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SPLIT_VGROUP
,
"split-vgroup"
,
NULL
,
NULL
)
TD_NEW_MSG_SEG
(
TDMT_VND_MSG
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBMIT
,
"submit"
,
SSubmitReq
,
SSubmitRsp
)
...
...
include/common/ttokendef.h
浏览文件 @
a4cd6bfb
...
...
@@ -192,67 +192,68 @@
#define TK_VGROUP 174
#define TK_MERGE 175
#define TK_REDISTRIBUTE 176
#define TK_SYNCDB 177
#define TK_DELETE 178
#define TK_NULL 179
#define TK_NK_QUESTION 180
#define TK_NK_ARROW 181
#define TK_ROWTS 182
#define TK_TBNAME 183
#define TK_QSTARTTS 184
#define TK_QENDTS 185
#define TK_WSTARTTS 186
#define TK_WENDTS 187
#define TK_WDURATION 188
#define TK_CAST 189
#define TK_NOW 190
#define TK_TODAY 191
#define TK_TIMEZONE 192
#define TK_COUNT 193
#define TK_FIRST 194
#define TK_LAST 195
#define TK_LAST_ROW 196
#define TK_BETWEEN 197
#define TK_IS 198
#define TK_NK_LT 199
#define TK_NK_GT 200
#define TK_NK_LE 201
#define TK_NK_GE 202
#define TK_NK_NE 203
#define TK_MATCH 204
#define TK_NMATCH 205
#define TK_CONTAINS 206
#define TK_JOIN 207
#define TK_INNER 208
#define TK_SELECT 209
#define TK_DISTINCT 210
#define TK_WHERE 211
#define TK_PARTITION 212
#define TK_BY 213
#define TK_SESSION 214
#define TK_STATE_WINDOW 215
#define TK_SLIDING 216
#define TK_FILL 217
#define TK_VALUE 218
#define TK_NONE 219
#define TK_PREV 220
#define TK_LINEAR 221
#define TK_NEXT 222
#define TK_HAVING 223
#define TK_ORDER 224
#define TK_SLIMIT 225
#define TK_SOFFSET 226
#define TK_LIMIT 227
#define TK_OFFSET 228
#define TK_ASC 229
#define TK_NULLS 230
#define TK_ID 231
#define TK_NK_BITNOT 232
#define TK_INSERT 233
#define TK_VALUES 234
#define TK_IMPORT 235
#define TK_NK_SEMI 236
#define TK_FILE 237
#define TK_SPLIT 177
#define TK_SYNCDB 178
#define TK_DELETE 179
#define TK_NULL 180
#define TK_NK_QUESTION 181
#define TK_NK_ARROW 182
#define TK_ROWTS 183
#define TK_TBNAME 184
#define TK_QSTARTTS 185
#define TK_QENDTS 186
#define TK_WSTARTTS 187
#define TK_WENDTS 188
#define TK_WDURATION 189
#define TK_CAST 190
#define TK_NOW 191
#define TK_TODAY 192
#define TK_TIMEZONE 193
#define TK_COUNT 194
#define TK_FIRST 195
#define TK_LAST 196
#define TK_LAST_ROW 197
#define TK_BETWEEN 198
#define TK_IS 199
#define TK_NK_LT 200
#define TK_NK_GT 201
#define TK_NK_LE 202
#define TK_NK_GE 203
#define TK_NK_NE 204
#define TK_MATCH 205
#define TK_NMATCH 206
#define TK_CONTAINS 207
#define TK_JOIN 208
#define TK_INNER 209
#define TK_SELECT 210
#define TK_DISTINCT 211
#define TK_WHERE 212
#define TK_PARTITION 213
#define TK_BY 214
#define TK_SESSION 215
#define TK_STATE_WINDOW 216
#define TK_SLIDING 217
#define TK_FILL 218
#define TK_VALUE 219
#define TK_NONE 220
#define TK_PREV 221
#define TK_LINEAR 222
#define TK_NEXT 223
#define TK_HAVING 224
#define TK_ORDER 225
#define TK_SLIMIT 226
#define TK_SOFFSET 227
#define TK_LIMIT 228
#define TK_OFFSET 229
#define TK_ASC 230
#define TK_NULLS 231
#define TK_ID 232
#define TK_NK_BITNOT 233
#define TK_INSERT 234
#define TK_VALUES 235
#define TK_IMPORT 236
#define TK_NK_SEMI 237
#define TK_FILE 238
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
...
...
source/common/src/tmsg.c
浏览文件 @
a4cd6bfb
...
...
@@ -2419,7 +2419,7 @@ int32_t tDeserializeSTableIndexReq(void *buf, int32_t bufLen, STableIndexReq *pR
return
0
;
}
int32_t
tSerializeSTableIndexInfo
(
SEncoder
*
pEncoder
,
STableIndexInfo
*
pInfo
)
{
int32_t
tSerializeSTableIndexInfo
(
SEncoder
*
pEncoder
,
STableIndexInfo
*
pInfo
)
{
if
(
tEncodeI8
(
pEncoder
,
pInfo
->
intervalUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pInfo
->
slidingUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pInfo
->
interval
)
<
0
)
return
-
1
;
...
...
@@ -2441,7 +2441,7 @@ int32_t tSerializeSTableIndexRsp(void *buf, int32_t bufLen, const STableIndexRsp
if
(
tEncodeI32
(
&
encoder
,
num
)
<
0
)
return
-
1
;
if
(
num
>
0
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
STableIndexInfo
*
pInfo
=
(
STableIndexInfo
*
)
taosArrayGet
(
pRsp
->
pIndex
,
i
);
STableIndexInfo
*
pInfo
=
(
STableIndexInfo
*
)
taosArrayGet
(
pRsp
->
pIndex
,
i
);
if
(
tSerializeSTableIndexInfo
(
&
encoder
,
pInfo
)
<
0
)
return
-
1
;
}
}
...
...
@@ -2491,12 +2491,12 @@ int32_t tDeserializeSTableIndexRsp(void *buf, int32_t bufLen, STableIndexRsp *pR
return
0
;
}
void
tFreeSTableIndexInfo
(
void
*
info
)
{
void
tFreeSTableIndexInfo
(
void
*
info
)
{
if
(
NULL
==
info
)
{
return
;
}
STableIndexInfo
*
pInfo
=
(
STableIndexInfo
*
)
info
;
STableIndexInfo
*
pInfo
=
(
STableIndexInfo
*
)
info
;
taosMemoryFree
(
pInfo
->
expr
);
}
...
...
@@ -3448,6 +3448,31 @@ int32_t tDeserializeSRedistributeVgroupReq(void *buf, int32_t bufLen, SRedistrib
return
0
;
}
int32_t
tSerializeSSplitVgroupReq
(
void
*
buf
,
int32_t
bufLen
,
SSplitVgroupReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
vgId
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSSplitVgroupReq
(
void
*
buf
,
int32_t
bufLen
,
SSplitVgroupReq
*
pReq
)
{
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
vgId
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSDCreateMnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SDCreateMnodeReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
...
...
source/libs/function/src/functionMgt.c
浏览文件 @
a4cd6bfb
...
...
@@ -200,6 +200,21 @@ bool fmIsInvertible(int32_t funcId) {
return
res
;
}
static
int32_t
getFuncInfo
(
SFunctionNode
*
pFunc
)
{
char
msg
[
64
]
=
{
0
};
if
(
NULL
!=
gFunMgtService
.
pFuncNameHashTable
)
{
return
fmGetFuncInfo
(
pFunc
,
msg
,
sizeof
(
msg
));
}
for
(
int32_t
i
=
0
;
i
<
funcMgtBuiltinsNum
;
++
i
)
{
if
(
0
==
strcmp
(
funcMgtBuiltins
[
i
].
name
,
pFunc
->
functionName
))
{
pFunc
->
funcId
=
i
;
pFunc
->
funcType
=
funcMgtBuiltins
[
pFunc
->
funcId
].
type
;
return
funcMgtBuiltins
[
pFunc
->
funcId
].
translateFunc
(
pFunc
,
msg
,
sizeof
(
msg
));
}
}
return
TSDB_CODE_FUNC_NOT_BUILTIN_FUNTION
;
}
static
SFunctionNode
*
createFunction
(
const
char
*
pName
,
SNodeList
*
pParameterList
)
{
SFunctionNode
*
pFunc
=
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
if
(
NULL
==
pFunc
)
{
...
...
@@ -207,8 +222,8 @@ static SFunctionNode* createFunction(const char* pName, SNodeList* pParameterLis
}
strcpy
(
pFunc
->
functionName
,
pName
);
pFunc
->
pParameterList
=
pParameterList
;
char
msg
[
64
]
=
{
0
};
if
(
TSDB_CODE_SUCCESS
!=
fmGetFuncInfo
(
pFunc
,
msg
,
sizeof
(
msg
)))
{
if
(
TSDB_CODE_SUCCESS
!=
getFuncInfo
(
pFunc
))
{
pFunc
->
pParameterList
=
NULL
;
nodesDestroyNode
(
pFunc
);
return
NULL
;
}
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
a4cd6bfb
...
...
@@ -678,6 +678,7 @@ static int32_t jsonToLogicExchangeNode(const SJson* pJson, void* pObj) {
}
static
const
char
*
jkMergeLogicPlanMergeKeys
=
"MergeKeys"
;
static
const
char
*
jkMergeLogicPlanInputs
=
"Inputs"
;
static
const
char
*
jkMergeLogicPlanNumOfChannels
=
"NumOfChannels"
;
static
const
char
*
jkMergeLogicPlanSrcGroupId
=
"SrcGroupId"
;
...
...
@@ -688,6 +689,9 @@ static int32_t logicMergeNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkMergeLogicPlanMergeKeys
,
pNode
->
pMergeKeys
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkMergeLogicPlanInputs
,
pNode
->
pInputs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkMergeLogicPlanNumOfChannels
,
pNode
->
numOfChannels
);
}
...
...
@@ -705,6 +709,9 @@ static int32_t jsonToLogicMergeNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkMergeLogicPlanMergeKeys
,
&
pNode
->
pMergeKeys
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkMergeLogicPlanInputs
,
&
pNode
->
pInputs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetIntValue
(
pJson
,
jkMergeLogicPlanNumOfChannels
,
&
pNode
->
numOfChannels
);
}
...
...
source/libs/parser/inc/sql.y
浏览文件 @
a4cd6bfb
...
...
@@ -472,7 +472,7 @@ cmd ::= KILL TRANSACTION NK_INTEGER(A).
cmd ::= BALANCE VGROUP. { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); }
cmd ::= MERGE VGROUP NK_INTEGER(A) NK_INTEGER(B). { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &A, &B); }
cmd ::= REDISTRIBUTE VGROUP NK_INTEGER(A) dnode_list(B). { pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &A, B); }
//
cmd ::= SPLIT VGROUP NK_INTEGER(A). { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &A); }
cmd ::= SPLIT VGROUP NK_INTEGER(A). { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &A); }
%type dnode_list { SNodeList* }
%destructor dnode_list { nodesDestroyList($$); }
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
a4cd6bfb
...
...
@@ -248,6 +248,9 @@ static int32_t collectMetaKeyFromCreateIndex(SCollectMetaKeyCxt* pCxt, SCreateIn
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
db
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
db
,
pCxt
->
pMetaCache
);
}
}
return
code
;
}
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
a4cd6bfb
...
...
@@ -174,7 +174,7 @@ static SKeyword keywordTable[] = {
{
"SNODE"
,
TK_SNODE
},
{
"SNODES"
,
TK_SNODES
},
{
"SOFFSET"
,
TK_SOFFSET
},
//
{"SPLIT", TK_SPLIT},
{
"SPLIT"
,
TK_SPLIT
},
{
"STABLE"
,
TK_STABLE
},
{
"STABLES"
,
TK_STABLES
},
{
"STATE"
,
TK_STATE
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
a4cd6bfb
...
...
@@ -824,9 +824,9 @@ static EDealRes translateComparisonOperator(STranslateContext* pCxt, SOperatorNo
}
if
(
OP_TYPE_IN
==
pOp
->
opType
||
OP_TYPE_NOT_IN
==
pOp
->
opType
)
{
SNodeListNode
*
pRight
=
(
SNodeListNode
*
)
pOp
->
pRight
;
bool
first
=
true
;
SDataType
targetDt
=
{
0
};
SNode
*
pNode
=
NULL
;
bool
first
=
true
;
SDataType
targetDt
=
{
0
};
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pRight
->
pNodeList
)
{
SDataType
dt
=
((
SExprNode
*
)
pNode
)
->
resType
;
if
(
first
)
{
...
...
@@ -3672,6 +3672,11 @@ static int32_t translateRedistributeVgroup(STranslateContext* pCxt, SRedistribut
return
code
;
}
static
int32_t
translateSplitVgroup
(
STranslateContext
*
pCxt
,
SSplitVgroupStmt
*
pStmt
)
{
SSplitVgroupReq
req
=
{.
vgId
=
pStmt
->
vgId
};
return
buildCmdMsg
(
pCxt
,
TDMT_MND_SPLIT_VGROUP
,
(
FSerializeFunc
)
tSerializeSSplitVgroupReq
,
&
req
);
}
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pNode
))
{
...
...
@@ -3803,6 +3808,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case
QUERY_NODE_REDISTRIBUTE_VGROUP_STMT
:
code
=
translateRedistributeVgroup
(
pCxt
,
(
SRedistributeVgroupStmt
*
)
pNode
);
break
;
case
QUERY_NODE_SPLIT_VGROUP_STMT
:
code
=
translateSplitVgroup
(
pCxt
,
(
SSplitVgroupStmt
*
)
pNode
);
break
;
default:
break
;
}
...
...
source/libs/parser/src/sql.c
浏览文件 @
a4cd6bfb
此差异已折叠。
点击以展开。
source/libs/parser/test/parInitialCTest.cpp
浏览文件 @
a4cd6bfb
...
...
@@ -267,10 +267,12 @@ TEST_F(ParserInitialCTest, createFunction) {
// run("CREATE AGGREGATE FUNCTION IF NOT EXISTS udf2 AS './build/lib/libudf2.so' OUTPUTTYPE DOUBLE BUFSIZE 8");
}
TEST_F
(
ParserInitialCTest
,
create
IndexSma
)
{
TEST_F
(
ParserInitialCTest
,
create
SmaIndex
)
{
useDb
(
"root"
,
"test"
);
run
(
"CREATE SMA INDEX index1 ON t1 FUNCTION(MAX(c1), MIN(c3 + 10), SUM(c4)) INTERVAL(10s)"
);
run
(
"CREATE SMA INDEX index2 ON st1 FUNCTION(MAX(c1), MIN(tag1)) INTERVAL(10s)"
);
}
TEST_F
(
ParserInitialCTest
,
createMnode
)
{
...
...
source/libs/parser/test/parShowToUse.cpp
浏览文件 @
a4cd6bfb
...
...
@@ -19,7 +19,7 @@ using namespace std;
namespace
ParserTest
{
class
ParserShowToUseTest
:
public
Parser
TestBase
{};
class
ParserShowToUseTest
:
public
Parser
DdlTest
{};
// todo SHOW accounts
// todo SHOW apps
...
...
@@ -133,7 +133,24 @@ TEST_F(ParserShowToUseTest, showVgroups) {
// todo SHOW vnodes
// todo split vgroup
TEST_F
(
ParserShowToUseTest
,
splitVgroup
)
{
useDb
(
"root"
,
"test"
);
SSplitVgroupReq
expect
=
{
0
};
auto
setSplitVgroupReqFunc
=
[
&
](
int32_t
vgId
)
{
expect
.
vgId
=
vgId
;
};
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_SPLIT_VGROUP_STMT
);
ASSERT_EQ
(
pQuery
->
pCmdMsg
->
msgType
,
TDMT_MND_SPLIT_VGROUP
);
SSplitVgroupReq
req
=
{
0
};
ASSERT_EQ
(
tDeserializeSSplitVgroupReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
req
.
vgId
,
expect
.
vgId
);
});
setSplitVgroupReqFunc
(
15
);
run
(
"SPLIT VGROUP 15"
);
}
TEST_F
(
ParserShowToUseTest
,
useDatabase
)
{
useDb
(
"root"
,
"test"
);
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
a4cd6bfb
...
...
@@ -135,7 +135,8 @@ typedef struct SStableSplitInfo {
static
bool
stbSplHasGatherExecFunc
(
const
SNodeList
*
pFuncs
)
{
SNode
*
pFunc
=
NULL
;
FOREACH
(
pFunc
,
pFuncs
)
{
if
(
!
fmIsDistExecFunc
(((
SFunctionNode
*
)
pFunc
)
->
funcId
))
{
if
(
!
fmIsWindowPseudoColumnFunc
(((
SFunctionNode
*
)
pFunc
)
->
funcId
)
&&
!
fmIsDistExecFunc
(((
SFunctionNode
*
)
pFunc
)
->
funcId
))
{
return
true
;
}
}
...
...
@@ -314,7 +315,12 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla
int32_t
code
=
TSDB_CODE_SUCCESS
;
pMerge
->
pInputs
=
nodesCloneList
(
pPartChild
->
pTargets
);
pMerge
->
node
.
pTargets
=
nodesCloneList
(
pSplitNode
->
pTargets
);
// NULL == pSubplan means 'merge node' replaces 'split node'.
if
(
NULL
==
pSubplan
)
{
pMerge
->
node
.
pTargets
=
nodesCloneList
(
pPartChild
->
pTargets
);
}
else
{
pMerge
->
node
.
pTargets
=
nodesCloneList
(
pSplitNode
->
pTargets
);
}
if
(
NULL
==
pMerge
->
node
.
pTargets
||
NULL
==
pMerge
->
pInputs
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
...
...
@@ -340,6 +346,21 @@ static int32_t stbSplCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pParent
return
code
;
}
static
int32_t
stbSplCreateMergeKeysForInterval
(
SNode
*
pWStartTs
,
SNodeList
**
pMergeKeys
)
{
SOrderByExprNode
*
pMergeKey
=
nodesMakeNode
(
QUERY_NODE_ORDER_BY_EXPR
);
if
(
NULL
==
pMergeKey
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pMergeKey
->
pExpr
=
nodesCloneNode
(
pWStartTs
);
if
(
NULL
==
pMergeKey
->
pExpr
)
{
nodesDestroyNode
(
pMergeKey
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pMergeKey
->
order
=
ORDER_ASC
;
pMergeKey
->
nullOrder
=
NULL_ORDER_FIRST
;
return
nodesListMakeStrictAppend
(
pMergeKeys
,
pMergeKey
);
}
static
int32_t
stbSplSplitIntervalForBatch
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
SLogicNode
*
pPartWindow
=
NULL
;
int32_t
code
=
stbSplCreatePartWindowNode
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
,
&
pPartWindow
);
...
...
@@ -347,7 +368,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo
((
SWindowLogicNode
*
)
pPartWindow
)
->
intervalAlgo
=
INTERVAL_ALGO_HASH
;
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
intervalAlgo
=
INTERVAL_ALGO_MERGE
;
SNodeList
*
pMergeKeys
=
NULL
;
code
=
nodesListMakeStrictAppend
(
&
pMergeKeys
,
nodesCloneNode
(((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
pTspk
)
);
code
=
stbSplCreateMergeKeysForInterval
(((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
pTspk
,
&
pMergeKeys
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbSplCreateMergeNode
(
pCxt
,
NULL
,
pInfo
->
pSplitNode
,
pMergeKeys
,
pPartWindow
);
}
...
...
source/libs/planner/test/planIntervalTest.cpp
浏览文件 @
a4cd6bfb
...
...
@@ -58,4 +58,6 @@ TEST_F(PlanIntervalTest, stable) {
useDb
(
"root"
,
"test"
);
run
(
"SELECT COUNT(*) FROM st1 INTERVAL(10s)"
);
run
(
"SELECT _WSTARTTS, COUNT(*) FROM st1 INTERVAL(10s)"
);
}
source/libs/planner/test/planSTableTest.cpp
浏览文件 @
a4cd6bfb
...
...
@@ -38,5 +38,5 @@ TEST_F(PlanSuperTableTest, pseudoColOnChildTable) {
TEST_F
(
PlanSuperTableTest
,
orderBy
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT -1
*c1, c1 FROM st1 ORDER BY -1*
c1"
);
run
(
"SELECT -1
* c1, c1 FROM st1 ORDER BY -1 *
c1"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录