Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0f99cc08
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看板
未验证
提交
0f99cc08
编写于
6月 11, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
6月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13736 from taosdata/feature/3.0_wxy
feat: sma index optimize
上级
b0593497
fc4b959a
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
84 addition
and
34 deletion
+84
-34
include/common/tglobal.h
include/common/tglobal.h
+1
-0
source/common/src/tglobal.c
source/common/src/tglobal.c
+4
-1
source/libs/parser/inc/parInt.h
source/libs/parser/inc/parInt.h
+3
-0
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+2
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+1
-1
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+9
-1
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+35
-16
source/libs/planner/test/planOtherTest.cpp
source/libs/planner/test/planOtherTest.cpp
+9
-0
source/libs/planner/test/planSubqueryTest.cpp
source/libs/planner/test/planSubqueryTest.cpp
+6
-0
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+14
-14
未找到文件。
include/common/tglobal.h
浏览文件 @
0f99cc08
...
@@ -96,6 +96,7 @@ extern bool tsDeadLockKillQuery;
...
@@ -96,6 +96,7 @@ extern bool tsDeadLockKillQuery;
// query client
// query client
extern
int32_t
tsQueryPolicy
;
extern
int32_t
tsQueryPolicy
;
extern
int32_t
tsQuerySmaOptimize
;
// client
// client
extern
int32_t
tsMinSlidingTime
;
extern
int32_t
tsMinSlidingTime
;
...
...
source/common/src/tglobal.c
浏览文件 @
0f99cc08
...
@@ -86,6 +86,7 @@ bool tsSmlDataFormat =
...
@@ -86,6 +86,7 @@ bool tsSmlDataFormat =
// query
// query
int32_t
tsQueryPolicy
=
1
;
int32_t
tsQueryPolicy
=
1
;
int32_t
tsQuerySmaOptimize
=
1
;
/*
/*
* denote if the server needs to compress response message at the application layer to client, including query rsp,
* denote if the server needs to compress response message at the application layer to client, including query rsp,
...
@@ -113,7 +114,7 @@ int32_t tsCompatibleModel = 1;
...
@@ -113,7 +114,7 @@ int32_t tsCompatibleModel = 1;
int32_t
tsCountAlwaysReturnValue
=
1
;
int32_t
tsCountAlwaysReturnValue
=
1
;
// 10 ms for sliding time, the value will changed in case of time precision changed
// 10 ms for sliding time, the value will changed in case of time precision changed
int32_t
tsMinSlidingTime
=
10
;
int32_t
tsMinSlidingTime
=
10
;
// the maxinum number of distict query result
// the maxinum number of distict query result
int32_t
tsMaxNumOfDistinctResults
=
1000
*
10000
;
int32_t
tsMaxNumOfDistinctResults
=
1000
*
10000
;
...
@@ -331,6 +332,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
...
@@ -331,6 +332,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
if
(
cfgAddInt32
(
pCfg
,
"compressColData"
,
tsCompressColData
,
-
1
,
100000000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"compressColData"
,
tsCompressColData
,
-
1
,
100000000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"keepColumnName"
,
tsKeepOriginalColumnName
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"keepColumnName"
,
tsKeepOriginalColumnName
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"queryPolicy"
,
tsQueryPolicy
,
1
,
3
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"queryPolicy"
,
tsQueryPolicy
,
1
,
3
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"querySmaOptimize"
,
tsQuerySmaOptimize
,
0
,
1
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"smlChildTableName"
,
""
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"smlChildTableName"
,
""
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"smlTagName"
,
tsSmlTagName
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"smlTagName"
,
tsSmlTagName
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"smlDataFormat"
,
tsSmlDataFormat
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"smlDataFormat"
,
tsSmlDataFormat
,
1
)
!=
0
)
return
-
1
;
...
@@ -541,6 +543,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
...
@@ -541,6 +543,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
tsKeepOriginalColumnName
=
cfgGetItem
(
pCfg
,
"keepColumnName"
)
->
bval
;
tsKeepOriginalColumnName
=
cfgGetItem
(
pCfg
,
"keepColumnName"
)
->
bval
;
tsNumOfTaskQueueThreads
=
cfgGetItem
(
pCfg
,
"numOfTaskQueueThreads"
)
->
i32
;
tsNumOfTaskQueueThreads
=
cfgGetItem
(
pCfg
,
"numOfTaskQueueThreads"
)
->
i32
;
tsQueryPolicy
=
cfgGetItem
(
pCfg
,
"queryPolicy"
)
->
i32
;
tsQueryPolicy
=
cfgGetItem
(
pCfg
,
"queryPolicy"
)
->
i32
;
tsQuerySmaOptimize
=
cfgGetItem
(
pCfg
,
"querySmaOptimize"
)
->
i32
;
return
0
;
return
0
;
}
}
...
...
source/libs/parser/inc/parInt.h
浏览文件 @
0f99cc08
...
@@ -24,6 +24,9 @@ extern "C" {
...
@@ -24,6 +24,9 @@ extern "C" {
#include "parUtil.h"
#include "parUtil.h"
#include "parser.h"
#include "parser.h"
#define QUERY_SMA_OPTIMIZE_DISABLE 0
#define QUERY_SMA_OPTIMIZE_ENABLE 1
int32_t
parseInsertSyntax
(
SParseContext
*
pContext
,
SQuery
**
pQuery
);
int32_t
parseInsertSyntax
(
SParseContext
*
pContext
,
SQuery
**
pQuery
);
int32_t
parseInsertSql
(
SParseContext
*
pContext
,
SQuery
**
pQuery
);
int32_t
parseInsertSql
(
SParseContext
*
pContext
,
SQuery
**
pQuery
);
int32_t
parse
(
SParseContext
*
pParseCxt
,
SQuery
**
pQuery
);
int32_t
parse
(
SParseContext
*
pParseCxt
,
SQuery
**
pQuery
);
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
0f99cc08
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "parInt.h"
#include "parInt.h"
#include "parToken.h"
#include "parToken.h"
#include "systable.h"
#include "systable.h"
#include "tglobal.h"
typedef
void
*
(
*
FMalloc
)(
size_t
);
typedef
void
*
(
*
FMalloc
)(
size_t
);
typedef
void
(
*
FFree
)(
void
*
);
typedef
void
(
*
FFree
)(
void
*
);
...
@@ -116,7 +117,7 @@ static EDealRes collectMetaKeyFromFunction(SCollectMetaKeyFromExprCxt* pCxt, SFu
...
@@ -116,7 +117,7 @@ static EDealRes collectMetaKeyFromFunction(SCollectMetaKeyFromExprCxt* pCxt, SFu
}
}
static
bool
needGetTableIndex
(
SNode
*
pStmt
)
{
static
bool
needGetTableIndex
(
SNode
*
pStmt
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
if
(
QUERY_
SMA_OPTIMIZE_ENABLE
==
tsQuerySmaOptimize
&&
QUERY_
NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pStmt
;
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pStmt
;
return
(
NULL
!=
pSelect
->
pWindow
&&
QUERY_NODE_INTERVAL_WINDOW
==
nodeType
(
pSelect
->
pWindow
));
return
(
NULL
!=
pSelect
->
pWindow
&&
QUERY_NODE_INTERVAL_WINDOW
==
nodeType
(
pSelect
->
pWindow
));
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
0f99cc08
...
@@ -1411,7 +1411,7 @@ static bool isSingleTable(SRealTableNode* pRealTable) {
...
@@ -1411,7 +1411,7 @@ static bool isSingleTable(SRealTableNode* pRealTable) {
}
}
static
int32_t
setTableIndex
(
STranslateContext
*
pCxt
,
SName
*
pName
,
SRealTableNode
*
pRealTable
)
{
static
int32_t
setTableIndex
(
STranslateContext
*
pCxt
,
SName
*
pName
,
SRealTableNode
*
pRealTable
)
{
if
(
pCxt
->
createStream
)
{
if
(
pCxt
->
createStream
||
QUERY_SMA_OPTIMIZE_DISABLE
==
tsQuerySmaOptimize
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
NULL
!=
pCxt
->
pCurrSelectStmt
&&
NULL
!=
pCxt
->
pCurrSelectStmt
->
pWindow
&&
if
(
NULL
!=
pCxt
->
pCurrSelectStmt
&&
NULL
!=
pCxt
->
pCurrSelectStmt
->
pWindow
&&
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
0f99cc08
...
@@ -158,7 +158,9 @@ class MockCatalogServiceImpl {
...
@@ -158,7 +158,9 @@ class MockCatalogServiceImpl {
}
}
*
pIndexes
=
taosArrayInit
(
it
->
second
.
size
(),
sizeof
(
STableIndexInfo
));
*
pIndexes
=
taosArrayInit
(
it
->
second
.
size
(),
sizeof
(
STableIndexInfo
));
for
(
const
auto
&
index
:
it
->
second
)
{
for
(
const
auto
&
index
:
it
->
second
)
{
taosArrayPush
(
*
pIndexes
,
&
index
);
STableIndexInfo
info
;
taosArrayPush
(
*
pIndexes
,
copyTableIndexInfo
(
&
info
,
&
index
));
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -316,6 +318,12 @@ class MockCatalogServiceImpl {
...
@@ -316,6 +318,12 @@ class MockCatalogServiceImpl {
pEpSet
->
inUse
=
0
;
pEpSet
->
inUse
=
0
;
}
}
STableIndexInfo
*
copyTableIndexInfo
(
STableIndexInfo
*
pDst
,
const
STableIndexInfo
*
pSrc
)
const
{
memcpy
(
pDst
,
pSrc
,
sizeof
(
STableIndexInfo
));
pDst
->
expr
=
strdup
(
pSrc
->
expr
);
return
pDst
;
}
std
::
string
toDbname
(
const
std
::
string
&
dbFullName
)
const
{
std
::
string
toDbname
(
const
std
::
string
&
dbFullName
)
const
{
std
::
string
::
size_type
n
=
dbFullName
.
find
(
"."
);
std
::
string
::
size_type
n
=
dbFullName
.
find
(
"."
);
if
(
n
==
std
::
string
::
npos
)
{
if
(
n
==
std
::
string
::
npos
)
{
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
0f99cc08
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include "functionMgt.h"
#include "functionMgt.h"
#include "index.h"
#include "index.h"
#include "planInt.h"
#include "planInt.h"
#include "ttime.h"
#define OPTIMIZE_FLAG_MASK(n) (1 << n)
#define OPTIMIZE_FLAG_MASK(n) (1 << n)
...
@@ -816,7 +817,8 @@ static int32_t smaOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pInde
...
@@ -816,7 +817,8 @@ static int32_t smaOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pInde
pSmaScan
->
dataRequired
=
FUNC_DATA_REQUIRED_DATA_LOAD
;
pSmaScan
->
dataRequired
=
FUNC_DATA_REQUIRED_DATA_LOAD
;
pSmaScan
->
pVgroupList
=
taosMemoryCalloc
(
1
,
sizeof
(
SVgroupsInfo
)
+
sizeof
(
SVgroupInfo
));
pSmaScan
->
pVgroupList
=
taosMemoryCalloc
(
1
,
sizeof
(
SVgroupsInfo
)
+
sizeof
(
SVgroupInfo
));
if
(
NULL
==
pSmaScan
->
pVgroupList
)
{
pSmaScan
->
node
.
pTargets
=
nodesCloneList
(
pCols
);
if
(
NULL
==
pSmaScan
->
pVgroupList
||
NULL
==
pSmaScan
->
node
.
pTargets
)
{
nodesDestroyNode
(
pSmaScan
);
nodesDestroyNode
(
pSmaScan
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
...
@@ -828,19 +830,26 @@ static int32_t smaOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pInde
...
@@ -828,19 +830,26 @@ static int32_t smaOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pInde
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
bool
smaOptEqualInterval
(
SWindowLogicNode
*
pWindow
,
STableIndexInfo
*
pIndex
)
{
static
bool
smaOptEqualInterval
(
S
ScanLogicNode
*
pScan
,
S
WindowLogicNode
*
pWindow
,
STableIndexInfo
*
pIndex
)
{
if
(
pWindow
->
interval
!=
pIndex
->
interval
||
pWindow
->
intervalUnit
!=
pIndex
->
intervalUnit
||
if
(
pWindow
->
interval
!=
pIndex
->
interval
||
pWindow
->
intervalUnit
!=
pIndex
->
intervalUnit
||
pWindow
->
offset
!=
pIndex
->
offset
||
pWindow
->
sliding
!=
pIndex
->
sliding
||
pWindow
->
offset
!=
pIndex
->
offset
||
pWindow
->
sliding
!=
pIndex
->
sliding
||
pWindow
->
slidingUnit
!=
pIndex
->
slidingUnit
)
{
pWindow
->
slidingUnit
!=
pIndex
->
slidingUnit
)
{
return
false
;
return
false
;
}
}
// todo time range
if
(
IS_TSWINDOW_SPECIFIED
(
pScan
->
scanRange
))
{
SInterval
interval
=
{.
interval
=
pIndex
->
interval
,
.
intervalUnit
=
pIndex
->
intervalUnit
,
.
offset
=
pIndex
->
offset
,
.
offsetUnit
=
TIME_UNIT_MILLISECOND
,
.
sliding
=
pIndex
->
sliding
,
.
slidingUnit
=
pIndex
->
slidingUnit
,
.
precision
=
pScan
->
node
.
precision
};
return
(
pScan
->
scanRange
.
skey
==
taosTimeTruncate
(
pScan
->
scanRange
.
skey
,
&
interval
,
pScan
->
node
.
precision
))
&&
(
pScan
->
scanRange
.
ekey
+
1
==
taosTimeTruncate
(
pScan
->
scanRange
.
ekey
+
1
,
&
interval
,
pScan
->
node
.
precision
));
}
return
true
;
return
true
;
}
}
// #define SMA_TABLE_NAME "#sma_table"
// #define SMA_COL_NAME_PREFIX "#sma_col_"
static
SNode
*
smaOptCreateSmaCol
(
SNode
*
pFunc
,
uint64_t
tableId
,
int32_t
colId
)
{
static
SNode
*
smaOptCreateSmaCol
(
SNode
*
pFunc
,
uint64_t
tableId
,
int32_t
colId
)
{
SColumnNode
*
pCol
=
nodesMakeNode
(
QUERY_NODE_COLUMN
);
SColumnNode
*
pCol
=
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
if
(
NULL
==
pCol
)
{
...
@@ -850,9 +859,7 @@ static SNode* smaOptCreateSmaCol(SNode* pFunc, uint64_t tableId, int32_t colId)
...
@@ -850,9 +859,7 @@ static SNode* smaOptCreateSmaCol(SNode* pFunc, uint64_t tableId, int32_t colId)
pCol
->
tableType
=
TSDB_SUPER_TABLE
;
pCol
->
tableType
=
TSDB_SUPER_TABLE
;
pCol
->
colId
=
colId
;
pCol
->
colId
=
colId
;
pCol
->
colType
=
COLUMN_TYPE_COLUMN
;
pCol
->
colType
=
COLUMN_TYPE_COLUMN
;
snprintf
(
pCol
->
colName
,
sizeof
(
pCol
->
colName
),
"#sma_col_%d"
,
pCol
->
colId
);
strcpy
(
pCol
->
colName
,
((
SExprNode
*
)
pFunc
)
->
aliasName
);
// strcpy(pCol->tableName, SMA_TABLE_NAME);
// strcpy(pCol->tableAlias, SMA_TABLE_NAME);
pCol
->
node
.
resType
=
((
SExprNode
*
)
pFunc
)
->
resType
;
pCol
->
node
.
resType
=
((
SExprNode
*
)
pFunc
)
->
resType
;
strcpy
(
pCol
->
node
.
aliasName
,
((
SExprNode
*
)
pFunc
)
->
aliasName
);
strcpy
(
pCol
->
node
.
aliasName
,
((
SExprNode
*
)
pFunc
)
->
aliasName
);
return
(
SNode
*
)
pCol
;
return
(
SNode
*
)
pCol
;
...
@@ -876,12 +883,13 @@ static int32_t smaOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNodeLis
...
@@ -876,12 +883,13 @@ static int32_t smaOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNodeLis
SNode
*
pFunc
=
NULL
;
SNode
*
pFunc
=
NULL
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
index
=
0
;
int32_t
index
=
0
;
int32_t
smaFuncIndex
=
-
1
;
*
pWStrartIndex
=
-
1
;
*
pWStrartIndex
=
-
1
;
FOREACH
(
pFunc
,
pFuncs
)
{
FOREACH
(
pFunc
,
pFuncs
)
{
if
(
FUNCTION_TYPE_WSTARTTS
==
((
SFunctionNode
*
)
pFunc
)
->
funcType
)
{
if
(
FUNCTION_TYPE_WSTARTTS
==
((
SFunctionNode
*
)
pFunc
)
->
funcType
)
{
*
pWStrartIndex
=
index
;
*
pWStrartIndex
=
index
;
}
}
int32_t
smaFuncIndex
=
smaOptFindSmaFunc
(
pFunc
,
pSmaFuncs
);
smaFuncIndex
=
smaOptFindSmaFunc
(
pFunc
,
pSmaFuncs
);
if
(
smaFuncIndex
<
0
)
{
if
(
smaFuncIndex
<
0
)
{
break
;
break
;
}
else
{
}
else
{
...
@@ -893,7 +901,7 @@ static int32_t smaOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNodeLis
...
@@ -893,7 +901,7 @@ static int32_t smaOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNodeLis
++
index
;
++
index
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
smaFuncIndex
>=
0
)
{
*
pOutput
=
pCols
;
*
pOutput
=
pCols
;
}
else
{
}
else
{
nodesDestroyList
(
pCols
);
nodesDestroyList
(
pCols
);
...
@@ -902,9 +910,10 @@ static int32_t smaOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNodeLis
...
@@ -902,9 +910,10 @@ static int32_t smaOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNodeLis
return
code
;
return
code
;
}
}
static
int32_t
smaOptCouldApplyIndex
(
S
WindowLogicNode
*
pWindow
,
STableIndexInfo
*
pIndex
,
SNodeList
**
pCols
,
static
int32_t
smaOptCouldApplyIndex
(
S
ScanLogicNode
*
pScan
,
STableIndexInfo
*
pIndex
,
SNodeList
**
pCols
,
int32_t
*
pWStrartIndex
)
{
int32_t
*
pWStrartIndex
)
{
if
(
!
smaOptEqualInterval
(
pWindow
,
pIndex
))
{
SWindowLogicNode
*
pWindow
=
(
SWindowLogicNode
*
)
pScan
->
node
.
pParent
;
if
(
!
smaOptEqualInterval
(
pScan
,
pWindow
,
pIndex
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SNodeList
*
pSmaFuncs
=
NULL
;
SNodeList
*
pSmaFuncs
=
NULL
;
...
@@ -961,8 +970,8 @@ static int32_t smaOptRewriteInterval(SWindowLogicNode* pInterval, int32_t wstrar
...
@@ -961,8 +970,8 @@ static int32_t smaOptRewriteInterval(SWindowLogicNode* pInterval, int32_t wstrar
return
smaOptCreateMergeKey
(
nodesListGetNode
(
pInterval
->
node
.
pTargets
,
wstrartIndex
),
pMergeKeys
);
return
smaOptCreateMergeKey
(
nodesListGetNode
(
pInterval
->
node
.
pTargets
,
wstrartIndex
),
pMergeKeys
);
}
}
static
int32_t
smaOptApplyIndex
(
SLogicSubplan
*
pLogicSubplan
,
SScanLogicNode
*
pScan
,
STableIndexInfo
*
pIndex
,
static
int32_t
smaOptApplyIndex
Ext
(
SLogicSubplan
*
pLogicSubplan
,
SScanLogicNode
*
pScan
,
STableIndexInfo
*
pIndex
,
SNodeList
*
pSmaCols
,
int32_t
wstrartIndex
)
{
SNodeList
*
pSmaCols
,
int32_t
wstrartIndex
)
{
SWindowLogicNode
*
pInterval
=
(
SWindowLogicNode
*
)
pScan
->
node
.
pParent
;
SWindowLogicNode
*
pInterval
=
(
SWindowLogicNode
*
)
pScan
->
node
.
pParent
;
SNodeList
*
pMergeTargets
=
nodesCloneList
(
pInterval
->
node
.
pTargets
);
SNodeList
*
pMergeTargets
=
nodesCloneList
(
pInterval
->
node
.
pTargets
);
if
(
NULL
==
pMergeTargets
)
{
if
(
NULL
==
pMergeTargets
)
{
...
@@ -984,6 +993,16 @@ static int32_t smaOptApplyIndex(SLogicSubplan* pLogicSubplan, SScanLogicNode* pS
...
@@ -984,6 +993,16 @@ static int32_t smaOptApplyIndex(SLogicSubplan* pLogicSubplan, SScanLogicNode* pS
return
code
;
return
code
;
}
}
static
int32_t
smaOptApplyIndex
(
SLogicSubplan
*
pLogicSubplan
,
SScanLogicNode
*
pScan
,
STableIndexInfo
*
pIndex
,
SNodeList
*
pSmaCols
,
int32_t
wstrartIndex
)
{
SLogicNode
*
pSmaScan
=
NULL
;
int32_t
code
=
smaOptCreateSmaScan
(
pScan
,
pIndex
,
pSmaCols
,
&
pSmaScan
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
replaceLogicNode
(
pLogicSubplan
,
pScan
->
node
.
pParent
,
pSmaScan
);
}
return
code
;
}
static
void
smaOptDestroySmaIndex
(
void
*
p
)
{
taosMemoryFree
(((
STableIndexInfo
*
)
p
)
->
expr
);
}
static
void
smaOptDestroySmaIndex
(
void
*
p
)
{
taosMemoryFree
(((
STableIndexInfo
*
)
p
)
->
expr
);
}
static
int32_t
smaOptimizeImpl
(
SOptimizeContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
,
SScanLogicNode
*
pScan
)
{
static
int32_t
smaOptimizeImpl
(
SOptimizeContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
,
SScanLogicNode
*
pScan
)
{
...
@@ -993,7 +1012,7 @@ static int32_t smaOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubp
...
@@ -993,7 +1012,7 @@ static int32_t smaOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubp
STableIndexInfo
*
pIndex
=
taosArrayGet
(
pScan
->
pSmaIndexes
,
i
);
STableIndexInfo
*
pIndex
=
taosArrayGet
(
pScan
->
pSmaIndexes
,
i
);
SNodeList
*
pSmaCols
=
NULL
;
SNodeList
*
pSmaCols
=
NULL
;
int32_t
wstrartIndex
=
-
1
;
int32_t
wstrartIndex
=
-
1
;
code
=
smaOptCouldApplyIndex
(
(
SWindowLogicNode
*
)
pScan
->
node
.
pParent
,
pIndex
,
&
pSmaCols
,
&
wstrartIndex
);
code
=
smaOptCouldApplyIndex
(
pScan
,
pIndex
,
&
pSmaCols
,
&
wstrartIndex
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pSmaCols
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pSmaCols
)
{
code
=
smaOptApplyIndex
(
pLogicSubplan
,
pScan
,
pIndex
,
pSmaCols
,
wstrartIndex
);
code
=
smaOptApplyIndex
(
pLogicSubplan
,
pScan
,
pIndex
,
pSmaCols
,
wstrartIndex
);
taosArrayDestroyEx
(
pScan
->
pSmaIndexes
,
smaOptDestroySmaIndex
);
taosArrayDestroyEx
(
pScan
->
pSmaIndexes
,
smaOptDestroySmaIndex
);
...
...
source/libs/planner/test/planOtherTest.cpp
浏览文件 @
0f99cc08
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include "planTestUtil.h"
#include "planTestUtil.h"
#include "planner.h"
#include "planner.h"
#include "tglobal.h"
using
namespace
std
;
using
namespace
std
;
...
@@ -45,6 +46,14 @@ TEST_F(PlanOtherTest, createSmaIndex) {
...
@@ -45,6 +46,14 @@ TEST_F(PlanOtherTest, createSmaIndex) {
run
(
"CREATE SMA INDEX idx1 ON t1 FUNCTION(MAX(c1), MIN(c3 + 10), SUM(c4)) INTERVAL(10s)"
);
run
(
"CREATE SMA INDEX idx1 ON t1 FUNCTION(MAX(c1), MIN(c3 + 10), SUM(c4)) INTERVAL(10s)"
);
run
(
"SELECT SUM(c4) FROM t1 INTERVAL(10s)"
);
run
(
"SELECT SUM(c4) FROM t1 INTERVAL(10s)"
);
run
(
"SELECT _WSTARTTS, MIN(c3 + 10) FROM t1 "
"WHERE ts BETWEEN TIMESTAMP '2022-04-01 00:00:00' AND TIMESTAMP '2022-04-30 23:59:59.999' INTERVAL(10s)"
);
run
(
"SELECT SUM(c4), MAX(c3) FROM t1 INTERVAL(10s)"
);
tsQuerySmaOptimize
=
0
;
run
(
"SELECT SUM(c4) FROM t1 INTERVAL(10s)"
);
}
}
TEST_F
(
PlanOtherTest
,
explain
)
{
TEST_F
(
PlanOtherTest
,
explain
)
{
...
...
source/libs/planner/test/planSubqueryTest.cpp
浏览文件 @
0f99cc08
...
@@ -28,6 +28,12 @@ TEST_F(PlanSubqeuryTest, basic) {
...
@@ -28,6 +28,12 @@ TEST_F(PlanSubqeuryTest, basic) {
run
(
"SELECT LAST(c1) FROM (SELECT * FROM t1)"
);
run
(
"SELECT LAST(c1) FROM (SELECT * FROM t1)"
);
run
(
"SELECT c1 FROM (SELECT TODAY() AS c1 FROM t1)"
);
run
(
"SELECT c1 FROM (SELECT TODAY() AS c1 FROM t1)"
);
run
(
"SELECT NOW() FROM t1"
);
run
(
"SELECT NOW() FROM (SELECT * FROM t1)"
);
// run("SELECT NOW() FROM (SELECT * FROM t1) ORDER BY ts");
}
}
TEST_F
(
PlanSubqeuryTest
,
doubleGroupBy
)
{
TEST_F
(
PlanSubqeuryTest
,
doubleGroupBy
)
{
...
...
tests/script/jenkins/basic.txt
浏览文件 @
0f99cc08
...
@@ -2,20 +2,20 @@
...
@@ -2,20 +2,20 @@
#======================b1-start===============
#======================b1-start===============
# ---- user
# ---- user
./test.sh -f tsim/user/basic1.sim
#
./test.sh -f tsim/user/basic1.sim
./test.sh -f tsim/user/pass_alter.sim
#
./test.sh -f tsim/user/pass_alter.sim
./test.sh -f tsim/user/pass_len.sim
#
./test.sh -f tsim/user/pass_len.sim
./test.sh -f tsim/user/user_len.sim
#
./test.sh -f tsim/user/user_len.sim
./test.sh -f tsim/user/privilege1.sim
#
./test.sh -f tsim/user/privilege1.sim
./test.sh -f tsim/user/privilege2.sim
#./test.sh -f tsim/user/privilege2.sim#
# ---- db
#
#
---- db
./test.sh -f tsim/db/create_all_options.sim
#
./test.sh -f tsim/db/create_all_options.sim
./test.sh -f tsim/db/alter_option.sim
#
./test.sh -f tsim/db/alter_option.sim
./test.sh -f tsim/db/basic1.sim
#
./test.sh -f tsim/db/basic1.sim
./test.sh -f tsim/db/basic2.sim
#
./test.sh -f tsim/db/basic2.sim
./test.sh -f tsim/db/basic3.sim
#
./test.sh -f tsim/db/basic3.sim
./test.sh -f tsim/db/basic6.sim
#
./test.sh -f tsim/db/basic6.sim
./test.sh -f tsim/db/basic7.sim
./test.sh -f tsim/db/basic7.sim
./test.sh -f tsim/db/error1.sim
./test.sh -f tsim/db/error1.sim
./test.sh -f tsim/db/taosdlog.sim
./test.sh -f tsim/db/taosdlog.sim
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录