plannodes.h 14.8 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

29 30 31
typedef enum EDataOrderLevel {
  DATA_ORDER_LEVEL_NONE = 1,
  DATA_ORDER_LEVEL_IN_BLOCK,
32 33
  DATA_ORDER_LEVEL_IN_GROUP,
  DATA_ORDER_LEVEL_GLOBAL
34 35
} EDataOrderLevel;

X
Xiaoyu Wang 已提交
36
typedef struct SLogicNode {
37 38 39 40
  ENodeType          type;
  SNodeList*         pTargets;  // SColumnNode
  SNode*             pConditions;
  SNodeList*         pChildren;
X
Xiaoyu Wang 已提交
41
  struct SLogicNode* pParent;
42
  int32_t            optimizedFlag;
X
Xiaoyu Wang 已提交
43
  uint8_t            precision;
44 45
  SNode*             pLimit;
  SNode*             pSlimit;
46 47
  EDataOrderLevel    requireDataOrder;  // requirements for input data
  EDataOrderLevel    resultDataOrder;   // properties of the output data
X
Xiaoyu Wang 已提交
48 49
} SLogicNode;

X
Xiaoyu Wang 已提交
50 51 52 53 54
typedef enum EScanType {
  SCAN_TYPE_TAG = 1,
  SCAN_TYPE_TABLE,
  SCAN_TYPE_SYSTEM_TABLE,
  SCAN_TYPE_STREAM,
55
  SCAN_TYPE_TABLE_MERGE,
X
Xiaoyu Wang 已提交
56 57
  SCAN_TYPE_BLOCK_INFO,
  SCAN_TYPE_LAST_ROW
X
Xiaoyu Wang 已提交
58
} EScanType;
X
Xiaoyu Wang 已提交
59

X
Xiaoyu Wang 已提交
60
typedef struct SScanLogicNode {
X
Xiaoyu Wang 已提交
61 62 63 64 65
  SLogicNode    node;
  SNodeList*    pScanCols;
  SNodeList*    pScanPseudoCols;
  int8_t        tableType;
  uint64_t      tableId;
X
Xiaoyu Wang 已提交
66
  uint64_t      stableId;
X
Xiaoyu Wang 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
  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 已提交
82
  SNode*        pTagIndexCond;
X
Xiaoyu Wang 已提交
83 84
  int8_t        triggerType;
  int64_t       watermark;
85
  int8_t        igExpired;
X
Xiaoyu Wang 已提交
86
  SArray*       pSmaIndexes;
87 88
  SNodeList*    pGroupTags;
  bool          groupSort;
89
  int8_t        cacheLastMode;
90
  bool          hasNormalCols;  // neither tag column nor primary key tag column
X
Xiaoyu Wang 已提交
91 92 93 94
} SScanLogicNode;

typedef struct SJoinLogicNode {
  SLogicNode node;
95
  EJoinType  joinType;
96
  SNode*     pMergeCondition;
97
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
98
  bool       isSingleTableJoin;
X
Xiaoyu Wang 已提交
99 100 101 102 103 104
} SJoinLogicNode;

typedef struct SAggLogicNode {
  SLogicNode node;
  SNodeList* pGroupKeys;
  SNodeList* pAggFuncs;
105
  bool       hasLastRow;
X
Xiaoyu Wang 已提交
106 107 108 109 110
} SAggLogicNode;

typedef struct SProjectLogicNode {
  SLogicNode node;
  SNodeList* pProjections;
111
  char       stmtName[TSDB_TABLE_NAME_LEN];
X
Xiaoyu Wang 已提交
112 113
} SProjectLogicNode;

114 115
typedef struct SIndefRowsFuncLogicNode {
  SLogicNode node;
X
Xiaoyu Wang 已提交
116
  SNodeList* pFuncs;
117
  bool       isTailFunc;
118
  bool       isUniqueFunc;
119
  bool       isTimeLineFunc;
120 121
} SIndefRowsFuncLogicNode;

X
Xiaoyu Wang 已提交
122 123 124 125 126
typedef struct SInterpFuncLogicNode {
  SLogicNode  node;
  SNodeList*  pFuncs;
  STimeWindow timeRange;
  int64_t     interval;
X
Xiaoyu Wang 已提交
127 128 129
  EFillMode   fillMode;
  SNode*      pFillValues;  // SNodeListNode
  SNode*      pTimeSeries;  // SColumnNode
X
Xiaoyu Wang 已提交
130 131
} SInterpFuncLogicNode;

X
Xiaoyu Wang 已提交
132 133 134 135 136 137 138 139
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 已提交
140
  SNode*           pAffectedRows;  // SColumnNode
X
Xiaoyu Wang 已提交
141
  uint64_t         tableId;
142
  uint64_t         stableId;
X
Xiaoyu Wang 已提交
143 144 145
  int8_t           tableType;  // table type
  char             tableFName[TSDB_TABLE_FNAME_LEN];
  STimeWindow      deleteTimeRange;
146
  SVgroupsInfo*    pVgroupList;
147
  SNodeList*       pInsertCols;
X
Xiaoyu Wang 已提交
148
} SVnodeModifyLogicNode;
149

X
Xiaoyu Wang 已提交
150 151
typedef struct SExchangeLogicNode {
  SLogicNode node;
152
  int32_t    srcGroupId;
X
Xiaoyu Wang 已提交
153 154
} SExchangeLogicNode;

X
Xiaoyu Wang 已提交
155 156 157
typedef struct SMergeLogicNode {
  SLogicNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
158
  SNodeList* pInputs;
X
Xiaoyu Wang 已提交
159 160
  int32_t    numOfChannels;
  int32_t    srcGroupId;
161
  bool       groupSort;
X
Xiaoyu Wang 已提交
162 163
} SMergeLogicNode;

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

166
typedef enum EWindowAlgorithm {
X
Xiaoyu Wang 已提交
167
  INTERVAL_ALGO_HASH = 1,
X
Xiaoyu Wang 已提交
168
  INTERVAL_ALGO_MERGE,
X
Xiaoyu Wang 已提交
169 170 171
  INTERVAL_ALGO_STREAM_FINAL,
  INTERVAL_ALGO_STREAM_SEMI,
  INTERVAL_ALGO_STREAM_SINGLE,
172 173 174 175 176
  SESSION_ALGO_STREAM_SEMI,
  SESSION_ALGO_STREAM_FINAL,
  SESSION_ALGO_STREAM_SINGLE,
  SESSION_ALGO_MERGE,
} EWindowAlgorithm;
177

X
Xiaoyu Wang 已提交
178
typedef struct SWindowLogicNode {
179 180 181 182 183 184 185 186 187 188
  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 已提交
189
  SNode*           pTsEnd;
190 191 192
  SNode*           pStateExpr;
  int8_t           triggerType;
  int64_t          watermark;
193
  int8_t           igExpired;
194
  EWindowAlgorithm windowAlgo;
X
Xiaoyu Wang 已提交
195 196
} SWindowLogicNode;

X
Xiaoyu Wang 已提交
197
typedef struct SFillLogicNode {
X
Xiaoyu Wang 已提交
198 199 200 201 202
  SLogicNode  node;
  EFillMode   mode;
  SNode*      pWStartTs;
  SNode*      pValues;  // SNodeListNode
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
203 204
} SFillLogicNode;

X
Xiaoyu Wang 已提交
205 206 207
typedef struct SSortLogicNode {
  SLogicNode node;
  SNodeList* pSortKeys;
208
  bool       groupSort;
X
Xiaoyu Wang 已提交
209 210
} SSortLogicNode;

211 212 213 214 215
typedef struct SPartitionLogicNode {
  SLogicNode node;
  SNodeList* pPartitionKeys;
} SPartitionLogicNode;

216 217 218 219
typedef enum ESubplanType {
  SUBPLAN_TYPE_MERGE = 1,
  SUBPLAN_TYPE_PARTIAL,
  SUBPLAN_TYPE_SCAN,
220 221
  SUBPLAN_TYPE_MODIFY,
  SUBPLAN_TYPE_COMPUTE
222 223
} ESubplanType;

X
Xiaoyu Wang 已提交
224 225
typedef struct SSubplanId {
  uint64_t queryId;
226 227
  int32_t  groupId;
  int32_t  subplanId;
X
Xiaoyu Wang 已提交
228 229
} SSubplanId;

X
Xiaoyu Wang 已提交
230
typedef struct SLogicSubplan {
231 232 233 234 235 236
  ENodeType     type;
  SSubplanId    id;
  SNodeList*    pChildren;
  SNodeList*    pParents;
  SLogicNode*   pNode;
  ESubplanType  subplanType;
X
Xiaoyu Wang 已提交
237
  SVgroupsInfo* pVgroupList;
238 239
  int32_t       level;
  int32_t       splitFlag;
240
  int32_t       numOfComputeNodes;
X
Xiaoyu Wang 已提交
241
} SLogicSubplan;
X
Xiaoyu Wang 已提交
242 243

typedef struct SQueryLogicPlan {
244
  ENodeType  type;
X
Xiaoyu Wang 已提交
245
  SNodeList* pTopSubplans;
X
Xiaoyu Wang 已提交
246 247
} SQueryLogicPlan;

X
Xiaoyu Wang 已提交
248 249
typedef struct SSlotDescNode {
  ENodeType type;
250
  int16_t   slotId;
X
Xiaoyu Wang 已提交
251
  SDataType dataType;
252 253 254
  bool      reserve;
  bool      output;
  bool      tag;
255
  char      name[SLOT_NAME_LEN];
X
Xiaoyu Wang 已提交
256 257
} SSlotDescNode;

X
Xiaoyu Wang 已提交
258
typedef struct SDataBlockDescNode {
259 260
  ENodeType  type;
  int16_t    dataBlockId;
X
Xiaoyu Wang 已提交
261
  SNodeList* pSlots;
262 263 264
  int32_t    totalRowSize;
  int32_t    outputRowSize;
  uint8_t    precision;
X
Xiaoyu Wang 已提交
265
} SDataBlockDescNode;
X
Xiaoyu Wang 已提交
266 267

typedef struct SPhysiNode {
268
  ENodeType           type;
X
Xiaoyu Wang 已提交
269
  SDataBlockDescNode* pOutputDataBlockDesc;
270 271 272
  SNode*              pConditions;
  SNodeList*          pChildren;
  struct SPhysiNode*  pParent;
273 274
  SNode*              pLimit;
  SNode*              pSlimit;
X
Xiaoyu Wang 已提交
275 276 277
} SPhysiNode;

typedef struct SScanPhysiNode {
X
Xiaoyu Wang 已提交
278
  SPhysiNode node;
X
Xiaoyu Wang 已提交
279
  SNodeList* pScanCols;
280 281
  SNodeList* pScanPseudoCols;
  uint64_t   uid;  // unique id of the table
X
Xiaoyu Wang 已提交
282
  uint64_t   suid;
283 284
  int8_t     tableType;
  SName      tableName;
X
Xiaoyu Wang 已提交
285 286 287
} SScanPhysiNode;

typedef SScanPhysiNode STagScanPhysiNode;
288
typedef SScanPhysiNode SBlockDistScanPhysiNode;
X
Xiaoyu Wang 已提交
289 290 291 292 293 294

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

X
Xiaoyu Wang 已提交
296 297
typedef struct SSystemTableScanPhysiNode {
  SScanPhysiNode scan;
298 299 300
  SEpSet         mgmtEpSet;
  bool           showRewrite;
  int32_t        accountId;
X
Xiaoyu Wang 已提交
301 302
} SSystemTableScanPhysiNode;

X
Xiaoyu Wang 已提交
303 304
typedef struct STableScanPhysiNode {
  SScanPhysiNode scan;
305 306 307 308 309
  uint8_t        scanSeq[2];  // first is scan count, and second is reverse scan count
  STimeWindow    scanRange;
  double         ratio;
  int32_t        dataRequired;
  SNodeList*     pDynamicScanFuncs;
310 311
  SNodeList*     pGroupTags;
  bool           groupSort;
312 313 314 315 316
  int64_t        interval;
  int64_t        offset;
  int64_t        sliding;
  int8_t         intervalUnit;
  int8_t         slidingUnit;
5
54liuyao 已提交
317 318
  int8_t         triggerType;
  int64_t        watermark;
319
  int8_t         igExpired;
X
Xiaoyu Wang 已提交
320 321 322
} STableScanPhysiNode;

typedef STableScanPhysiNode STableSeqScanPhysiNode;
X
Xiaoyu Wang 已提交
323
typedef STableScanPhysiNode STableMergeScanPhysiNode;
5
54liuyao 已提交
324
typedef STableScanPhysiNode SStreamScanPhysiNode;
X
Xiaoyu Wang 已提交
325 326 327 328

typedef struct SProjectPhysiNode {
  SPhysiNode node;
  SNodeList* pProjections;
329
  bool       mergeDataBlock;
X
Xiaoyu Wang 已提交
330 331
} SProjectPhysiNode;

332 333 334
typedef struct SIndefRowsFuncPhysiNode {
  SPhysiNode node;
  SNodeList* pExprs;
X
Xiaoyu Wang 已提交
335
  SNodeList* pFuncs;
336 337
} SIndefRowsFuncPhysiNode;

X
Xiaoyu Wang 已提交
338 339 340 341 342 343
typedef struct SInterpFuncPhysiNode {
  SPhysiNode  node;
  SNodeList*  pExprs;
  SNodeList*  pFuncs;
  STimeWindow timeRange;
  int64_t     interval;
D
dapan1121 已提交
344
  int8_t      intervalUnit;
X
Xiaoyu Wang 已提交
345 346 347
  EFillMode   fillMode;
  SNode*      pFillValues;  // SNodeListNode
  SNode*      pTimeSeries;  // SColumnNode
X
Xiaoyu Wang 已提交
348 349
} SInterpFuncPhysiNode;

X
Xiaoyu Wang 已提交
350 351
typedef struct SJoinPhysiNode {
  SPhysiNode node;
352
  EJoinType  joinType;
353
  SNode*     pMergeCondition;
X
Xiaoyu Wang 已提交
354
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
355 356 357
  SNodeList* pTargets;
} SJoinPhysiNode;

X
Xiaoyu Wang 已提交
358 359
typedef SJoinPhysiNode SSortMergeJoinPhysiNode;

X
Xiaoyu Wang 已提交
360 361
typedef struct SAggPhysiNode {
  SPhysiNode node;
362
  SNodeList* pExprs;  // these are expression list of group_by_clause and parameter expression of aggregate function
X
Xiaoyu Wang 已提交
363
  SNodeList* pGroupKeys;
X
Xiaoyu Wang 已提交
364 365 366
  SNodeList* pAggFuncs;
} SAggPhysiNode;

X
Xiaoyu Wang 已提交
367
typedef struct SDownstreamSourceNode {
368
  ENodeType      type;
X
Xiaoyu Wang 已提交
369
  SQueryNodeAddr addr;
370 371
  uint64_t       taskId;
  uint64_t       schedId;
D
dapan1121 已提交
372
  int32_t        execId;
D
dapan1121 已提交
373
  int32_t        fetchMsgType;
X
Xiaoyu Wang 已提交
374
} SDownstreamSourceNode;
X
Xiaoyu Wang 已提交
375 376

typedef struct SExchangePhysiNode {
X
Xiaoyu Wang 已提交
377
  SPhysiNode node;
X
Xiaoyu Wang 已提交
378
  int32_t    srcGroupId;  // group id of datasource suplans
D
dapan1121 已提交
379
  bool       singleChannel;
X
Xiaoyu Wang 已提交
380
  SNodeList* pSrcEndPoints;  // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
X
Xiaoyu Wang 已提交
381 382
} SExchangePhysiNode;

X
Xiaoyu Wang 已提交
383 384 385
typedef struct SMergePhysiNode {
  SPhysiNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
386
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
387 388
  int32_t    numOfChannels;
  int32_t    srcGroupId;
389
  bool       groupSort;
X
Xiaoyu Wang 已提交
390 391
} SMergePhysiNode;

X
Xiaoyu Wang 已提交
392
typedef struct SWinodwPhysiNode {
X
Xiaoyu Wang 已提交
393
  SPhysiNode node;
394
  SNodeList* pExprs;  // these are expression list of parameter expression of function
X
Xiaoyu Wang 已提交
395
  SNodeList* pFuncs;
X
Xiaoyu Wang 已提交
396 397
  SNode*     pTspk;   // timestamp primary key
  SNode*     pTsEnd;  // window end timestamp
398 399
  int8_t     triggerType;
  int64_t    watermark;
400
  int8_t     igExpired;
X
Xiaoyu Wang 已提交
401 402 403 404
} SWinodwPhysiNode;

typedef struct SIntervalPhysiNode {
  SWinodwPhysiNode window;
405 406 407 408 409
  int64_t          interval;
  int64_t          offset;
  int64_t          sliding;
  int8_t           intervalUnit;
  int8_t           slidingUnit;
X
Xiaoyu Wang 已提交
410 411
} SIntervalPhysiNode;

412
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
413
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
X
Xiaoyu Wang 已提交
414
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
415 416
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode;
X
Xiaoyu Wang 已提交
417

X
Xiaoyu Wang 已提交
418
typedef struct SFillPhysiNode {
X
Xiaoyu Wang 已提交
419 420 421 422 423 424
  SPhysiNode  node;
  EFillMode   mode;
  SNode*      pWStartTs;  // SColumnNode
  SNode*      pValues;    // SNodeListNode
  SNodeList*  pTargets;
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
425 426
} SFillPhysiNode;

427 428
typedef struct SMultiTableIntervalPhysiNode {
  SIntervalPhysiNode interval;
429
  SNodeList*         pPartitionKeys;
430 431
} SMultiTableIntervalPhysiNode;

X
Xiaoyu Wang 已提交
432 433
typedef struct SSessionWinodwPhysiNode {
  SWinodwPhysiNode window;
434
  int64_t          gap;
X
Xiaoyu Wang 已提交
435 436
} SSessionWinodwPhysiNode;

5
54liuyao 已提交
437
typedef SSessionWinodwPhysiNode SStreamSessionWinodwPhysiNode;
438 439
typedef SSessionWinodwPhysiNode SStreamSemiSessionWinodwPhysiNode;
typedef SSessionWinodwPhysiNode SStreamFinalSessionWinodwPhysiNode;
5
54liuyao 已提交
440

441 442
typedef struct SStateWinodwPhysiNode {
  SWinodwPhysiNode window;
443
  SNode*           pStateKey;
444 445
} SStateWinodwPhysiNode;

5
54liuyao 已提交
446 447
typedef SStateWinodwPhysiNode SStreamStateWinodwPhysiNode;

X
Xiaoyu Wang 已提交
448 449
typedef struct SSortPhysiNode {
  SPhysiNode node;
450 451
  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 已提交
452
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
453 454
} SSortPhysiNode;

S
shenglian zhou 已提交
455 456
typedef SSortPhysiNode SGroupSortPhysiNode;

457 458
typedef struct SPartitionPhysiNode {
  SPhysiNode node;
459
  SNodeList* pExprs;  // these are expression list of partition_by_clause
460
  SNodeList* pPartitionKeys;
X
Xiaoyu Wang 已提交
461
  SNodeList* pTargets;
462 463
} SPartitionPhysiNode;

X
Xiaoyu Wang 已提交
464
typedef struct SDataSinkNode {
465
  ENodeType           type;
X
Xiaoyu Wang 已提交
466
  SDataBlockDescNode* pInputDataBlockDesc;
X
Xiaoyu Wang 已提交
467 468 469 470 471 472 473 474
} SDataSinkNode;

typedef struct SDataDispatcherNode {
  SDataSinkNode sink;
} SDataDispatcherNode;

typedef struct SDataInserterNode {
  SDataSinkNode sink;
475 476 477
  int32_t       numOfTables;
  uint32_t      size;
  char*         pData;
X
Xiaoyu Wang 已提交
478 479
} SDataInserterNode;

480 481
typedef struct SQueryInserterNode {
  SDataSinkNode sink;
482
  SNodeList*    pCols;
483
  uint64_t      tableId;
484
  uint64_t      stableId;
485 486 487 488 489 490
  int8_t        tableType;  // table type
  char          tableFName[TSDB_TABLE_FNAME_LEN];
  int32_t       vgId;
  SEpSet        epSet;
} SQueryInserterNode;

X
Xiaoyu Wang 已提交
491 492 493 494 495 496
typedef struct SDataDeleterNode {
  SDataSinkNode sink;
  uint64_t      tableId;
  int8_t        tableType;  // table type
  char          tableFName[TSDB_TABLE_FNAME_LEN];
  STimeWindow   deleteTimeRange;
X
Xiaoyu Wang 已提交
497
  SNode*        pAffectedRows;
X
Xiaoyu Wang 已提交
498 499
} SDataDeleterNode;

X
Xiaoyu Wang 已提交
500
typedef struct SSubplan {
501 502 503 504 505 506
  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 已提交
507
  char           user[TSDB_USER_LEN];
508 509 510 511 512 513
  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 已提交
514
  SNode*         pTagCond;
X
Xiaoyu Wang 已提交
515
  SNode*         pTagIndexCond;
X
Xiaoyu Wang 已提交
516 517
} SSubplan;

518
typedef enum EExplainMode { EXPLAIN_MODE_DISABLE = 1, EXPLAIN_MODE_STATIC, EXPLAIN_MODE_ANALYZE } EExplainMode;
519 520 521

typedef struct SExplainInfo {
  EExplainMode mode;
522 523
  bool         verbose;
  double       ratio;
524
} SExplainInfo;
525

X
Xiaoyu Wang 已提交
526
typedef struct SQueryPlan {
527 528 529 530
  ENodeType    type;
  uint64_t     queryId;
  int32_t      numOfSubplans;
  SNodeList*   pSubplans;  // Element is SNodeListNode. The execution level of subplan, starting from 0.
531
  SExplainInfo explainInfo;
X
Xiaoyu Wang 已提交
532 533
} SQueryPlan;

534 535
void nodesWalkPhysiPlan(SNode* pNode, FNodeWalker walker, void* pContext);

X
Xiaoyu Wang 已提交
536 537 538 539 540
#ifdef __cplusplus
}
#endif

#endif /*_TD_PLANN_NODES_H_*/