Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b445afb5
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b445afb5
编写于
5月 31, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: stable interval split
上级
0b99a1b3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
101 addition
and
65 deletion
+101
-65
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+2
-2
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+27
-2
source/libs/parser/test/mockCatalogService.h
source/libs/parser/test/mockCatalogService.h
+1
-0
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+64
-60
source/libs/planner/test/planIntervalTest.cpp
source/libs/planner/test/planIntervalTest.cpp
+7
-1
未找到文件。
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
b445afb5
...
@@ -188,8 +188,8 @@ int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* ve
...
@@ -188,8 +188,8 @@ int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* ve
}
}
int32_t
__catalogGetDBVgInfo
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
dbFName
,
int32_t
__catalogGetDBVgInfo
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
dbFName
,
SArray
**
vgroup
List
)
{
SArray
**
pVg
List
)
{
return
0
;
return
g_mockCatalogService
->
catalogGetDBVgInfo
(
dbFName
,
pVgList
)
;
}
}
int32_t
__catalogGetDBCfg
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
int32_t
__catalogGetDBCfg
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
b445afb5
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include <iomanip>
#include <iomanip>
#include <iostream>
#include <iostream>
#include <map>
#include <map>
#include <set>
#include "tdatablock.h"
#include "tdatablock.h"
#include "tname.h"
#include "tname.h"
...
@@ -120,6 +121,25 @@ class MockCatalogServiceImpl {
...
@@ -120,6 +121,25 @@ class MockCatalogServiceImpl {
return
copyTableVgroup
(
db
,
tNameGetTableName
(
pTableName
),
vgList
);
return
copyTableVgroup
(
db
,
tNameGetTableName
(
pTableName
),
vgList
);
}
}
int32_t
catalogGetDBVgInfo
(
const
char
*
pDbFName
,
SArray
**
pVgList
)
const
{
std
::
string
dbFName
(
pDbFName
);
DbMetaCache
::
const_iterator
it
=
meta_
.
find
(
dbFName
.
substr
(
std
::
string
(
pDbFName
).
find_last_of
(
'.'
)
+
1
));
if
(
meta_
.
end
()
==
it
)
{
return
TSDB_CODE_FAILED
;
}
std
::
set
<
int32_t
>
vgSet
;
*
pVgList
=
taosArrayInit
(
it
->
second
.
size
(),
sizeof
(
SVgroupInfo
));
for
(
const
auto
&
vgs
:
it
->
second
)
{
for
(
const
auto
&
vg
:
vgs
.
second
->
vgs
)
{
if
(
0
==
vgSet
.
count
(
vg
.
vgId
))
{
taosArrayPush
(
*
pVgList
,
&
vg
);
vgSet
.
insert
(
vg
.
vgId
);
}
}
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
catalogGetUdfInfo
(
const
std
::
string
&
funcName
,
SFuncInfo
*
pInfo
)
const
{
int32_t
catalogGetUdfInfo
(
const
std
::
string
&
funcName
,
SFuncInfo
*
pInfo
)
const
{
auto
it
=
udf_
.
find
(
funcName
);
auto
it
=
udf_
.
find
(
funcName
);
if
(
udf_
.
end
()
==
it
)
{
if
(
udf_
.
end
()
==
it
)
{
...
@@ -187,8 +207,9 @@ class MockCatalogServiceImpl {
...
@@ -187,8 +207,9 @@ class MockCatalogServiceImpl {
// number of backward fills
// number of backward fills
#define NOB(n) ((n) % 2 ? (n) / 2 + 1 : (n) / 2)
#define NOB(n) ((n) % 2 ? (n) / 2 + 1 : (n) / 2)
// center aligned
// center aligned
#define CA(n, s) std::setw(NOF((n) - int((s).length()))) << "" << (s) \
#define CA(n, s) \
<< std::setw(NOB((n) - int((s).length()))) << "" << "|"
std::setw(NOF((n) - int((s).length()))) << "" << (s) << std::setw(NOB((n) - int((s).length()))) << "" \
<< "|"
// string field length
// string field length
#define SFL 20
#define SFL 20
// string field header
// string field header
...
@@ -490,6 +511,10 @@ int32_t MockCatalogService::catalogGetTableDistVgInfo(const SName* pTableName, S
...
@@ -490,6 +511,10 @@ int32_t MockCatalogService::catalogGetTableDistVgInfo(const SName* pTableName, S
return
impl_
->
catalogGetTableDistVgInfo
(
pTableName
,
pVgList
);
return
impl_
->
catalogGetTableDistVgInfo
(
pTableName
,
pVgList
);
}
}
int32_t
MockCatalogService
::
catalogGetDBVgInfo
(
const
char
*
pDbFName
,
SArray
**
pVgList
)
const
{
return
impl_
->
catalogGetDBVgInfo
(
pDbFName
,
pVgList
);
}
int32_t
MockCatalogService
::
catalogGetUdfInfo
(
const
std
::
string
&
funcName
,
SFuncInfo
*
pInfo
)
const
{
int32_t
MockCatalogService
::
catalogGetUdfInfo
(
const
std
::
string
&
funcName
,
SFuncInfo
*
pInfo
)
const
{
return
impl_
->
catalogGetUdfInfo
(
funcName
,
pInfo
);
return
impl_
->
catalogGetUdfInfo
(
funcName
,
pInfo
);
}
}
...
...
source/libs/parser/test/mockCatalogService.h
浏览文件 @
b445afb5
...
@@ -61,6 +61,7 @@ class MockCatalogService {
...
@@ -61,6 +61,7 @@ class MockCatalogService {
int32_t
catalogGetTableMeta
(
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
const
;
int32_t
catalogGetTableMeta
(
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
const
;
int32_t
catalogGetTableHashVgroup
(
const
SName
*
pTableName
,
SVgroupInfo
*
vgInfo
)
const
;
int32_t
catalogGetTableHashVgroup
(
const
SName
*
pTableName
,
SVgroupInfo
*
vgInfo
)
const
;
int32_t
catalogGetTableDistVgInfo
(
const
SName
*
pTableName
,
SArray
**
pVgList
)
const
;
int32_t
catalogGetTableDistVgInfo
(
const
SName
*
pTableName
,
SArray
**
pVgList
)
const
;
int32_t
catalogGetDBVgInfo
(
const
char
*
pDbFName
,
SArray
**
pVgList
)
const
;
int32_t
catalogGetUdfInfo
(
const
std
::
string
&
funcName
,
SFuncInfo
*
pInfo
)
const
;
int32_t
catalogGetUdfInfo
(
const
std
::
string
&
funcName
,
SFuncInfo
*
pInfo
)
const
;
int32_t
catalogGetAllMeta
(
const
SCatalogReq
*
pCatalogReq
,
SMetaData
*
pMetaData
)
const
;
int32_t
catalogGetAllMeta
(
const
SCatalogReq
*
pCatalogReq
,
SMetaData
*
pMetaData
)
const
;
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
b445afb5
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
#define SPLIT_FLAG_MASK(n) (1 << n)
#define SPLIT_FLAG_MASK(n) (1 << n)
#define SPLIT_FLAG_ST
S
SPLIT_FLAG_MASK(0)
#define SPLIT_FLAG_ST
ABLE_SPLIT
SPLIT_FLAG_MASK(0)
#define SPLIT_FLAG_SET_MASK(val, mask) (val) |= (mask)
#define SPLIT_FLAG_SET_MASK(val, mask) (val) |= (mask)
#define SPLIT_FLAG_TEST_MASK(val, mask) (((val) & (mask)) != 0)
#define SPLIT_FLAG_TEST_MASK(val, mask) (((val) & (mask)) != 0)
...
@@ -35,27 +35,6 @@ typedef struct SSplitRule {
...
@@ -35,27 +35,6 @@ typedef struct SSplitRule {
FSplit
splitFunc
;
FSplit
splitFunc
;
}
SSplitRule
;
}
SSplitRule
;
typedef
struct
SStsInfo
{
SScanLogicNode
*
pScan
;
SLogicSubplan
*
pSubplan
;
}
SStsInfo
;
typedef
struct
SCtjInfo
{
SJoinLogicNode
*
pJoin
;
SLogicNode
*
pSplitNode
;
SLogicSubplan
*
pSubplan
;
}
SCtjInfo
;
typedef
struct
SUaInfo
{
SProjectLogicNode
*
pProject
;
SLogicSubplan
*
pSubplan
;
}
SUaInfo
;
typedef
struct
SUnInfo
{
SAggLogicNode
*
pAgg
;
SLogicSubplan
*
pSubplan
;
}
SUnInfo
;
typedef
bool
(
*
FSplFindSplitNode
)(
SLogicSubplan
*
pSubplan
,
void
*
pInfo
);
typedef
bool
(
*
FSplFindSplitNode
)(
SLogicSubplan
*
pSubplan
,
void
*
pInfo
);
static
SLogicSubplan
*
splCreateSubplan
(
SSplitContext
*
pCxt
,
SLogicNode
*
pNode
,
int32_t
flag
)
{
static
SLogicSubplan
*
splCreateSubplan
(
SSplitContext
*
pCxt
,
SLogicNode
*
pNode
,
int32_t
flag
)
{
...
@@ -121,14 +100,19 @@ static bool splMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan, int32_t flag,
...
@@ -121,14 +100,19 @@ static bool splMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan, int32_t flag,
return
false
;
return
false
;
}
}
static
SLogicNode
*
stsMatchByNode
(
SLogicNode
*
pNode
)
{
typedef
struct
SStableSplitInfo
{
SScanLogicNode
*
pScan
;
SLogicSubplan
*
pSubplan
;
}
SStableSplitInfo
;
static
SLogicNode
*
stbSplMatchByNode
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
)
&&
NULL
!=
((
SScanLogicNode
*
)
pNode
)
->
pVgroupList
&&
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
)
&&
NULL
!=
((
SScanLogicNode
*
)
pNode
)
->
pVgroupList
&&
((
SScanLogicNode
*
)
pNode
)
->
pVgroupList
->
numOfVgroups
>
1
)
{
((
SScanLogicNode
*
)
pNode
)
->
pVgroupList
->
numOfVgroups
>
1
)
{
return
pNode
;
return
pNode
;
}
}
SNode
*
pChild
;
SNode
*
pChild
;
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
SLogicNode
*
pSplitNode
=
st
s
MatchByNode
((
SLogicNode
*
)
pChild
);
SLogicNode
*
pSplitNode
=
st
bSpl
MatchByNode
((
SLogicNode
*
)
pChild
);
if
(
NULL
!=
pSplitNode
)
{
if
(
NULL
!=
pSplitNode
)
{
return
pSplitNode
;
return
pSplitNode
;
}
}
...
@@ -136,8 +120,8 @@ static SLogicNode* stsMatchByNode(SLogicNode* pNode) {
...
@@ -136,8 +120,8 @@ static SLogicNode* stsMatchByNode(SLogicNode* pNode) {
return
NULL
;
return
NULL
;
}
}
static
bool
st
sFindSplitNode
(
SLogicSubplan
*
pSubplan
,
SSts
Info
*
pInfo
)
{
static
bool
st
bSplFindSplitNode
(
SLogicSubplan
*
pSubplan
,
SStableSplit
Info
*
pInfo
)
{
SLogicNode
*
pSplitNode
=
st
s
MatchByNode
(
pSubplan
->
pNode
);
SLogicNode
*
pSplitNode
=
st
bSpl
MatchByNode
(
pSubplan
->
pNode
);
if
(
NULL
!=
pSplitNode
)
{
if
(
NULL
!=
pSplitNode
)
{
pInfo
->
pScan
=
(
SScanLogicNode
*
)
pSplitNode
;
pInfo
->
pScan
=
(
SScanLogicNode
*
)
pSplitNode
;
pInfo
->
pSubplan
=
pSubplan
;
pInfo
->
pSubplan
=
pSubplan
;
...
@@ -145,13 +129,13 @@ static bool stsFindSplitNode(SLogicSubplan* pSubplan, SStsInfo* pInfo) {
...
@@ -145,13 +129,13 @@ static bool stsFindSplitNode(SLogicSubplan* pSubplan, SStsInfo* pInfo) {
return
NULL
!=
pSplitNode
;
return
NULL
!=
pSplitNode
;
}
}
static
int32_t
st
s
Split
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
static
int32_t
st
able
Split
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
SSt
s
Info
info
=
{
0
};
SSt
ableSplit
Info
info
=
{
0
};
if
(
!
splMatch
(
pCxt
,
pSubplan
,
SPLIT_FLAG_ST
S
,
(
FSplFindSplitNode
)
sts
FindSplitNode
,
&
info
))
{
if
(
!
splMatch
(
pCxt
,
pSubplan
,
SPLIT_FLAG_ST
ABLE_SPLIT
,
(
FSplFindSplitNode
)
stbSpl
FindSplitNode
,
&
info
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
code
=
nodesListMakeStrictAppend
(
&
info
.
pSubplan
->
pChildren
,
int32_t
code
=
nodesListMakeStrictAppend
(
&
info
.
pSubplan
->
pChildren
,
splCreateSubplan
(
pCxt
,
(
SLogicNode
*
)
info
.
pScan
,
SPLIT_FLAG_ST
S
));
splCreateSubplan
(
pCxt
,
(
SLogicNode
*
)
info
.
pScan
,
SPLIT_FLAG_ST
ABLE_SPLIT
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
splCreateExchangeNode
(
pCxt
,
info
.
pSubplan
,
(
SLogicNode
*
)
info
.
pScan
,
SUBPLAN_TYPE_MERGE
);
code
=
splCreateExchangeNode
(
pCxt
,
info
.
pSubplan
,
(
SLogicNode
*
)
info
.
pScan
,
SUBPLAN_TYPE_MERGE
);
}
}
...
@@ -160,7 +144,13 @@ static int32_t stsSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
...
@@ -160,7 +144,13 @@ static int32_t stsSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
return
code
;
return
code
;
}
}
static
bool
needSplit
(
SJoinLogicNode
*
pJoin
)
{
typedef
struct
SSigTbJoinSplitInfo
{
SJoinLogicNode
*
pJoin
;
SLogicNode
*
pSplitNode
;
SLogicSubplan
*
pSubplan
;
}
SSigTbJoinSplitInfo
;
static
bool
sigTbJoinSplNeedSplit
(
SJoinLogicNode
*
pJoin
)
{
if
(
!
pJoin
->
isSingleTableJoin
)
{
if
(
!
pJoin
->
isSingleTableJoin
)
{
return
false
;
return
false
;
}
}
...
@@ -168,13 +158,13 @@ static bool needSplit(SJoinLogicNode* pJoin) {
...
@@ -168,13 +158,13 @@ static bool needSplit(SJoinLogicNode* pJoin) {
QUERY_NODE_LOGIC_PLAN_EXCHANGE
!=
nodeType
(
nodesListGetNode
(
pJoin
->
node
.
pChildren
,
1
));
QUERY_NODE_LOGIC_PLAN_EXCHANGE
!=
nodeType
(
nodesListGetNode
(
pJoin
->
node
.
pChildren
,
1
));
}
}
static
SJoinLogicNode
*
ctj
MatchByNode
(
SLogicNode
*
pNode
)
{
static
SJoinLogicNode
*
sigTbJoinSpl
MatchByNode
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_JOIN
==
nodeType
(
pNode
)
&&
n
eedSplit
((
SJoinLogicNode
*
)
pNode
))
{
if
(
QUERY_NODE_LOGIC_PLAN_JOIN
==
nodeType
(
pNode
)
&&
sigTbJoinSplN
eedSplit
((
SJoinLogicNode
*
)
pNode
))
{
return
(
SJoinLogicNode
*
)
pNode
;
return
(
SJoinLogicNode
*
)
pNode
;
}
}
SNode
*
pChild
;
SNode
*
pChild
;
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
SJoinLogicNode
*
pSplitNode
=
ctj
MatchByNode
((
SLogicNode
*
)
pChild
);
SJoinLogicNode
*
pSplitNode
=
sigTbJoinSpl
MatchByNode
((
SLogicNode
*
)
pChild
);
if
(
NULL
!=
pSplitNode
)
{
if
(
NULL
!=
pSplitNode
)
{
return
pSplitNode
;
return
pSplitNode
;
}
}
...
@@ -182,8 +172,8 @@ static SJoinLogicNode* ctjMatchByNode(SLogicNode* pNode) {
...
@@ -182,8 +172,8 @@ static SJoinLogicNode* ctjMatchByNode(SLogicNode* pNode) {
return
NULL
;
return
NULL
;
}
}
static
bool
ctjFindSplitNode
(
SLogicSubplan
*
pSubplan
,
SCtj
Info
*
pInfo
)
{
static
bool
sigTbJoinSplFindSplitNode
(
SLogicSubplan
*
pSubplan
,
SSigTbJoinSplit
Info
*
pInfo
)
{
SJoinLogicNode
*
pJoin
=
ctj
MatchByNode
(
pSubplan
->
pNode
);
SJoinLogicNode
*
pJoin
=
sigTbJoinSpl
MatchByNode
(
pSubplan
->
pNode
);
if
(
NULL
!=
pJoin
)
{
if
(
NULL
!=
pJoin
)
{
pInfo
->
pJoin
=
pJoin
;
pInfo
->
pJoin
=
pJoin
;
pInfo
->
pSplitNode
=
nodesListGetNode
(
pJoin
->
node
.
pChildren
,
1
);
pInfo
->
pSplitNode
=
nodesListGetNode
(
pJoin
->
node
.
pChildren
,
1
);
...
@@ -192,9 +182,9 @@ static bool ctjFindSplitNode(SLogicSubplan* pSubplan, SCtjInfo* pInfo) {
...
@@ -192,9 +182,9 @@ static bool ctjFindSplitNode(SLogicSubplan* pSubplan, SCtjInfo* pInfo) {
return
NULL
!=
pJoin
;
return
NULL
!=
pJoin
;
}
}
static
int32_t
ctj
Split
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
static
int32_t
singleTableJoin
Split
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
S
Ctj
Info
info
=
{
0
};
S
SigTbJoinSplit
Info
info
=
{
0
};
if
(
!
splMatch
(
pCxt
,
pSubplan
,
0
,
(
FSplFindSplitNode
)
ctj
FindSplitNode
,
&
info
))
{
if
(
!
splMatch
(
pCxt
,
pSubplan
,
0
,
(
FSplFindSplitNode
)
sigTbJoinSpl
FindSplitNode
,
&
info
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
code
=
nodesListMakeStrictAppend
(
&
info
.
pSubplan
->
pChildren
,
splCreateSubplan
(
pCxt
,
info
.
pSplitNode
,
0
));
int32_t
code
=
nodesListMakeStrictAppend
(
&
info
.
pSubplan
->
pChildren
,
splCreateSubplan
(
pCxt
,
info
.
pSplitNode
,
0
));
...
@@ -277,13 +267,18 @@ static int32_t unionSplitSubplan(SSplitContext* pCxt, SLogicSubplan* pUnionSubpl
...
@@ -277,13 +267,18 @@ static int32_t unionSplitSubplan(SSplitContext* pCxt, SLogicSubplan* pUnionSubpl
return
code
;
return
code
;
}
}
static
SLogicNode
*
uaMatchByNode
(
SLogicNode
*
pNode
)
{
typedef
struct
SUnionAllSplitInfo
{
SProjectLogicNode
*
pProject
;
SLogicSubplan
*
pSubplan
;
}
SUnionAllSplitInfo
;
static
SLogicNode
*
unionAllMatchByNode
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_PROJECT
==
nodeType
(
pNode
)
&&
LIST_LENGTH
(
pNode
->
pChildren
)
>
1
)
{
if
(
QUERY_NODE_LOGIC_PLAN_PROJECT
==
nodeType
(
pNode
)
&&
LIST_LENGTH
(
pNode
->
pChildren
)
>
1
)
{
return
pNode
;
return
pNode
;
}
}
SNode
*
pChild
;
SNode
*
pChild
;
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
SLogicNode
*
pSplitNode
=
u
a
MatchByNode
((
SLogicNode
*
)
pChild
);
SLogicNode
*
pSplitNode
=
u
nionAll
MatchByNode
((
SLogicNode
*
)
pChild
);
if
(
NULL
!=
pSplitNode
)
{
if
(
NULL
!=
pSplitNode
)
{
return
pSplitNode
;
return
pSplitNode
;
}
}
...
@@ -291,8 +286,8 @@ static SLogicNode* uaMatchByNode(SLogicNode* pNode) {
...
@@ -291,8 +286,8 @@ static SLogicNode* uaMatchByNode(SLogicNode* pNode) {
return
NULL
;
return
NULL
;
}
}
static
bool
u
aFindSplitNode
(
SLogicSubplan
*
pSubplan
,
SUa
Info
*
pInfo
)
{
static
bool
u
nionAllFindSplitNode
(
SLogicSubplan
*
pSubplan
,
SUnionAllSplit
Info
*
pInfo
)
{
SLogicNode
*
pSplitNode
=
u
a
MatchByNode
(
pSubplan
->
pNode
);
SLogicNode
*
pSplitNode
=
u
nionAll
MatchByNode
(
pSubplan
->
pNode
);
if
(
NULL
!=
pSplitNode
)
{
if
(
NULL
!=
pSplitNode
)
{
pInfo
->
pProject
=
(
SProjectLogicNode
*
)
pSplitNode
;
pInfo
->
pProject
=
(
SProjectLogicNode
*
)
pSplitNode
;
pInfo
->
pSubplan
=
pSubplan
;
pInfo
->
pSubplan
=
pSubplan
;
...
@@ -300,13 +295,13 @@ static bool uaFindSplitNode(SLogicSubplan* pSubplan, SUaInfo* pInfo) {
...
@@ -300,13 +295,13 @@ static bool uaFindSplitNode(SLogicSubplan* pSubplan, SUaInfo* pInfo) {
return
NULL
!=
pSplitNode
;
return
NULL
!=
pSplitNode
;
}
}
static
int32_t
u
a
CreateExchangeNode
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
SProjectLogicNode
*
pProject
)
{
static
int32_t
u
nionAll
CreateExchangeNode
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
SProjectLogicNode
*
pProject
)
{
SExchangeLogicNode
*
pExchange
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_EXCHANGE
);
SExchangeLogicNode
*
pExchange
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_EXCHANGE
);
if
(
NULL
==
pExchange
)
{
if
(
NULL
==
pExchange
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pExchange
->
srcGroupId
=
pCxt
->
groupId
;
pExchange
->
srcGroupId
=
pCxt
->
groupId
;
// pExchange->precision = pScan->pMeta->tableInfo
.precision;
pExchange
->
precision
=
pProject
->
node
.
precision
;
pExchange
->
node
.
pTargets
=
nodesCloneList
(
pProject
->
node
.
pTargets
);
pExchange
->
node
.
pTargets
=
nodesCloneList
(
pProject
->
node
.
pTargets
);
if
(
NULL
==
pExchange
->
node
.
pTargets
)
{
if
(
NULL
==
pExchange
->
node
.
pTargets
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -332,28 +327,33 @@ static int32_t uaCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan
...
@@ -332,28 +327,33 @@ static int32_t uaCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
static
int32_t
u
a
Split
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
static
int32_t
u
nionAll
Split
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
SU
a
Info
info
=
{
0
};
SU
nionAllSplit
Info
info
=
{
0
};
if
(
!
splMatch
(
pCxt
,
pSubplan
,
0
,
(
FSplFindSplitNode
)
u
a
FindSplitNode
,
&
info
))
{
if
(
!
splMatch
(
pCxt
,
pSubplan
,
0
,
(
FSplFindSplitNode
)
u
nionAll
FindSplitNode
,
&
info
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
code
=
unionSplitSubplan
(
pCxt
,
info
.
pSubplan
,
(
SLogicNode
*
)
info
.
pProject
);
int32_t
code
=
unionSplitSubplan
(
pCxt
,
info
.
pSubplan
,
(
SLogicNode
*
)
info
.
pProject
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
u
a
CreateExchangeNode
(
pCxt
,
info
.
pSubplan
,
info
.
pProject
);
code
=
u
nionAll
CreateExchangeNode
(
pCxt
,
info
.
pSubplan
,
info
.
pProject
);
}
}
++
(
pCxt
->
groupId
);
++
(
pCxt
->
groupId
);
pCxt
->
split
=
true
;
pCxt
->
split
=
true
;
return
code
;
return
code
;
}
}
static
SLogicNode
*
unMatchByNode
(
SLogicNode
*
pNode
)
{
typedef
struct
SUnionDistinctSplitInfo
{
SAggLogicNode
*
pAgg
;
SLogicSubplan
*
pSubplan
;
}
SUnionDistinctSplitInfo
;
static
SLogicNode
*
unionDistinctMatchByNode
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_AGG
==
nodeType
(
pNode
)
&&
LIST_LENGTH
(
pNode
->
pChildren
)
>
1
)
{
if
(
QUERY_NODE_LOGIC_PLAN_AGG
==
nodeType
(
pNode
)
&&
LIST_LENGTH
(
pNode
->
pChildren
)
>
1
)
{
return
pNode
;
return
pNode
;
}
}
SNode
*
pChild
;
SNode
*
pChild
;
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
SLogicNode
*
pSplitNode
=
unMatchByNode
((
SLogicNode
*
)
pChild
);
SLogicNode
*
pSplitNode
=
un
ionDistinct
MatchByNode
((
SLogicNode
*
)
pChild
);
if
(
NULL
!=
pSplitNode
)
{
if
(
NULL
!=
pSplitNode
)
{
return
pSplitNode
;
return
pSplitNode
;
}
}
...
@@ -378,8 +378,8 @@ static int32_t unCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan
...
@@ -378,8 +378,8 @@ static int32_t unCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan
return
nodesListMakeAppend
(
&
pAgg
->
node
.
pChildren
,
pExchange
);
return
nodesListMakeAppend
(
&
pAgg
->
node
.
pChildren
,
pExchange
);
}
}
static
bool
un
FindSplitNode
(
SLogicSubplan
*
pSubplan
,
SUn
Info
*
pInfo
)
{
static
bool
un
ionDistinctFindSplitNode
(
SLogicSubplan
*
pSubplan
,
SUnionDistinctSplit
Info
*
pInfo
)
{
SLogicNode
*
pSplitNode
=
unMatchByNode
(
pSubplan
->
pNode
);
SLogicNode
*
pSplitNode
=
un
ionDistinct
MatchByNode
(
pSubplan
->
pNode
);
if
(
NULL
!=
pSplitNode
)
{
if
(
NULL
!=
pSplitNode
)
{
pInfo
->
pAgg
=
(
SAggLogicNode
*
)
pSplitNode
;
pInfo
->
pAgg
=
(
SAggLogicNode
*
)
pSplitNode
;
pInfo
->
pSubplan
=
pSubplan
;
pInfo
->
pSubplan
=
pSubplan
;
...
@@ -387,9 +387,9 @@ static bool unFindSplitNode(SLogicSubplan* pSubplan, SUnInfo* pInfo) {
...
@@ -387,9 +387,9 @@ static bool unFindSplitNode(SLogicSubplan* pSubplan, SUnInfo* pInfo) {
return
NULL
!=
pSplitNode
;
return
NULL
!=
pSplitNode
;
}
}
static
int32_t
unSplit
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
static
int32_t
un
ionDistinct
Split
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
SUnInfo
info
=
{
0
};
SUn
ionDistinctSplit
Info
info
=
{
0
};
if
(
!
splMatch
(
pCxt
,
pSubplan
,
0
,
(
FSplFindSplitNode
)
unFindSplitNode
,
&
info
))
{
if
(
!
splMatch
(
pCxt
,
pSubplan
,
0
,
(
FSplFindSplitNode
)
un
ionDistinct
FindSplitNode
,
&
info
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -402,10 +402,14 @@ static int32_t unSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
...
@@ -402,10 +402,14 @@ static int32_t unSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
return
code
;
return
code
;
}
}
static
const
SSplitRule
splitRuleSet
[]
=
{{.
pName
=
"SuperTableScan"
,
.
splitFunc
=
stsSplit
},
// clang-format off
{.
pName
=
"ChildTableJoin"
,
.
splitFunc
=
ctjSplit
},
static
const
SSplitRule
splitRuleSet
[]
=
{
{.
pName
=
"UnionAll"
,
.
splitFunc
=
uaSplit
},
{.
pName
=
"SuperTableSplit"
,
.
splitFunc
=
stableSplit
},
{.
pName
=
"Union"
,
.
splitFunc
=
unSplit
}};
{.
pName
=
"SingleTableJoinSplit"
,
.
splitFunc
=
singleTableJoinSplit
},
{.
pName
=
"UnionAllSplit"
,
.
splitFunc
=
unionAllSplit
},
{.
pName
=
"UnionDistinctSplit"
,
.
splitFunc
=
unionDistinctSplit
}
};
// clang-format on
static
const
int32_t
splitRuleNum
=
(
sizeof
(
splitRuleSet
)
/
sizeof
(
SSplitRule
));
static
const
int32_t
splitRuleNum
=
(
sizeof
(
splitRuleSet
)
/
sizeof
(
SSplitRule
));
...
...
source/libs/planner/test/planIntervalTest.cpp
浏览文件 @
b445afb5
...
@@ -50,4 +50,10 @@ TEST_F(PlanIntervalTest, selectFunc) {
...
@@ -50,4 +50,10 @@ TEST_F(PlanIntervalTest, selectFunc) {
run
(
"SELECT MAX(c1), MIN(c1) FROM t1 INTERVAL(10s)"
);
run
(
"SELECT MAX(c1), MIN(c1) FROM t1 INTERVAL(10s)"
);
// select function along with the columns of select row, and with INTERVAL clause
// select function along with the columns of select row, and with INTERVAL clause
run
(
"SELECT MAX(c1), c2 FROM t1 INTERVAL(10s)"
);
run
(
"SELECT MAX(c1), c2 FROM t1 INTERVAL(10s)"
);
}
}
\ No newline at end of file
TEST_F
(
PlanIntervalTest
,
stable
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT COUNT(*) FROM st1 INTERVAL(10s)"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录