Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6a78053b
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
6a78053b
编写于
8月 14, 2023
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add hint supporting
上级
6ce28e88
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
2844 addition
and
2739 deletion
+2844
-2739
include/common/tmsg.h
include/common/tmsg.h
+1
-1
include/common/ttokendef.h
include/common/ttokendef.h
+80
-77
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+13
-0
source/libs/executor/src/mergejoinoperator.c
source/libs/executor/src/mergejoinoperator.c
+10
-5
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+18
-0
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+2
-1
source/libs/parser/inc/parUtil.h
source/libs/parser/inc/parUtil.h
+1
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+13
-2
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+2
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+1
-1
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+4
-1
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2672
-2642
source/libs/planner/inc/planInt.h
source/libs/planner/inc/planInt.h
+1
-0
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+1
-0
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+7
-7
source/libs/planner/src/planUtil.c
source/libs/planner/src/planUtil.c
+17
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
6a78053b
...
...
@@ -247,6 +247,7 @@ typedef enum ENodeType {
QUERY_NODE_WHEN_THEN
,
QUERY_NODE_CASE_WHEN
,
QUERY_NODE_EVENT_WINDOW
,
QUERY_NODE_HINT
,
// Statement nodes are used in parser and planner module.
QUERY_NODE_SET_OPERATOR
=
100
,
...
...
@@ -950,7 +951,6 @@ typedef struct STimeWindow {
}
STimeWindow
;
typedef
struct
SQueryHint
{
bool
withHint
;
bool
batchScan
;
}
SQueryHint
;
...
...
include/common/ttokendef.h
浏览文件 @
6a78053b
...
...
@@ -276,83 +276,86 @@
#define TK_JOIN 258
#define TK_INNER 259
#define TK_SELECT 260
#define TK_DISTINCT 261
#define TK_WHERE 262
#define TK_PARTITION 263
#define TK_BY 264
#define TK_SESSION 265
#define TK_STATE_WINDOW 266
#define TK_EVENT_WINDOW 267
#define TK_SLIDING 268
#define TK_FILL 269
#define TK_VALUE 270
#define TK_VALUE_F 271
#define TK_NONE 272
#define TK_PREV 273
#define TK_NULL_F 274
#define TK_LINEAR 275
#define TK_NEXT 276
#define TK_HAVING 277
#define TK_RANGE 278
#define TK_EVERY 279
#define TK_ORDER 280
#define TK_SLIMIT 281
#define TK_SOFFSET 282
#define TK_LIMIT 283
#define TK_OFFSET 284
#define TK_ASC 285
#define TK_NULLS 286
#define TK_ABORT 287
#define TK_AFTER 288
#define TK_ATTACH 289
#define TK_BEFORE 290
#define TK_BEGIN 291
#define TK_BITAND 292
#define TK_BITNOT 293
#define TK_BITOR 294
#define TK_BLOCKS 295
#define TK_CHANGE 296
#define TK_COMMA 297
#define TK_CONCAT 298
#define TK_CONFLICT 299
#define TK_COPY 300
#define TK_DEFERRED 301
#define TK_DELIMITERS 302
#define TK_DETACH 303
#define TK_DIVIDE 304
#define TK_DOT 305
#define TK_EACH 306
#define TK_FAIL 307
#define TK_FILE 308
#define TK_FOR 309
#define TK_GLOB 310
#define TK_ID 311
#define TK_IMMEDIATE 312
#define TK_IMPORT 313
#define TK_INITIALLY 314
#define TK_INSTEAD 315
#define TK_ISNULL 316
#define TK_KEY 317
#define TK_MODULES 318
#define TK_NK_BITNOT 319
#define TK_NK_SEMI 320
#define TK_NOTNULL 321
#define TK_OF 322
#define TK_PLUS 323
#define TK_PRIVILEGE 324
#define TK_RAISE 325
#define TK_RESTRICT 326
#define TK_ROW 327
#define TK_SEMI 328
#define TK_STAR 329
#define TK_STATEMENT 330
#define TK_STRICT 331
#define TK_STRING 332
#define TK_TIMES 333
#define TK_VALUES 334
#define TK_VARIABLE 335
#define TK_VIEW 336
#define TK_WAL 337
#define TK_NO_BATCH_SCAN 261
#define TK_BATCH_SCAN 262
#define TK_DISTINCT 263
#define TK_WHERE 264
#define TK_PARTITION 265
#define TK_BY 266
#define TK_SESSION 267
#define TK_STATE_WINDOW 268
#define TK_EVENT_WINDOW 269
#define TK_SLIDING 270
#define TK_FILL 271
#define TK_VALUE 272
#define TK_VALUE_F 273
#define TK_NONE 274
#define TK_PREV 275
#define TK_NULL_F 276
#define TK_LINEAR 277
#define TK_NEXT 278
#define TK_HAVING 279
#define TK_RANGE 280
#define TK_EVERY 281
#define TK_ORDER 282
#define TK_SLIMIT 283
#define TK_SOFFSET 284
#define TK_LIMIT 285
#define TK_OFFSET 286
#define TK_ASC 287
#define TK_NULLS 288
#define TK_ABORT 289
#define TK_AFTER 290
#define TK_ATTACH 291
#define TK_BEFORE 292
#define TK_BEGIN 293
#define TK_BITAND 294
#define TK_BITNOT 295
#define TK_BITOR 296
#define TK_BLOCKS 297
#define TK_CHANGE 298
#define TK_COMMA 299
#define TK_CONCAT 300
#define TK_CONFLICT 301
#define TK_COPY 302
#define TK_DEFERRED 303
#define TK_DELIMITERS 304
#define TK_DETACH 305
#define TK_DIVIDE 306
#define TK_DOT 307
#define TK_EACH 308
#define TK_FAIL 309
#define TK_FILE 310
#define TK_FOR 311
#define TK_GLOB 312
#define TK_ID 313
#define TK_IMMEDIATE 314
#define TK_IMPORT 315
#define TK_INITIALLY 316
#define TK_INSTEAD 317
#define TK_ISNULL 318
#define TK_KEY 319
#define TK_MODULES 320
#define TK_NK_BITNOT 321
#define TK_NK_SEMI 322
#define TK_NOTNULL 323
#define TK_OF 324
#define TK_PLUS 325
#define TK_PRIVILEGE 326
#define TK_RAISE 327
#define TK_RESTRICT 328
#define TK_ROW 329
#define TK_SEMI 330
#define TK_STAR 331
#define TK_STATEMENT 332
#define TK_STRICT 333
#define TK_STRING 334
#define TK_TIMES 335
#define TK_VALUES 336
#define TK_VARIABLE 337
#define TK_VIEW 338
#define TK_WAL 339
#define TK_NK_SPACE 600
...
...
include/libs/nodes/querynodes.h
浏览文件 @
6a78053b
...
...
@@ -116,6 +116,18 @@ typedef struct SLeftValueNode {
ENodeType
type
;
}
SLeftValueNode
;
typedef
enum
EHintOption
{
HINT_NO_BATCH_SCAN
=
1
,
HINT_BATCH_SCAN
,
}
EHintOption
;
typedef
struct
SHintNode
{
ENodeType
type
;
EHintOption
option
;
char
*
literal
;
void
*
value
;
}
SHintNode
;
typedef
struct
SOperatorNode
{
SExprNode
node
;
// QUERY_NODE_OPERATOR
EOperatorType
opType
;
...
...
@@ -304,6 +316,7 @@ typedef struct SSelectStmt {
SLimitNode
*
pLimit
;
SLimitNode
*
pSlimit
;
STimeWindow
timeRange
;
SNodeList
*
pHint
;
char
stmtName
[
TSDB_TABLE_NAME_LEN
];
uint8_t
precision
;
int32_t
selectFuncNum
;
...
...
source/libs/executor/src/mergejoinoperator.c
浏览文件 @
6a78053b
...
...
@@ -236,6 +236,9 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
goto
_error
;
}
numOfDownstream
=
2
;
}
else
{
pInfo
->
downstreamResBlkId
[
0
]
=
getOperatorResultBlockId
(
pDownstream
[
0
],
0
);
pInfo
->
downstreamResBlkId
[
1
]
=
getOperatorResultBlockId
(
pDownstream
[
1
],
1
);
}
int32_t
numOfCols
=
0
;
...
...
@@ -653,10 +656,12 @@ static int32_t mergeJoinJoinDownstreamTsRanges(SOperatorInfo* pOperator, int64_t
static
void
setMergeJoinDone
(
SOperatorInfo
*
pOperator
)
{
setOperatorCompleted
(
pOperator
);
freeOperatorParam
(
pOperator
->
pDownstreamGetParams
[
0
],
OP_GET_PARAM
);
freeOperatorParam
(
pOperator
->
pDownstreamGetParams
[
1
],
OP_GET_PARAM
);
pOperator
->
pDownstreamGetParams
[
0
]
=
NULL
;
pOperator
->
pDownstreamGetParams
[
1
]
=
NULL
;
if
(
pOperator
->
pDownstreamGetParams
)
{
freeOperatorParam
(
pOperator
->
pDownstreamGetParams
[
0
],
OP_GET_PARAM
);
freeOperatorParam
(
pOperator
->
pDownstreamGetParams
[
1
],
OP_GET_PARAM
);
pOperator
->
pDownstreamGetParams
[
0
]
=
NULL
;
pOperator
->
pDownstreamGetParams
[
1
]
=
NULL
;
}
}
static
bool
mergeJoinGetNextTimestamp
(
SOperatorInfo
*
pOperator
,
int64_t
*
pLeftTs
,
int64_t
*
pRightTs
)
{
...
...
@@ -785,7 +790,7 @@ void resetMergeJoinOperator(struct SOperatorInfo* pOperator) {
SSDataBlock
*
doMergeJoin
(
struct
SOperatorInfo
*
pOperator
)
{
SMJoinOperatorInfo
*
pJoinInfo
=
pOperator
->
info
;
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
if
(
NULL
==
pOperator
->
pDownstreamGetParams
[
0
]
||
NULL
==
pOperator
->
pDownstreamGetParams
[
1
])
{
if
(
NULL
==
pOperator
->
pDownstreamGetParams
||
NULL
==
pOperator
->
pDownstreamGetParams
[
0
]
||
NULL
==
pOperator
->
pDownstreamGetParams
[
1
])
{
qError
(
"total merge join res rows:%"
PRId64
,
pJoinInfo
->
resRows
);
return
NULL
;
}
else
{
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
6a78053b
...
...
@@ -301,6 +301,8 @@ SNode* nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SCaseWhenNode
));
case
QUERY_NODE_EVENT_WINDOW
:
return
makeNode
(
type
,
sizeof
(
SEventWindowNode
));
case
QUERY_NODE_HINT
:
return
makeNode
(
type
,
sizeof
(
SHintNode
));
case
QUERY_NODE_SET_OPERATOR
:
return
makeNode
(
type
,
sizeof
(
SSetOperator
));
case
QUERY_NODE_SELECT_STMT
:
...
...
@@ -656,6 +658,15 @@ static void destroyTableCfg(STableCfg* pCfg) {
static
void
destroySmaIndex
(
void
*
pIndex
)
{
taosMemoryFree
(((
STableIndexInfo
*
)
pIndex
)
->
expr
);
}
static
void
destroyHintValue
(
EHintOption
option
,
void
*
value
)
{
switch
(
option
)
{
default:
break
;
}
taosMemoryFree
(
value
);
}
void
nodesDestroyNode
(
SNode
*
pNode
)
{
if
(
NULL
==
pNode
)
{
return
;
...
...
@@ -814,6 +825,12 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyNode
(
pEvent
->
pEndCond
);
break
;
}
case
QUERY_NODE_HINT
:
{
SHintNode
*
pHint
=
(
SHintNode
*
)
pNode
;
taosMemoryFreeClear
(
pHint
->
literal
);
destroyHintValue
(
pHint
->
option
,
pHint
->
value
);
break
;
}
case
QUERY_NODE_SET_OPERATOR
:
{
SSetOperator
*
pStmt
=
(
SSetOperator
*
)
pNode
;
nodesDestroyList
(
pStmt
->
pProjectionList
);
...
...
@@ -840,6 +857,7 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyList
(
pStmt
->
pOrderByList
);
nodesDestroyNode
((
SNode
*
)
pStmt
->
pLimit
);
nodesDestroyNode
((
SNode
*
)
pStmt
->
pSlimit
);
nodesDestroyList
(
pStmt
->
pHint
);
break
;
}
case
QUERY_NODE_VNODE_MODIFY_STMT
:
{
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
6a78053b
...
...
@@ -101,6 +101,7 @@ SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode
SNode
*
createColumnNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pTableAlias
,
SToken
*
pColumnName
);
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
);
SNode
*
createHintNode
(
SAstCreateContext
*
pCxt
,
EHintOption
option
,
const
SToken
*
pLiteral
);
SNode
*
createIdentifierValueNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pLiteral
);
SNode
*
createDurationValueNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLiteral
);
SNode
*
createDefaultDatabaseCondValue
(
SAstCreateContext
*
pCxt
);
...
...
@@ -142,7 +143,7 @@ SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit);
SNode
*
addRangeClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pRange
);
SNode
*
addEveryClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pEvery
);
SNode
*
addFillClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pFill
);
SNode
*
createSelectStmt
(
SAstCreateContext
*
pCxt
,
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
);
SNode
*
createSelectStmt
(
SAstCreateContext
*
pCxt
,
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
,
SNodeList
*
pHint
);
SNode
*
createSetOperator
(
SAstCreateContext
*
pCxt
,
ESetOperatorType
type
,
SNode
*
pLeft
,
SNode
*
pRight
);
SDataType
createDataType
(
uint8_t
type
);
...
...
source/libs/parser/inc/parUtil.h
浏览文件 @
6a78053b
...
...
@@ -116,7 +116,7 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName,
int32_t
getTableCfgFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
STableCfg
**
pOutput
);
int32_t
getDnodeListFromCache
(
SParseMetaCache
*
pMetaCache
,
SArray
**
pDnodes
);
void
destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
,
bool
request
);
SNode
*
createSelectStmtImpl
(
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
);
SNode
*
createSelectStmtImpl
(
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
,
SNodeList
*
pHint
);
/**
* @brief return a - b with overflow check
...
...
source/libs/parser/inc/sql.y
浏览文件 @
6a78053b
...
...
@@ -1024,12 +1024,12 @@ query_specification(A) ::=
}
hint_opt(A) ::= . { A = false; }
hint_opt(A) ::= NO_BATCH_SCAN NK_LP NK_RP. { A = createHintNode(pCxt, HINT_NO_BATCH_SCAN, NULL); }
hint_opt(A) ::= BATCH_SCAN NK_LP NK_RP. { A = createHintNode(pCxt, HINT_BATCH_SCAN, NULL); }
%type hint_opt_list { SNodeList* }
%destructor hint_opt_list { nodesDestroyList($$); }
hint_opt_list(A) ::= . { A = NULL; }
hint_opt_list(A) ::= hint_opt(B). { A = createNodeList(pCxt, B); }
hint_opt_list(A) ::= hint_opt_list(B) hint_opt(C). { A = addNodeToList(pCxt, B, C); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
6a78053b
...
...
@@ -348,6 +348,17 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken*
return
(
SNode
*
)
val
;
}
SNode
*
createHintNode
(
SAstCreateContext
*
pCxt
,
EHintOption
option
,
const
SToken
*
pLiteral
)
{
CHECK_PARSER_STATUS
(
pCxt
);
SHintNode
*
hint
=
(
SHintNode
*
)
nodesMakeNode
(
QUERY_NODE_HINT
);
CHECK_OUT_OF_MEM
(
hint
);
hint
->
option
=
option
;
hint
->
literal
=
strndup
(
pLiteral
->
z
,
pLiteral
->
n
);
trimString
(
pLiteral
->
z
,
pLiteral
->
n
,
hint
->
literal
,
pLiteral
->
n
);
CHECK_OUT_OF_MEM
(
hint
->
literal
);
return
(
SNode
*
)
hint
;
}
SNode
*
createIdentifierValueNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pLiteral
)
{
trimEscape
(
pLiteral
);
return
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_BINARY
,
pLiteral
);
...
...
@@ -845,9 +856,9 @@ SNode* addFillClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pFill) {
return
pStmt
;
}
SNode
*
createSelectStmt
(
SAstCreateContext
*
pCxt
,
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
)
{
SNode
*
createSelectStmt
(
SAstCreateContext
*
pCxt
,
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
,
SNodeList
*
pHint
)
{
CHECK_PARSER_STATUS
(
pCxt
);
SNode
*
select
=
createSelectStmtImpl
(
isDistinct
,
pProjectionList
,
pTable
);
SNode
*
select
=
createSelectStmtImpl
(
isDistinct
,
pProjectionList
,
pTable
,
pHint
);
CHECK_OUT_OF_MEM
(
select
);
return
select
;
}
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
6a78053b
...
...
@@ -42,6 +42,7 @@ static SKeyword keywordTable[] = {
{
"ASC"
,
TK_ASC
},
{
"AT_ONCE"
,
TK_AT_ONCE
},
{
"BALANCE"
,
TK_BALANCE
},
{
"BATCH_SCAN"
,
TK_BATCH_SCAN
},
{
"BETWEEN"
,
TK_BETWEEN
},
{
"BIGINT"
,
TK_BIGINT
},
{
"BINARY"
,
TK_BINARY
},
...
...
@@ -153,6 +154,7 @@ static SKeyword keywordTable[] = {
{
"NONE"
,
TK_NONE
},
{
"NOT"
,
TK_NOT
},
{
"NOW"
,
TK_NOW
},
{
"NO_BATCH_SCAN"
,
TK_NO_BATCH_SCAN
},
{
"NULL"
,
TK_NULL
},
{
"NULL_F"
,
TK_NULL_F
},
{
"NULLS"
,
TK_NULLS
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
6a78053b
...
...
@@ -6166,7 +6166,7 @@ static int32_t buildQueryForTableTopic(STranslateContext* pCxt, SCreateTopicStmt
strcpy
(
realTable
->
table
.
dbName
,
pStmt
->
subDbName
);
strcpy
(
realTable
->
table
.
tableName
,
pStmt
->
subSTbName
);
strcpy
(
realTable
->
table
.
tableAlias
,
pStmt
->
subSTbName
);
*
pSelect
=
createSelectStmtImpl
(
true
,
pProjection
,
(
SNode
*
)
realTable
);
*
pSelect
=
createSelectStmtImpl
(
true
,
pProjection
,
(
SNode
*
)
realTable
,
NULL
);
((
SSelectStmt
*
)
*
pSelect
)
->
pWhere
=
nodesCloneNode
(
pStmt
->
pWhere
);
pCxt
->
pParseCxt
->
topicQuery
=
true
;
code
=
translateQuery
(
pCxt
,
*
pSelect
);
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
6a78053b
...
...
@@ -692,7 +692,7 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog
}
SNode
*
createSelectStmtImpl
(
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
)
{
SNode
*
createSelectStmtImpl
(
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
,
SNodeList
*
pHint
)
{
SSelectStmt
*
select
=
(
SSelectStmt
*
)
nodesMakeNode
(
QUERY_NODE_SELECT_STMT
);
if
(
NULL
==
select
)
{
return
NULL
;
...
...
@@ -704,6 +704,7 @@ SNode* createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode*
select
->
timeLineResMode
=
select
->
isDistinct
?
TIME_LINE_NONE
:
TIME_LINE_GLOBAL
;
select
->
onlyHasKeepOrderFunc
=
true
;
select
->
timeRange
=
TSWINDOW_INITIALIZER
;
select
->
pHint
=
pHint
;
return
(
SNode
*
)
select
;
}
...
...
@@ -1157,3 +1158,5 @@ int64_t int64SafeSub(int64_t a, int64_t b) {
}
return
res
;
}
source/libs/parser/src/sql.c
浏览文件 @
6a78053b
此差异已折叠。
点击以展开。
source/libs/planner/inc/planInt.h
浏览文件 @
6a78053b
...
...
@@ -45,6 +45,7 @@ int32_t createPhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryP
bool
isPartTableAgg
(
SAggLogicNode
*
pAgg
);
bool
isPartTableWinodw
(
SWindowLogicNode
*
pWindow
);
bool
getBatchScanOptionFromHint
(
SNodeList
*
pList
);
#ifdef __cplusplus
}
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
6a78053b
...
...
@@ -435,6 +435,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
}
pJoin
->
joinType
=
pJoinTable
->
joinType
;
pJoin
->
joinAlgo
=
JOIN_ALGO_UNKNOWN
;
pJoin
->
isSingleTableJoin
=
pJoinTable
->
table
.
singleTable
;
pJoin
->
hasSubQuery
=
pJoinTable
->
hasSubQuery
;
pJoin
->
node
.
inputTsOrder
=
ORDER_ASC
;
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
6a78053b
...
...
@@ -930,6 +930,7 @@ static int32_t pushDownCondOptDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* p
if
(
pJoin
->
joinAlgo
!=
JOIN_ALGO_UNKNOWN
)
{
return
TSDB_CODE_SUCCESS
;
}
pJoin
->
joinAlgo
=
JOIN_ALGO_MERGE
;
if
(
NULL
==
pJoin
->
node
.
pConditions
)
{
int32_t
code
=
pushDownCondOptJoinExtractCond
(
pCxt
,
pJoin
);
...
...
@@ -3328,7 +3329,7 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL
return
code
;
}
static
int32_t
stbJoinOptCreateGroupCacheNode
(
SNodeList
*
pChildren
,
SLogicNode
**
ppLogic
)
{
static
int32_t
stbJoinOptCreateGroupCacheNode
(
S
OptimizeContext
*
pCxt
,
S
NodeList
*
pChildren
,
SLogicNode
**
ppLogic
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SGroupCacheLogicNode
*
pGrpCache
=
(
SGroupCacheLogicNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_GROUP_CACHE
);
if
(
NULL
==
pGrpCache
)
{
...
...
@@ -3338,7 +3339,7 @@ static int32_t stbJoinOptCreateGroupCacheNode(SNodeList* pChildren, SLogicNode**
//pGrpCache->node.dynamicOp = true;
pGrpCache
->
grpColsMayBeNull
=
false
;
pGrpCache
->
grpByUid
=
true
;
pGrpCache
->
batchFetch
=
false
;
pGrpCache
->
batchFetch
=
getBatchScanOptionFromHint
(((
SSelectStmt
*
)
pCxt
->
pPlanCxt
->
pAstRoot
)
->
pHint
)
;
pGrpCache
->
node
.
pChildren
=
pChildren
;
pGrpCache
->
node
.
pTargets
=
nodesMakeList
();
if
(
NULL
==
pGrpCache
->
node
.
pTargets
)
{
...
...
@@ -3435,8 +3436,7 @@ static int32_t stbJoinOptCreateMergeJoinNode(SLogicNode* pOrig, SLogicNode* pChi
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
stbJoinOptCreateDynQueryCtrlNode
(
SLogicNode
*
pPrev
,
SLogicNode
*
pPost
,
bool
*
srcScan
,
SLogicNode
**
ppDynNode
)
{
static
int32_t
stbJoinOptCreateDynQueryCtrlNode
(
SOptimizeContext
*
pCxt
,
SLogicNode
*
pPrev
,
SLogicNode
*
pPost
,
bool
*
srcScan
,
SLogicNode
**
ppDynNode
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SDynQueryCtrlLogicNode
*
pDynCtrl
=
(
SDynQueryCtrlLogicNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_DYN_QUERY_CTRL
);
if
(
NULL
==
pDynCtrl
)
{
...
...
@@ -3444,7 +3444,7 @@ static int32_t stbJoinOptCreateDynQueryCtrlNode(SLogicNode* pPrev, SLogicNode* p
}
pDynCtrl
->
qType
=
DYN_QTYPE_STB_HASH
;
pDynCtrl
->
stbJoin
.
batchFetch
=
false
;
pDynCtrl
->
stbJoin
.
batchFetch
=
getBatchScanOptionFromHint
(((
SSelectStmt
*
)
pCxt
->
pPlanCxt
->
pAstRoot
)
->
pHint
)
;
memcpy
(
pDynCtrl
->
stbJoin
.
srcScan
,
srcScan
,
sizeof
(
pDynCtrl
->
stbJoin
.
srcScan
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -3510,13 +3510,13 @@ static int32_t stbJoinOptRewriteStableJoin(SOptimizeContext* pCxt, SLogicNode* p
code
=
stbJoinOptCreateTableScanNodes
(
pJoin
,
&
pTbScanNodes
,
srcScan
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbJoinOptCreateGroupCacheNode
(
pTbScanNodes
,
&
pGrpCacheNode
);
code
=
stbJoinOptCreateGroupCacheNode
(
p
Cxt
,
p
TbScanNodes
,
&
pGrpCacheNode
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbJoinOptCreateMergeJoinNode
(
pJoin
,
pGrpCacheNode
,
&
pMJoinNode
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbJoinOptCreateDynQueryCtrlNode
(
pHJoinNode
,
pMJoinNode
,
srcScan
,
&
pDynNode
);
code
=
stbJoinOptCreateDynQueryCtrlNode
(
p
Cxt
,
p
HJoinNode
,
pMJoinNode
,
srcScan
,
&
pDynNode
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
replaceLogicNode
(
pLogicSubplan
,
pJoin
,
(
SLogicNode
*
)
pDynNode
);
...
...
source/libs/planner/src/planUtil.c
浏览文件 @
6a78053b
...
...
@@ -374,4 +374,21 @@ bool isPartTableWinodw(SWindowLogicNode* pWindow) {
return
stbHasPartTbname
(
stbSplGetPartKeys
((
SLogicNode
*
)
nodesListGetNode
(
pWindow
->
node
.
pChildren
,
0
)));
}
bool
getBatchScanOptionFromHint
(
SNodeList
*
pList
)
{
SNode
*
pNode
=
NULL
;
bool
batchScan
=
true
;
FOREACH
(
pNode
,
pList
)
{
SHintNode
*
pHint
=
(
SHintNode
*
)
pNode
;
if
(
pHint
->
option
==
HINT_BATCH_SCAN
)
{
batchScan
=
true
;
break
;
}
else
if
(
pHint
->
option
==
HINT_NO_BATCH_SCAN
)
{
batchScan
=
false
;
break
;
}
}
return
batchScan
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录