plannodes.h 14.4 KB
Newer Older
X
Xiaoyu Wang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _TD_PLANN_NODES_H_
#define _TD_PLANN_NODES_H_

#ifdef __cplusplus
extern "C" {
#endif

X
Xiaoyu Wang 已提交
23
#include "query.h"
24
#include "querynodes.h"
X
Xiaoyu Wang 已提交
25
#include "tname.h"
X
Xiaoyu Wang 已提交
26

27 28
#define SLOT_NAME_LEN TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN

X
Xiaoyu Wang 已提交
29
typedef struct SLogicNode {
30 31 32 33
  ENodeType          type;
  SNodeList*         pTargets;  // SColumnNode
  SNode*             pConditions;
  SNodeList*         pChildren;
X
Xiaoyu Wang 已提交
34
  struct SLogicNode* pParent;
35
  int32_t            optimizedFlag;
X
Xiaoyu Wang 已提交
36
  uint8_t            precision;
37 38
  SNode*             pLimit;
  SNode*             pSlimit;
X
Xiaoyu Wang 已提交
39 40
} SLogicNode;

X
Xiaoyu Wang 已提交
41 42 43 44 45
typedef enum EScanType {
  SCAN_TYPE_TAG = 1,
  SCAN_TYPE_TABLE,
  SCAN_TYPE_SYSTEM_TABLE,
  SCAN_TYPE_STREAM,
46
  SCAN_TYPE_TABLE_MERGE,
X
Xiaoyu Wang 已提交
47 48
  SCAN_TYPE_BLOCK_INFO,
  SCAN_TYPE_LAST_ROW
X
Xiaoyu Wang 已提交
49
} EScanType;
X
Xiaoyu Wang 已提交
50

X
Xiaoyu Wang 已提交
51
typedef struct SScanLogicNode {
X
Xiaoyu Wang 已提交
52 53 54 55 56
  SLogicNode    node;
  SNodeList*    pScanCols;
  SNodeList*    pScanPseudoCols;
  int8_t        tableType;
  uint64_t      tableId;
X
Xiaoyu Wang 已提交
57
  uint64_t      stableId;
X
Xiaoyu Wang 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
  SVgroupsInfo* pVgroupList;
  EScanType     scanType;
  uint8_t       scanSeq[2];  // first is scan count, and second is reverse scan count
  STimeWindow   scanRange;
  SName         tableName;
  bool          showRewrite;
  double        ratio;
  SNodeList*    pDynamicScanFuncs;
  int32_t       dataRequired;
  int64_t       interval;
  int64_t       offset;
  int64_t       sliding;
  int8_t        intervalUnit;
  int8_t        slidingUnit;
  SNode*        pTagCond;
X
Xiaoyu Wang 已提交
73
  SNode*        pTagIndexCond;
X
Xiaoyu Wang 已提交
74 75
  int8_t        triggerType;
  int64_t       watermark;
76
  int8_t        igExpired;
X
Xiaoyu Wang 已提交
77
  SArray*       pSmaIndexes;
78 79
  SNodeList*    pGroupTags;
  bool          groupSort;
80
  int8_t        cacheLastMode;
X
Xiaoyu Wang 已提交
81 82 83 84
} SScanLogicNode;

typedef struct SJoinLogicNode {
  SLogicNode node;
85
  EJoinType  joinType;
86
  SNode*     pMergeCondition;
87
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
88
  bool       isSingleTableJoin;
X
Xiaoyu Wang 已提交
89 90 91 92 93 94
} SJoinLogicNode;

typedef struct SAggLogicNode {
  SLogicNode node;
  SNodeList* pGroupKeys;
  SNodeList* pAggFuncs;
95
  bool       hasLastRow;
X
Xiaoyu Wang 已提交
96 97 98 99 100
} SAggLogicNode;

typedef struct SProjectLogicNode {
  SLogicNode node;
  SNodeList* pProjections;
101
  char       stmtName[TSDB_TABLE_NAME_LEN];
X
Xiaoyu Wang 已提交
102 103
} SProjectLogicNode;

104 105
typedef struct SIndefRowsFuncLogicNode {
  SLogicNode node;
X
Xiaoyu Wang 已提交
106
  SNodeList* pFuncs;
107
  bool       isTailFunc;
108
  bool       isUniqueFunc;
109
  bool       isTimeLineFunc;
110 111
} SIndefRowsFuncLogicNode;

X
Xiaoyu Wang 已提交
112 113 114 115 116
typedef struct SInterpFuncLogicNode {
  SLogicNode  node;
  SNodeList*  pFuncs;
  STimeWindow timeRange;
  int64_t     interval;
X
Xiaoyu Wang 已提交
117 118 119
  EFillMode   fillMode;
  SNode*      pFillValues;  // SNodeListNode
  SNode*      pTimeSeries;  // SColumnNode
X
Xiaoyu Wang 已提交
120 121
} SInterpFuncLogicNode;

X
Xiaoyu Wang 已提交
122 123 124 125 126 127 128 129
typedef enum EModifyTableType { MODIFY_TABLE_TYPE_INSERT = 1, MODIFY_TABLE_TYPE_DELETE } EModifyTableType;

typedef struct SVnodeModifyLogicNode {
  SLogicNode       node;
  EModifyTableType modifyType;
  int32_t          msgType;
  SArray*          pDataBlocks;
  SVgDataBlocks*   pVgDataBlocks;
X
Xiaoyu Wang 已提交
130
  SNode*           pAffectedRows;  // SColumnNode
X
Xiaoyu Wang 已提交
131
  uint64_t         tableId;
132
  uint64_t         stableId;
X
Xiaoyu Wang 已提交
133 134 135
  int8_t           tableType;  // table type
  char             tableFName[TSDB_TABLE_FNAME_LEN];
  STimeWindow      deleteTimeRange;
136
  SVgroupsInfo*    pVgroupList;
137
  SNodeList*       pInsertCols;
X
Xiaoyu Wang 已提交
138
} SVnodeModifyLogicNode;
139

X
Xiaoyu Wang 已提交
140 141
typedef struct SExchangeLogicNode {
  SLogicNode node;
142
  int32_t    srcGroupId;
X
Xiaoyu Wang 已提交
143 144
} SExchangeLogicNode;

X
Xiaoyu Wang 已提交
145 146 147
typedef struct SMergeLogicNode {
  SLogicNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
148
  SNodeList* pInputs;
X
Xiaoyu Wang 已提交
149 150
  int32_t    numOfChannels;
  int32_t    srcGroupId;
151
  bool       groupSort;
X
Xiaoyu Wang 已提交
152 153
} SMergeLogicNode;

154
typedef enum EWindowType { WINDOW_TYPE_INTERVAL = 1, WINDOW_TYPE_SESSION, WINDOW_TYPE_STATE } EWindowType;
X
Xiaoyu Wang 已提交
155

156
typedef enum EWindowAlgorithm {
X
Xiaoyu Wang 已提交
157
  INTERVAL_ALGO_HASH = 1,
X
Xiaoyu Wang 已提交
158
  INTERVAL_ALGO_MERGE,
X
Xiaoyu Wang 已提交
159 160 161
  INTERVAL_ALGO_STREAM_FINAL,
  INTERVAL_ALGO_STREAM_SEMI,
  INTERVAL_ALGO_STREAM_SINGLE,
162 163 164 165 166
  SESSION_ALGO_STREAM_SEMI,
  SESSION_ALGO_STREAM_FINAL,
  SESSION_ALGO_STREAM_SINGLE,
  SESSION_ALGO_MERGE,
} EWindowAlgorithm;
167

X
Xiaoyu Wang 已提交
168
typedef struct SWindowLogicNode {
169 170 171 172 173 174 175 176 177 178
  SLogicNode       node;
  EWindowType      winType;
  SNodeList*       pFuncs;
  int64_t          interval;
  int64_t          offset;
  int64_t          sliding;
  int8_t           intervalUnit;
  int8_t           slidingUnit;
  int64_t          sessionGap;
  SNode*           pTspk;
X
Xiaoyu Wang 已提交
179
  SNode*           pTsEnd;
180 181 182
  SNode*           pStateExpr;
  int8_t           triggerType;
  int64_t          watermark;
183
  int8_t           igExpired;
184
  EWindowAlgorithm windowAlgo;
X
Xiaoyu Wang 已提交
185 186
} SWindowLogicNode;

X
Xiaoyu Wang 已提交
187
typedef struct SFillLogicNode {
X
Xiaoyu Wang 已提交
188 189 190 191 192
  SLogicNode  node;
  EFillMode   mode;
  SNode*      pWStartTs;
  SNode*      pValues;  // SNodeListNode
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
193 194
} SFillLogicNode;

X
Xiaoyu Wang 已提交
195 196 197
typedef struct SSortLogicNode {
  SLogicNode node;
  SNodeList* pSortKeys;
198
  bool       groupSort;
X
Xiaoyu Wang 已提交
199 200
} SSortLogicNode;

201 202 203 204 205
typedef struct SPartitionLogicNode {
  SLogicNode node;
  SNodeList* pPartitionKeys;
} SPartitionLogicNode;

206 207 208 209
typedef enum ESubplanType {
  SUBPLAN_TYPE_MERGE = 1,
  SUBPLAN_TYPE_PARTIAL,
  SUBPLAN_TYPE_SCAN,
210 211
  SUBPLAN_TYPE_MODIFY,
  SUBPLAN_TYPE_COMPUTE
212 213
} ESubplanType;

X
Xiaoyu Wang 已提交
214 215
typedef struct SSubplanId {
  uint64_t queryId;
216 217
  int32_t  groupId;
  int32_t  subplanId;
X
Xiaoyu Wang 已提交
218 219
} SSubplanId;

X
Xiaoyu Wang 已提交
220
typedef struct SLogicSubplan {
221 222 223 224 225 226
  ENodeType     type;
  SSubplanId    id;
  SNodeList*    pChildren;
  SNodeList*    pParents;
  SLogicNode*   pNode;
  ESubplanType  subplanType;
X
Xiaoyu Wang 已提交
227
  SVgroupsInfo* pVgroupList;
228 229
  int32_t       level;
  int32_t       splitFlag;
230
  int32_t       numOfComputeNodes;
X
Xiaoyu Wang 已提交
231
} SLogicSubplan;
X
Xiaoyu Wang 已提交
232 233

typedef struct SQueryLogicPlan {
234
  ENodeType  type;
X
Xiaoyu Wang 已提交
235
  SNodeList* pTopSubplans;
X
Xiaoyu Wang 已提交
236 237
} SQueryLogicPlan;

X
Xiaoyu Wang 已提交
238 239
typedef struct SSlotDescNode {
  ENodeType type;
240
  int16_t   slotId;
X
Xiaoyu Wang 已提交
241
  SDataType dataType;
242 243 244
  bool      reserve;
  bool      output;
  bool      tag;
245
  char      name[SLOT_NAME_LEN];
X
Xiaoyu Wang 已提交
246 247
} SSlotDescNode;

X
Xiaoyu Wang 已提交
248
typedef struct SDataBlockDescNode {
249 250
  ENodeType  type;
  int16_t    dataBlockId;
X
Xiaoyu Wang 已提交
251
  SNodeList* pSlots;
252 253 254
  int32_t    totalRowSize;
  int32_t    outputRowSize;
  uint8_t    precision;
X
Xiaoyu Wang 已提交
255
} SDataBlockDescNode;
X
Xiaoyu Wang 已提交
256 257

typedef struct SPhysiNode {
258
  ENodeType           type;
X
Xiaoyu Wang 已提交
259
  SDataBlockDescNode* pOutputDataBlockDesc;
260 261 262
  SNode*              pConditions;
  SNodeList*          pChildren;
  struct SPhysiNode*  pParent;
263 264
  SNode*              pLimit;
  SNode*              pSlimit;
X
Xiaoyu Wang 已提交
265 266 267
} SPhysiNode;

typedef struct SScanPhysiNode {
X
Xiaoyu Wang 已提交
268
  SPhysiNode node;
X
Xiaoyu Wang 已提交
269
  SNodeList* pScanCols;
270 271
  SNodeList* pScanPseudoCols;
  uint64_t   uid;  // unique id of the table
X
Xiaoyu Wang 已提交
272
  uint64_t   suid;
273 274
  int8_t     tableType;
  SName      tableName;
X
Xiaoyu Wang 已提交
275 276 277
} SScanPhysiNode;

typedef SScanPhysiNode STagScanPhysiNode;
278
typedef SScanPhysiNode SBlockDistScanPhysiNode;
X
Xiaoyu Wang 已提交
279 280 281 282 283 284

typedef struct SLastRowScanPhysiNode {
  SScanPhysiNode scan;
  SNodeList*     pGroupTags;
  bool           groupSort;
} SLastRowScanPhysiNode;
X
Xiaoyu Wang 已提交
285

X
Xiaoyu Wang 已提交
286 287
typedef struct SSystemTableScanPhysiNode {
  SScanPhysiNode scan;
288 289 290
  SEpSet         mgmtEpSet;
  bool           showRewrite;
  int32_t        accountId;
X
Xiaoyu Wang 已提交
291 292
} SSystemTableScanPhysiNode;

X
Xiaoyu Wang 已提交
293 294
typedef struct STableScanPhysiNode {
  SScanPhysiNode scan;
295 296 297 298 299
  uint8_t        scanSeq[2];  // first is scan count, and second is reverse scan count
  STimeWindow    scanRange;
  double         ratio;
  int32_t        dataRequired;
  SNodeList*     pDynamicScanFuncs;
300 301
  SNodeList*     pGroupTags;
  bool           groupSort;
302 303 304 305 306
  int64_t        interval;
  int64_t        offset;
  int64_t        sliding;
  int8_t         intervalUnit;
  int8_t         slidingUnit;
5
54liuyao 已提交
307 308
  int8_t         triggerType;
  int64_t        watermark;
309
  int8_t         igExpired;
X
Xiaoyu Wang 已提交
310 311 312
} STableScanPhysiNode;

typedef STableScanPhysiNode STableSeqScanPhysiNode;
X
Xiaoyu Wang 已提交
313
typedef STableScanPhysiNode STableMergeScanPhysiNode;
5
54liuyao 已提交
314
typedef STableScanPhysiNode SStreamScanPhysiNode;
X
Xiaoyu Wang 已提交
315 316 317 318 319 320

typedef struct SProjectPhysiNode {
  SPhysiNode node;
  SNodeList* pProjections;
} SProjectPhysiNode;

321 322 323
typedef struct SIndefRowsFuncPhysiNode {
  SPhysiNode node;
  SNodeList* pExprs;
X
Xiaoyu Wang 已提交
324
  SNodeList* pFuncs;
325 326
} SIndefRowsFuncPhysiNode;

X
Xiaoyu Wang 已提交
327 328 329 330 331 332
typedef struct SInterpFuncPhysiNode {
  SPhysiNode  node;
  SNodeList*  pExprs;
  SNodeList*  pFuncs;
  STimeWindow timeRange;
  int64_t     interval;
D
dapan1121 已提交
333
  int8_t      intervalUnit;
X
Xiaoyu Wang 已提交
334 335 336
  EFillMode   fillMode;
  SNode*      pFillValues;  // SNodeListNode
  SNode*      pTimeSeries;  // SColumnNode
X
Xiaoyu Wang 已提交
337 338
} SInterpFuncPhysiNode;

X
Xiaoyu Wang 已提交
339 340
typedef struct SJoinPhysiNode {
  SPhysiNode node;
341
  EJoinType  joinType;
342
  SNode*     pMergeCondition;
X
Xiaoyu Wang 已提交
343
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
344 345 346
  SNodeList* pTargets;
} SJoinPhysiNode;

X
Xiaoyu Wang 已提交
347 348
typedef SJoinPhysiNode SSortMergeJoinPhysiNode;

X
Xiaoyu Wang 已提交
349 350
typedef struct SAggPhysiNode {
  SPhysiNode node;
351
  SNodeList* pExprs;  // these are expression list of group_by_clause and parameter expression of aggregate function
X
Xiaoyu Wang 已提交
352
  SNodeList* pGroupKeys;
X
Xiaoyu Wang 已提交
353 354 355
  SNodeList* pAggFuncs;
} SAggPhysiNode;

X
Xiaoyu Wang 已提交
356
typedef struct SDownstreamSourceNode {
357
  ENodeType      type;
X
Xiaoyu Wang 已提交
358
  SQueryNodeAddr addr;
359 360
  uint64_t       taskId;
  uint64_t       schedId;
D
dapan1121 已提交
361
  int32_t        execId;
D
dapan1121 已提交
362
  int32_t        fetchMsgType;
X
Xiaoyu Wang 已提交
363
} SDownstreamSourceNode;
X
Xiaoyu Wang 已提交
364 365

typedef struct SExchangePhysiNode {
X
Xiaoyu Wang 已提交
366
  SPhysiNode node;
X
Xiaoyu Wang 已提交
367
  int32_t    srcGroupId;  // group id of datasource suplans
D
dapan1121 已提交
368
  bool       singleChannel;
X
Xiaoyu Wang 已提交
369
  SNodeList* pSrcEndPoints;  // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
X
Xiaoyu Wang 已提交
370 371
} SExchangePhysiNode;

X
Xiaoyu Wang 已提交
372 373 374
typedef struct SMergePhysiNode {
  SPhysiNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
375
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
376 377
  int32_t    numOfChannels;
  int32_t    srcGroupId;
378
  bool       groupSort;
X
Xiaoyu Wang 已提交
379 380
} SMergePhysiNode;

X
Xiaoyu Wang 已提交
381
typedef struct SWinodwPhysiNode {
X
Xiaoyu Wang 已提交
382
  SPhysiNode node;
383
  SNodeList* pExprs;  // these are expression list of parameter expression of function
X
Xiaoyu Wang 已提交
384
  SNodeList* pFuncs;
X
Xiaoyu Wang 已提交
385 386
  SNode*     pTspk;   // timestamp primary key
  SNode*     pTsEnd;  // window end timestamp
387 388
  int8_t     triggerType;
  int64_t    watermark;
389
  int8_t     igExpired;
X
Xiaoyu Wang 已提交
390 391 392 393
} SWinodwPhysiNode;

typedef struct SIntervalPhysiNode {
  SWinodwPhysiNode window;
394 395 396 397 398
  int64_t          interval;
  int64_t          offset;
  int64_t          sliding;
  int8_t           intervalUnit;
  int8_t           slidingUnit;
X
Xiaoyu Wang 已提交
399 400
} SIntervalPhysiNode;

401
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
402
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
X
Xiaoyu Wang 已提交
403
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
404 405
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode;
X
Xiaoyu Wang 已提交
406

X
Xiaoyu Wang 已提交
407
typedef struct SFillPhysiNode {
X
Xiaoyu Wang 已提交
408 409 410 411 412 413
  SPhysiNode  node;
  EFillMode   mode;
  SNode*      pWStartTs;  // SColumnNode
  SNode*      pValues;    // SNodeListNode
  SNodeList*  pTargets;
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
414 415
} SFillPhysiNode;

416 417
typedef struct SMultiTableIntervalPhysiNode {
  SIntervalPhysiNode interval;
418
  SNodeList*         pPartitionKeys;
419 420
} SMultiTableIntervalPhysiNode;

X
Xiaoyu Wang 已提交
421 422
typedef struct SSessionWinodwPhysiNode {
  SWinodwPhysiNode window;
423
  int64_t          gap;
X
Xiaoyu Wang 已提交
424 425
} SSessionWinodwPhysiNode;

5
54liuyao 已提交
426
typedef SSessionWinodwPhysiNode SStreamSessionWinodwPhysiNode;
427 428
typedef SSessionWinodwPhysiNode SStreamSemiSessionWinodwPhysiNode;
typedef SSessionWinodwPhysiNode SStreamFinalSessionWinodwPhysiNode;
5
54liuyao 已提交
429

430 431
typedef struct SStateWinodwPhysiNode {
  SWinodwPhysiNode window;
432
  SNode*           pStateKey;
433 434
} SStateWinodwPhysiNode;

5
54liuyao 已提交
435 436
typedef SStateWinodwPhysiNode SStreamStateWinodwPhysiNode;

X
Xiaoyu Wang 已提交
437 438
typedef struct SSortPhysiNode {
  SPhysiNode node;
439 440
  SNodeList* pExprs;     // these are expression list of order_by_clause and parameter expression of aggregate function
  SNodeList* pSortKeys;  // element is SOrderByExprNode, and SOrderByExprNode::pExpr is SColumnNode
X
Xiaoyu Wang 已提交
441
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
442 443
} SSortPhysiNode;

S
shenglian zhou 已提交
444 445
typedef SSortPhysiNode SGroupSortPhysiNode;

446 447
typedef struct SPartitionPhysiNode {
  SPhysiNode node;
448
  SNodeList* pExprs;  // these are expression list of partition_by_clause
449
  SNodeList* pPartitionKeys;
X
Xiaoyu Wang 已提交
450
  SNodeList* pTargets;
451 452
} SPartitionPhysiNode;

X
Xiaoyu Wang 已提交
453
typedef struct SDataSinkNode {
454
  ENodeType           type;
X
Xiaoyu Wang 已提交
455
  SDataBlockDescNode* pInputDataBlockDesc;
X
Xiaoyu Wang 已提交
456 457 458 459 460 461 462 463
} SDataSinkNode;

typedef struct SDataDispatcherNode {
  SDataSinkNode sink;
} SDataDispatcherNode;

typedef struct SDataInserterNode {
  SDataSinkNode sink;
464 465 466
  int32_t       numOfTables;
  uint32_t      size;
  char*         pData;
X
Xiaoyu Wang 已提交
467 468
} SDataInserterNode;

469 470
typedef struct SQueryInserterNode {
  SDataSinkNode sink;
471
  SNodeList*    pCols;
472
  uint64_t      tableId;
473
  uint64_t      stableId;
474 475 476 477 478 479
  int8_t        tableType;  // table type
  char          tableFName[TSDB_TABLE_FNAME_LEN];
  int32_t       vgId;
  SEpSet        epSet;
} SQueryInserterNode;

X
Xiaoyu Wang 已提交
480 481 482 483 484 485
typedef struct SDataDeleterNode {
  SDataSinkNode sink;
  uint64_t      tableId;
  int8_t        tableType;  // table type
  char          tableFName[TSDB_TABLE_FNAME_LEN];
  STimeWindow   deleteTimeRange;
X
Xiaoyu Wang 已提交
486
  SNode*        pAffectedRows;
X
Xiaoyu Wang 已提交
487 488
} SDataDeleterNode;

X
Xiaoyu Wang 已提交
489
typedef struct SSubplan {
490 491 492 493 494 495
  ENodeType      type;
  SSubplanId     id;  // unique id of the subplan
  ESubplanType   subplanType;
  int32_t        msgType;  // message type for subplan, used to denote the send message type to vnode.
  int32_t        level;    // the execution level of current subplan, starting from 0 in a top-down manner.
  char           dbFName[TSDB_DB_FNAME_LEN];
X
Xiaoyu Wang 已提交
496
  char           user[TSDB_USER_LEN];
497 498 499 500 501 502
  SQueryNodeAddr execNode;      // for the scan/modify subplan, the optional execution node
  SQueryNodeStat execNodeStat;  // only for scan subplan
  SNodeList*     pChildren;     // the datasource subplan,from which to fetch the result
  SNodeList*     pParents;      // the data destination subplan, get data from current subplan
  SPhysiNode*    pNode;         // physical plan of current subplan
  SDataSinkNode* pDataSink;     // data of the subplan flow into the datasink
X
Xiaoyu Wang 已提交
503
  SNode*         pTagCond;
X
Xiaoyu Wang 已提交
504
  SNode*         pTagIndexCond;
X
Xiaoyu Wang 已提交
505 506
} SSubplan;

507
typedef enum EExplainMode { EXPLAIN_MODE_DISABLE = 1, EXPLAIN_MODE_STATIC, EXPLAIN_MODE_ANALYZE } EExplainMode;
508 509 510

typedef struct SExplainInfo {
  EExplainMode mode;
511 512
  bool         verbose;
  double       ratio;
513
} SExplainInfo;
514

X
Xiaoyu Wang 已提交
515
typedef struct SQueryPlan {
516 517 518 519
  ENodeType    type;
  uint64_t     queryId;
  int32_t      numOfSubplans;
  SNodeList*   pSubplans;  // Element is SNodeListNode. The execution level of subplan, starting from 0.
520
  SExplainInfo explainInfo;
X
Xiaoyu Wang 已提交
521 522
} SQueryPlan;

523 524
void nodesWalkPhysiPlan(SNode* pNode, FNodeWalker walker, void* pContext);

X
Xiaoyu Wang 已提交
525 526 527 528 529
#ifdef __cplusplus
}
#endif

#endif /*_TD_PLANN_NODES_H_*/