Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
341a46e4
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看板
提交
341a46e4
编写于
6月 04, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feat/row_refact
上级
c568aeaa
a50d1086
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
222 addition
and
36 deletion
+222
-36
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+1
-1
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+12
-0
source/libs/function/src/functionMgt.c
source/libs/function/src/functionMgt.c
+3
-0
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+18
-0
source/libs/parser/test/parInitialDTest.cpp
source/libs/parser/test/parInitialDTest.cpp
+24
-14
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+143
-15
source/libs/planner/test/planGroupByTest.cpp
source/libs/planner/test/planGroupByTest.cpp
+8
-0
source/libs/planner/test/planOrderByTest.cpp
source/libs/planner/test/planOrderByTest.cpp
+13
-6
未找到文件。
source/client/src/clientImpl.c
浏览文件 @
341a46e4
...
@@ -1087,7 +1087,7 @@ void* doAsyncFetchRow(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUc
...
@@ -1087,7 +1087,7 @@ void* doAsyncFetchRow(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUc
tsem_wait
(
&
pParam
->
sem
);
tsem_wait
(
&
pParam
->
sem
);
}
}
if
(
pRequest
->
code
==
TSDB_CODE_SUCCESS
&&
setupOneRowPtr
)
{
if
(
pRequest
->
code
==
TSDB_CODE_SUCCESS
&&
pResultInfo
->
numOfRows
>
0
&&
setupOneRowPtr
)
{
doSetOneRowPtr
(
pResultInfo
);
doSetOneRowPtr
(
pResultInfo
);
pResultInfo
->
current
+=
1
;
pResultInfo
->
current
+=
1
;
}
}
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
341a46e4
...
@@ -328,6 +328,18 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
...
@@ -328,6 +328,18 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
CTG_ERR_JRET
(
ctgInitGetQnodeTask
(
pJob
,
taskIdx
++
));
CTG_ERR_JRET
(
ctgInitGetQnodeTask
(
pJob
,
taskIdx
++
));
}
}
pJob
->
refId
=
taosAddRef
(
gCtgMgmt
.
jobPool
,
pJob
);
if
(
pJob
->
refId
<
0
)
{
ctgError
(
"add job to ref failed, error: %s"
,
tstrerror
(
terrno
));
CTG_ERR_JRET
(
terrno
);
}
taosAcquireRef
(
gCtgMgmt
.
jobPool
,
pJob
->
refId
);
qDebug
(
"QID:%"
PRIx64
", job %"
PRIx64
" initialized, task num %d"
,
pJob
->
queryId
,
pJob
->
refId
,
*
taskNum
);
return
TSDB_CODE_SUCCESS
;
_return:
_return:
taosMemoryFreeClear
(
*
job
);
taosMemoryFreeClear
(
*
job
);
CTG_RET
(
code
);
CTG_RET
(
code
);
...
...
source/libs/function/src/functionMgt.c
浏览文件 @
341a46e4
...
@@ -226,6 +226,9 @@ static SColumnNode* createColumnByFunc(const SFunctionNode* pFunc) {
...
@@ -226,6 +226,9 @@ static SColumnNode* createColumnByFunc(const SFunctionNode* pFunc) {
}
}
bool
fmIsDistExecFunc
(
int32_t
funcId
)
{
bool
fmIsDistExecFunc
(
int32_t
funcId
)
{
if
(
fmIsUserDefinedFunc
(
funcId
))
{
return
false
;
}
if
(
!
fmIsVectorFunc
(
funcId
))
{
if
(
!
fmIsVectorFunc
(
funcId
))
{
return
true
;
return
true
;
}
}
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
341a46e4
...
@@ -199,6 +199,22 @@ static int32_t collectMetaKeyFromCreateMultiTable(SCollectMetaKeyCxt* pCxt, SCre
...
@@ -199,6 +199,22 @@ static int32_t collectMetaKeyFromCreateMultiTable(SCollectMetaKeyCxt* pCxt, SCre
return
code
;
return
code
;
}
}
static
int32_t
collectMetaKeyFromDropTable
(
SCollectMetaKeyCxt
*
pCxt
,
SDropTableStmt
*
pStmt
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pStmt
->
pTables
)
{
SDropTableClause
*
pClause
=
(
SDropTableClause
*
)
pNode
;
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pClause
->
dbName
,
pClause
->
tableName
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pClause
->
dbName
,
pClause
->
tableName
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
return
code
;
}
static
int32_t
collectMetaKeyFromAlterTable
(
SCollectMetaKeyCxt
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
static
int32_t
collectMetaKeyFromAlterTable
(
SCollectMetaKeyCxt
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -341,6 +357,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
...
@@ -341,6 +357,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return
collectMetaKeyFromCreateTable
(
pCxt
,
(
SCreateTableStmt
*
)
pStmt
);
return
collectMetaKeyFromCreateTable
(
pCxt
,
(
SCreateTableStmt
*
)
pStmt
);
case
QUERY_NODE_CREATE_MULTI_TABLE_STMT
:
case
QUERY_NODE_CREATE_MULTI_TABLE_STMT
:
return
collectMetaKeyFromCreateMultiTable
(
pCxt
,
(
SCreateMultiTableStmt
*
)
pStmt
);
return
collectMetaKeyFromCreateMultiTable
(
pCxt
,
(
SCreateMultiTableStmt
*
)
pStmt
);
case
QUERY_NODE_DROP_TABLE_STMT
:
return
collectMetaKeyFromDropTable
(
pCxt
,
(
SDropTableStmt
*
)
pStmt
);
case
QUERY_NODE_ALTER_TABLE_STMT
:
case
QUERY_NODE_ALTER_TABLE_STMT
:
return
collectMetaKeyFromAlterTable
(
pCxt
,
(
SAlterTableStmt
*
)
pStmt
);
return
collectMetaKeyFromAlterTable
(
pCxt
,
(
SAlterTableStmt
*
)
pStmt
);
case
QUERY_NODE_USE_DATABASE_STMT
:
case
QUERY_NODE_USE_DATABASE_STMT
:
...
...
source/libs/parser/test/parInitialDTest.cpp
浏览文件 @
341a46e4
...
@@ -24,7 +24,7 @@ class ParserInitialDTest : public ParserDdlTest {};
...
@@ -24,7 +24,7 @@ class ParserInitialDTest : public ParserDdlTest {};
// todo delete
// todo delete
// todo desc
// todo desc
// todo describe
// todo describe
// todo
drop
account
// todo
DROP
account
TEST_F
(
ParserInitialDTest
,
dropBnode
)
{
TEST_F
(
ParserInitialDTest
,
dropBnode
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
...
@@ -62,51 +62,61 @@ TEST_F(ParserInitialDTest, dropCGroup) {
...
@@ -62,51 +62,61 @@ TEST_F(ParserInitialDTest, dropCGroup) {
run
(
"DROP CONSUMER GROUP IF EXISTS cg1 ON tp1"
);
run
(
"DROP CONSUMER GROUP IF EXISTS cg1 ON tp1"
);
}
}
// todo
drop
database
// todo
DROP
database
// todo
drop
dnode
// todo
DROP
dnode
// todo
drop
function
// todo
DROP
function
TEST_F
(
ParserInitialDTest
,
dropIndex
)
{
TEST_F
(
ParserInitialDTest
,
dropIndex
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"
drop
index index1 on t1"
);
run
(
"
DROP
index index1 on t1"
);
}
}
TEST_F
(
ParserInitialDTest
,
dropMnode
)
{
TEST_F
(
ParserInitialDTest
,
dropMnode
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"
drop
mnode on dnode 1"
);
run
(
"
DROP
mnode on dnode 1"
);
}
}
TEST_F
(
ParserInitialDTest
,
dropQnode
)
{
TEST_F
(
ParserInitialDTest
,
dropQnode
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"
drop
qnode on dnode 1"
);
run
(
"
DROP
qnode on dnode 1"
);
}
}
TEST_F
(
ParserInitialDTest
,
dropSnode
)
{
TEST_F
(
ParserInitialDTest
,
dropSnode
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"
drop
snode on dnode 1"
);
run
(
"
DROP
snode on dnode 1"
);
}
}
// todo drop stable
TEST_F
(
ParserInitialDTest
,
dropSTable
)
{
// todo drop stream
useDb
(
"root"
,
"test"
);
// todo drop table
run
(
"DROP STABLE st1"
);
}
// todo DROP stream
TEST_F
(
ParserInitialDTest
,
dropTable
)
{
useDb
(
"root"
,
"test"
);
run
(
"DROP TABLE t1"
);
}
TEST_F
(
ParserInitialDTest
,
dropTopic
)
{
TEST_F
(
ParserInitialDTest
,
dropTopic
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"
drop
topic tp1"
);
run
(
"
DROP
topic tp1"
);
run
(
"
drop
topic if exists tp1"
);
run
(
"
DROP
topic if exists tp1"
);
}
}
TEST_F
(
ParserInitialDTest
,
dropUser
)
{
TEST_F
(
ParserInitialDTest
,
dropUser
)
{
login
(
"root"
);
login
(
"root"
);
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"
drop
user wxy"
);
run
(
"
DROP
user wxy"
);
}
}
}
// namespace ParserTest
}
// namespace ParserTest
source/libs/planner/src/planSpliter.c
浏览文件 @
341a46e4
...
@@ -151,8 +151,8 @@ static bool stbSplHasMultiTbScan(bool streamQuery, SLogicNode* pNode) {
...
@@ -151,8 +151,8 @@ static bool stbSplHasMultiTbScan(bool streamQuery, SLogicNode* pNode) {
static
bool
stbSplNeedSplit
(
bool
streamQuery
,
SLogicNode
*
pNode
)
{
static
bool
stbSplNeedSplit
(
bool
streamQuery
,
SLogicNode
*
pNode
)
{
switch
(
nodeType
(
pNode
))
{
switch
(
nodeType
(
pNode
))
{
//
case QUERY_NODE_LOGIC_PLAN_AGG:
case
QUERY_NODE_LOGIC_PLAN_AGG
:
// return !stbSplHasGatherExecFunc(((SAggLogicNode*)pNode)->pAggFuncs) && stbSplHasMultiTbScan(
pNode);
return
!
stbSplHasGatherExecFunc
(((
SAggLogicNode
*
)
pNode
)
->
pAggFuncs
)
&&
stbSplHasMultiTbScan
(
streamQuery
,
pNode
);
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
{
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
{
SWindowLogicNode
*
pWindow
=
(
SWindowLogicNode
*
)
pNode
;
SWindowLogicNode
*
pWindow
=
(
SWindowLogicNode
*
)
pNode
;
if
(
WINDOW_TYPE_INTERVAL
!=
pWindow
->
winType
)
{
if
(
WINDOW_TYPE_INTERVAL
!=
pWindow
->
winType
)
{
...
@@ -161,7 +161,7 @@ static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) {
...
@@ -161,7 +161,7 @@ static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) {
return
!
stbSplHasGatherExecFunc
(
pWindow
->
pFuncs
)
&&
stbSplHasMultiTbScan
(
streamQuery
,
pNode
);
return
!
stbSplHasGatherExecFunc
(
pWindow
->
pFuncs
)
&&
stbSplHasMultiTbScan
(
streamQuery
,
pNode
);
}
}
// case QUERY_NODE_LOGIC_PLAN_SORT:
// case QUERY_NODE_LOGIC_PLAN_SORT:
// return stbSplHasMultiTbScan(pNode);
// return stbSplHasMultiTbScan(
streamQuery,
pNode);
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
stbSplIsMultiTbScan
(
streamQuery
,
(
SScanLogicNode
*
)
pNode
);
return
stbSplIsMultiTbScan
(
streamQuery
,
(
SScanLogicNode
*
)
pNode
);
default:
default:
...
@@ -295,7 +295,8 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
...
@@ -295,7 +295,8 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
return
code
;
return
code
;
}
}
static
int32_t
stbSplCreateMergeNode
(
SSplitContext
*
pCxt
,
SLogicNode
*
pParent
,
SLogicNode
*
pPartChild
)
{
static
int32_t
stbSplCreateMergeNode
(
SSplitContext
*
pCxt
,
SLogicNode
*
pParent
,
SNodeList
*
pMergeKeys
,
SLogicNode
*
pPartChild
)
{
SMergeLogicNode
*
pMerge
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_MERGE
);
SMergeLogicNode
*
pMerge
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_MERGE
);
if
(
NULL
==
pMerge
)
{
if
(
NULL
==
pMerge
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -304,25 +305,28 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicNode* pParent, S
...
@@ -304,25 +305,28 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicNode* pParent, S
pMerge
->
srcGroupId
=
pCxt
->
groupId
;
pMerge
->
srcGroupId
=
pCxt
->
groupId
;
pMerge
->
node
.
pParent
=
pParent
;
pMerge
->
node
.
pParent
=
pParent
;
pMerge
->
node
.
precision
=
pPartChild
->
precision
;
pMerge
->
node
.
precision
=
pPartChild
->
precision
;
int32_t
code
=
nodesListMakeStrictAppend
(
&
pMerge
->
pMergeKeys
,
nodesCloneNode
(((
SWindowLogicNode
*
)
pParent
)
->
pTspk
));
pMerge
->
pMergeKeys
=
pMergeKeys
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pMerge
->
node
.
pTargets
=
nodesCloneList
(
pPartChild
->
pTargets
);
pMerge
->
node
.
pTargets
=
nodesCloneList
(
pPartChild
->
pTargets
);
if
(
NULL
==
pMerge
->
node
.
pTargets
)
{
if
(
NULL
==
pMerge
->
node
.
pTargets
)
{
nodesDestroyNode
(
pMerge
);
code
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeAppend
(
&
pParent
->
pChildren
,
pMerge
);
}
}
return
code
;
return
nodesListMakeAppend
(
&
pParent
->
pChildren
,
pMerge
)
;
}
}
static
int32_t
stbSplSplitWindowNodeForBatch
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
static
int32_t
stbSplSplitWindowNodeForBatch
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
SLogicNode
*
pPartWindow
=
NULL
;
SLogicNode
*
pPartWindow
=
NULL
;
int32_t
code
=
stbSplCreatePartWindowNode
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
,
&
pPartWindow
);
int32_t
code
=
stbSplCreatePartWindowNode
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
,
&
pPartWindow
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbSplCreateMergeNode
(
pCxt
,
pInfo
->
pSplitNode
,
pPartWindow
);
SNodeList
*
pMergeKeys
=
NULL
;
code
=
nodesListMakeStrictAppend
(
&
pMergeKeys
,
nodesCloneNode
(((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
pTspk
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbSplCreateMergeNode
(
pCxt
,
pInfo
->
pSplitNode
,
pMergeKeys
,
pPartWindow
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyList
(
pMergeKeys
);
}
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeStrictAppend
(
&
pInfo
->
pSubplan
->
pChildren
,
code
=
nodesListMakeStrictAppend
(
&
pInfo
->
pSubplan
->
pChildren
,
...
@@ -365,6 +369,124 @@ static int32_t stbSplSplitWindowNode(SSplitContext* pCxt, SStableSplitInfo* pInf
...
@@ -365,6 +369,124 @@ static int32_t stbSplSplitWindowNode(SSplitContext* pCxt, SStableSplitInfo* pInf
}
}
}
}
static
int32_t
stbSplCreatePartAggNode
(
SAggLogicNode
*
pMergeAgg
,
SLogicNode
**
pOutput
)
{
SNodeList
*
pFunc
=
pMergeAgg
->
pAggFuncs
;
pMergeAgg
->
pAggFuncs
=
NULL
;
SNodeList
*
pGroupKeys
=
pMergeAgg
->
pGroupKeys
;
pMergeAgg
->
pGroupKeys
=
NULL
;
SNodeList
*
pTargets
=
pMergeAgg
->
node
.
pTargets
;
pMergeAgg
->
node
.
pTargets
=
NULL
;
SNodeList
*
pChildren
=
pMergeAgg
->
node
.
pChildren
;
pMergeAgg
->
node
.
pChildren
=
NULL
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SAggLogicNode
*
pPartAgg
=
nodesCloneNode
(
pMergeAgg
);
if
(
NULL
==
pPartAgg
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pGroupKeys
)
{
pPartAgg
->
pGroupKeys
=
pGroupKeys
;
code
=
createColumnByRewriteExps
(
pPartAgg
->
pGroupKeys
,
&
pPartAgg
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pGroupKeys
)
{
pMergeAgg
->
pGroupKeys
=
nodesCloneList
(
pPartAgg
->
node
.
pTargets
);
if
(
NULL
==
pMergeAgg
->
pGroupKeys
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pMergeAgg
->
node
.
pTargets
=
pTargets
;
pPartAgg
->
node
.
pChildren
=
pChildren
;
code
=
stbSplRewriteFuns
(
pFunc
,
&
pPartAgg
->
pAggFuncs
,
&
pMergeAgg
->
pAggFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExps
(
pPartAgg
->
pAggFuncs
,
&
pPartAgg
->
node
.
pTargets
);
}
nodesDestroyList
(
pFunc
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pOutput
=
(
SLogicNode
*
)
pPartAgg
;
}
else
{
nodesDestroyNode
(
pPartAgg
);
}
return
code
;
}
static
int32_t
stbSplSplitAggNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
SLogicNode
*
pPartAgg
=
NULL
;
int32_t
code
=
stbSplCreatePartAggNode
((
SAggLogicNode
*
)
pInfo
->
pSplitNode
,
&
pPartAgg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbSplCreateExchangeNode
(
pCxt
,
pInfo
->
pSplitNode
,
pPartAgg
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeStrictAppend
(
&
pInfo
->
pSubplan
->
pChildren
,
splCreateScanSubplan
(
pCxt
,
pPartAgg
,
SPLIT_FLAG_STABLE_SPLIT
));
}
pInfo
->
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
return
code
;
}
static
int32_t
stbSplCreatePartSortNode
(
SSortLogicNode
*
pMergeSort
,
SLogicNode
**
pOutput
)
{
SNodeList
*
pSortKeys
=
pMergeSort
->
pSortKeys
;
pMergeSort
->
pSortKeys
=
NULL
;
SNodeList
*
pTargets
=
pMergeSort
->
node
.
pTargets
;
pMergeSort
->
node
.
pTargets
=
NULL
;
SNodeList
*
pChildren
=
pMergeSort
->
node
.
pChildren
;
pMergeSort
->
node
.
pChildren
=
NULL
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SSortLogicNode
*
pPartSort
=
nodesCloneNode
(
pMergeSort
);
if
(
NULL
==
pPartSort
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
pMergeSort
->
node
.
pTargets
=
pTargets
;
pPartSort
->
node
.
pChildren
=
pChildren
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pPartSort
->
pSortKeys
=
pSortKeys
;
code
=
createColumnByRewriteExps
(
pPartSort
->
pSortKeys
,
&
pPartSort
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pMergeSort
->
pSortKeys
=
nodesCloneList
(
pPartSort
->
node
.
pTargets
);
if
(
NULL
==
pMergeSort
->
pSortKeys
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pOutput
=
(
SLogicNode
*
)
pPartSort
;
}
else
{
nodesDestroyNode
(
pPartSort
);
}
return
code
;
}
static
int32_t
stbSplSplitSortNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
SLogicNode
*
pPartSort
=
NULL
;
int32_t
code
=
stbSplCreatePartSortNode
((
SSortLogicNode
*
)
pInfo
->
pSplitNode
,
&
pPartSort
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SNodeList
*
pMergeKeys
=
nodesCloneList
(((
SSortLogicNode
*
)
pInfo
->
pSplitNode
)
->
pSortKeys
);
if
(
NULL
!=
pMergeKeys
)
{
code
=
stbSplCreateMergeNode
(
pCxt
,
pInfo
->
pSplitNode
,
pMergeKeys
,
pPartSort
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyList
(
pMergeKeys
);
}
}
else
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeStrictAppend
(
&
pInfo
->
pSubplan
->
pChildren
,
splCreateScanSubplan
(
pCxt
,
pPartSort
,
SPLIT_FLAG_STABLE_SPLIT
));
}
pInfo
->
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
return
code
;
}
static
int32_t
stbSplSplitScanNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
static
int32_t
stbSplSplitScanNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
int32_t
code
=
splCreateExchangeNodeForSubplan
(
pCxt
,
pInfo
->
pSubplan
,
pInfo
->
pSplitNode
,
SUBPLAN_TYPE_MERGE
);
int32_t
code
=
splCreateExchangeNodeForSubplan
(
pCxt
,
pInfo
->
pSubplan
,
pInfo
->
pSplitNode
,
SUBPLAN_TYPE_MERGE
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -386,9 +508,15 @@ static int32_t stableSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
...
@@ -386,9 +508,15 @@ static int32_t stableSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
info
.
pSplitNode
))
{
switch
(
nodeType
(
info
.
pSplitNode
))
{
case
QUERY_NODE_LOGIC_PLAN_AGG
:
code
=
stbSplSplitAggNode
(
pCxt
,
&
info
);
break
;
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
code
=
stbSplSplitWindowNode
(
pCxt
,
&
info
);
code
=
stbSplSplitWindowNode
(
pCxt
,
&
info
);
break
;
break
;
case
QUERY_NODE_LOGIC_PLAN_SORT
:
code
=
stbSplSplitSortNode
(
pCxt
,
&
info
);
break
;
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
code
=
stbSplSplitScanNode
(
pCxt
,
&
info
);
code
=
stbSplSplitScanNode
(
pCxt
,
&
info
);
break
;
break
;
...
...
source/libs/planner/test/planGroupByTest.cpp
浏览文件 @
341a46e4
...
@@ -67,3 +67,11 @@ TEST_F(PlanGroupByTest, selectFunc) {
...
@@ -67,3 +67,11 @@ TEST_F(PlanGroupByTest, selectFunc) {
run
(
"SELECT MAX(c1), c2 FROM t1 GROUP BY c3"
);
run
(
"SELECT MAX(c1), c2 FROM t1 GROUP BY c3"
);
run
(
"SELECT MAX(c1), t1.* FROM t1 GROUP BY c3"
);
run
(
"SELECT MAX(c1), t1.* FROM t1 GROUP BY c3"
);
}
}
TEST_F
(
PlanGroupByTest
,
stable
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT COUNT(*) FROM st1"
);
run
(
"SELECT COUNT(*) FROM st1 GROUP BY c1"
);
}
source/libs/planner/test/planOrderByTest.cpp
浏览文件 @
341a46e4
...
@@ -23,20 +23,27 @@ class PlanOrderByTest : public PlannerTestBase {};
...
@@ -23,20 +23,27 @@ class PlanOrderByTest : public PlannerTestBase {};
TEST_F
(
PlanOrderByTest
,
basic
)
{
TEST_F
(
PlanOrderByTest
,
basic
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
//
order by
key is in the projection list
//
ORDER BY
key is in the projection list
run
(
"
select c1 from t1 order by
c1"
);
run
(
"
SELECT c1 FROM t1 ORDER BY
c1"
);
//
order by
key is not in the projection list
//
ORDER BY
key is not in the projection list
run
(
"
select c1 from t1 order by
c2"
);
run
(
"
SELECT c1 FROM t1 ORDER BY
c2"
);
}
}
TEST_F
(
PlanOrderByTest
,
expr
)
{
TEST_F
(
PlanOrderByTest
,
expr
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"
select * from t1 order by
c1 + 10, c2"
);
run
(
"
SELECT * FROM t1 ORDER BY
c1 + 10, c2"
);
}
}
TEST_F
(
PlanOrderByTest
,
nullsOrder
)
{
TEST_F
(
PlanOrderByTest
,
nullsOrder
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"select * from t1 order by c1 desc nulls first"
);
run
(
"SELECT * FROM t1 ORDER BY c1 DESC NULLS FIRST"
);
}
TEST_F
(
PlanOrderByTest
,
stable
)
{
useDb
(
"root"
,
"test"
);
// ORDER BY key is in the projection list
run
(
"SELECT c1 FROM st1 ORDER BY c1"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录