plannodes.h 15.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;

36 37 38 39 40 41 42
typedef enum EGroupAction {
  GROUP_ACTION_NONE = 1,
  GROUP_ACTION_SET,
  GROUP_ACTION_KEEP,
  GROUP_ACTION_CLEAR
} EGroupAction;

X
Xiaoyu Wang 已提交
43
typedef struct SLogicNode {
44 45 46 47
  ENodeType          type;
  SNodeList*         pTargets;  // SColumnNode
  SNode*             pConditions;
  SNodeList*         pChildren;
X
Xiaoyu Wang 已提交
48
  struct SLogicNode* pParent;
49
  int32_t            optimizedFlag;
X
Xiaoyu Wang 已提交
50
  uint8_t            precision;
51 52
  SNode*             pLimit;
  SNode*             pSlimit;
53 54
  EDataOrderLevel    requireDataOrder;  // requirements for input data
  EDataOrderLevel    resultDataOrder;   // properties of the output data
55
  EGroupAction       groupAction;
X
Xiaoyu Wang 已提交
56 57
} SLogicNode;

X
Xiaoyu Wang 已提交
58 59 60 61 62
typedef enum EScanType {
  SCAN_TYPE_TAG = 1,
  SCAN_TYPE_TABLE,
  SCAN_TYPE_SYSTEM_TABLE,
  SCAN_TYPE_STREAM,
63
  SCAN_TYPE_TABLE_MERGE,
X
Xiaoyu Wang 已提交
64 65
  SCAN_TYPE_BLOCK_INFO,
  SCAN_TYPE_LAST_ROW
X
Xiaoyu Wang 已提交
66
} EScanType;
X
Xiaoyu Wang 已提交
67

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

typedef struct SJoinLogicNode {
  SLogicNode node;
104
  EJoinType  joinType;
105
  SNode*     pMergeCondition;
106
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
107
  bool       isSingleTableJoin;
108
  EOrder     inputTsOrder;
X
Xiaoyu Wang 已提交
109 110 111 112 113 114
} SJoinLogicNode;

typedef struct SAggLogicNode {
  SLogicNode node;
  SNodeList* pGroupKeys;
  SNodeList* pAggFuncs;
115
  bool       hasLastRow;
116
  bool       hasTimeLineFunc;
H
Haojun Liao 已提交
117
  bool       onlyHasKeepOrderFunc;
X
Xiaoyu Wang 已提交
118 119 120 121 122
} SAggLogicNode;

typedef struct SProjectLogicNode {
  SLogicNode node;
  SNodeList* pProjections;
123
  char       stmtName[TSDB_TABLE_NAME_LEN];
124
  bool       ignoreGroupId;
X
Xiaoyu Wang 已提交
125 126
} SProjectLogicNode;

127 128
typedef struct SIndefRowsFuncLogicNode {
  SLogicNode node;
X
Xiaoyu Wang 已提交
129
  SNodeList* pFuncs;
130
  bool       isTailFunc;
131
  bool       isUniqueFunc;
132
  bool       isTimeLineFunc;
133 134
} SIndefRowsFuncLogicNode;

X
Xiaoyu Wang 已提交
135 136 137 138 139
typedef struct SInterpFuncLogicNode {
  SLogicNode  node;
  SNodeList*  pFuncs;
  STimeWindow timeRange;
  int64_t     interval;
X
Xiaoyu Wang 已提交
140 141 142
  EFillMode   fillMode;
  SNode*      pFillValues;  // SNodeListNode
  SNode*      pTimeSeries;  // SColumnNode
X
Xiaoyu Wang 已提交
143 144
} SInterpFuncLogicNode;

X
Xiaoyu Wang 已提交
145 146 147 148 149 150 151 152
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 已提交
153
  SNode*           pAffectedRows;  // SColumnNode
154 155
  SNode*           pStartTs;       // SColumnNode
  SNode*           pEndTs;         // SColumnNode
X
Xiaoyu Wang 已提交
156
  uint64_t         tableId;
157
  uint64_t         stableId;
X
Xiaoyu Wang 已提交
158
  int8_t           tableType;  // table type
159
  char             tableName[TSDB_TABLE_NAME_LEN];
160
  char             tsColName[TSDB_COL_NAME_LEN];
X
Xiaoyu Wang 已提交
161
  STimeWindow      deleteTimeRange;
162
  SVgroupsInfo*    pVgroupList;
163
  SNodeList*       pInsertCols;
X
Xiaoyu Wang 已提交
164
} SVnodeModifyLogicNode;
165

X
Xiaoyu Wang 已提交
166 167
typedef struct SExchangeLogicNode {
  SLogicNode node;
168
  int32_t    srcGroupId;
X
Xiaoyu Wang 已提交
169 170
} SExchangeLogicNode;

X
Xiaoyu Wang 已提交
171 172 173
typedef struct SMergeLogicNode {
  SLogicNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
174
  SNodeList* pInputs;
X
Xiaoyu Wang 已提交
175 176
  int32_t    numOfChannels;
  int32_t    srcGroupId;
177
  bool       groupSort;
X
Xiaoyu Wang 已提交
178 179
} SMergeLogicNode;

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

182
typedef enum EWindowAlgorithm {
X
Xiaoyu Wang 已提交
183
  INTERVAL_ALGO_HASH = 1,
X
Xiaoyu Wang 已提交
184
  INTERVAL_ALGO_MERGE,
X
Xiaoyu Wang 已提交
185 186 187
  INTERVAL_ALGO_STREAM_FINAL,
  INTERVAL_ALGO_STREAM_SEMI,
  INTERVAL_ALGO_STREAM_SINGLE,
188 189 190 191 192
  SESSION_ALGO_STREAM_SEMI,
  SESSION_ALGO_STREAM_FINAL,
  SESSION_ALGO_STREAM_SINGLE,
  SESSION_ALGO_MERGE,
} EWindowAlgorithm;
193

X
Xiaoyu Wang 已提交
194
typedef struct SWindowLogicNode {
195 196 197 198 199 200 201 202 203 204
  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 已提交
205
  SNode*           pTsEnd;
206 207 208
  SNode*           pStateExpr;
  int8_t           triggerType;
  int64_t          watermark;
209
  int8_t           igExpired;
210
  EWindowAlgorithm windowAlgo;
211
  EOrder           inputTsOrder;
X
Xiaoyu Wang 已提交
212
  EOrder           outputTsOrder;
X
Xiaoyu Wang 已提交
213 214
} SWindowLogicNode;

X
Xiaoyu Wang 已提交
215
typedef struct SFillLogicNode {
X
Xiaoyu Wang 已提交
216 217
  SLogicNode  node;
  EFillMode   mode;
218 219
  SNodeList*  pFillExprs;
  SNodeList*  pNotFillExprs;
X
Xiaoyu Wang 已提交
220 221 222
  SNode*      pWStartTs;
  SNode*      pValues;  // SNodeListNode
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
223
  EOrder      inputTsOrder;
X
Xiaoyu Wang 已提交
224 225
} SFillLogicNode;

X
Xiaoyu Wang 已提交
226 227 228
typedef struct SSortLogicNode {
  SLogicNode node;
  SNodeList* pSortKeys;
229
  bool       groupSort;
X
Xiaoyu Wang 已提交
230 231
} SSortLogicNode;

232 233 234 235 236
typedef struct SPartitionLogicNode {
  SLogicNode node;
  SNodeList* pPartitionKeys;
} SPartitionLogicNode;

237 238 239 240
typedef enum ESubplanType {
  SUBPLAN_TYPE_MERGE = 1,
  SUBPLAN_TYPE_PARTIAL,
  SUBPLAN_TYPE_SCAN,
241 242
  SUBPLAN_TYPE_MODIFY,
  SUBPLAN_TYPE_COMPUTE
243 244
} ESubplanType;

X
Xiaoyu Wang 已提交
245 246
typedef struct SSubplanId {
  uint64_t queryId;
247 248
  int32_t  groupId;
  int32_t  subplanId;
X
Xiaoyu Wang 已提交
249 250
} SSubplanId;

X
Xiaoyu Wang 已提交
251
typedef struct SLogicSubplan {
252 253 254 255 256 257
  ENodeType     type;
  SSubplanId    id;
  SNodeList*    pChildren;
  SNodeList*    pParents;
  SLogicNode*   pNode;
  ESubplanType  subplanType;
X
Xiaoyu Wang 已提交
258
  SVgroupsInfo* pVgroupList;
259 260
  int32_t       level;
  int32_t       splitFlag;
261
  int32_t       numOfComputeNodes;
X
Xiaoyu Wang 已提交
262
} SLogicSubplan;
X
Xiaoyu Wang 已提交
263 264

typedef struct SQueryLogicPlan {
265
  ENodeType  type;
X
Xiaoyu Wang 已提交
266
  SNodeList* pTopSubplans;
X
Xiaoyu Wang 已提交
267 268
} SQueryLogicPlan;

X
Xiaoyu Wang 已提交
269 270
typedef struct SSlotDescNode {
  ENodeType type;
271
  int16_t   slotId;
X
Xiaoyu Wang 已提交
272
  SDataType dataType;
273 274 275
  bool      reserve;
  bool      output;
  bool      tag;
276
  char      name[SLOT_NAME_LEN];
X
Xiaoyu Wang 已提交
277 278
} SSlotDescNode;

X
Xiaoyu Wang 已提交
279
typedef struct SDataBlockDescNode {
280 281
  ENodeType  type;
  int16_t    dataBlockId;
X
Xiaoyu Wang 已提交
282
  SNodeList* pSlots;
283 284 285
  int32_t    totalRowSize;
  int32_t    outputRowSize;
  uint8_t    precision;
X
Xiaoyu Wang 已提交
286
} SDataBlockDescNode;
X
Xiaoyu Wang 已提交
287 288

typedef struct SPhysiNode {
289
  ENodeType           type;
X
Xiaoyu Wang 已提交
290
  SDataBlockDescNode* pOutputDataBlockDesc;
291 292 293
  SNode*              pConditions;
  SNodeList*          pChildren;
  struct SPhysiNode*  pParent;
294 295
  SNode*              pLimit;
  SNode*              pSlimit;
X
Xiaoyu Wang 已提交
296 297 298
} SPhysiNode;

typedef struct SScanPhysiNode {
X
Xiaoyu Wang 已提交
299
  SPhysiNode node;
X
Xiaoyu Wang 已提交
300
  SNodeList* pScanCols;
301 302
  SNodeList* pScanPseudoCols;
  uint64_t   uid;  // unique id of the table
X
Xiaoyu Wang 已提交
303
  uint64_t   suid;
304 305
  int8_t     tableType;
  SName      tableName;
X
Xiaoyu Wang 已提交
306 307 308
} SScanPhysiNode;

typedef SScanPhysiNode STagScanPhysiNode;
309
typedef SScanPhysiNode SBlockDistScanPhysiNode;
X
Xiaoyu Wang 已提交
310 311 312 313 314 315

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

X
Xiaoyu Wang 已提交
317 318
typedef struct SSystemTableScanPhysiNode {
  SScanPhysiNode scan;
319 320 321
  SEpSet         mgmtEpSet;
  bool           showRewrite;
  int32_t        accountId;
322
  bool           sysInfo;
X
Xiaoyu Wang 已提交
323 324
} SSystemTableScanPhysiNode;

X
Xiaoyu Wang 已提交
325 326
typedef struct STableScanPhysiNode {
  SScanPhysiNode scan;
327 328 329 330 331
  uint8_t        scanSeq[2];  // first is scan count, and second is reverse scan count
  STimeWindow    scanRange;
  double         ratio;
  int32_t        dataRequired;
  SNodeList*     pDynamicScanFuncs;
332 333
  SNodeList*     pGroupTags;
  bool           groupSort;
334 335 336 337 338
  int64_t        interval;
  int64_t        offset;
  int64_t        sliding;
  int8_t         intervalUnit;
  int8_t         slidingUnit;
5
54liuyao 已提交
339 340
  int8_t         triggerType;
  int64_t        watermark;
341
  int8_t         igExpired;
X
Xiaoyu Wang 已提交
342
  bool           assignBlockUid;
X
Xiaoyu Wang 已提交
343 344 345
} STableScanPhysiNode;

typedef STableScanPhysiNode STableSeqScanPhysiNode;
X
Xiaoyu Wang 已提交
346
typedef STableScanPhysiNode STableMergeScanPhysiNode;
5
54liuyao 已提交
347
typedef STableScanPhysiNode SStreamScanPhysiNode;
X
Xiaoyu Wang 已提交
348 349 350 351

typedef struct SProjectPhysiNode {
  SPhysiNode node;
  SNodeList* pProjections;
352
  bool       mergeDataBlock;
353
  bool       ignoreGroupId;
X
Xiaoyu Wang 已提交
354 355
} SProjectPhysiNode;

356 357 358
typedef struct SIndefRowsFuncPhysiNode {
  SPhysiNode node;
  SNodeList* pExprs;
X
Xiaoyu Wang 已提交
359
  SNodeList* pFuncs;
360 361
} SIndefRowsFuncPhysiNode;

X
Xiaoyu Wang 已提交
362 363 364 365 366 367
typedef struct SInterpFuncPhysiNode {
  SPhysiNode  node;
  SNodeList*  pExprs;
  SNodeList*  pFuncs;
  STimeWindow timeRange;
  int64_t     interval;
D
dapan1121 已提交
368
  int8_t      intervalUnit;
X
Xiaoyu Wang 已提交
369 370 371
  EFillMode   fillMode;
  SNode*      pFillValues;  // SNodeListNode
  SNode*      pTimeSeries;  // SColumnNode
X
Xiaoyu Wang 已提交
372 373
} SInterpFuncPhysiNode;

374
typedef struct SSortMergeJoinPhysiNode {
X
Xiaoyu Wang 已提交
375
  SPhysiNode node;
376
  EJoinType  joinType;
377
  SNode*     pMergeCondition;
X
Xiaoyu Wang 已提交
378
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
379
  SNodeList* pTargets;
380 381
  EOrder     inputTsOrder;
} SSortMergeJoinPhysiNode;
X
Xiaoyu Wang 已提交
382

X
Xiaoyu Wang 已提交
383 384
typedef struct SAggPhysiNode {
  SPhysiNode node;
385
  SNodeList* pExprs;  // these are expression list of group_by_clause and parameter expression of aggregate function
X
Xiaoyu Wang 已提交
386
  SNodeList* pGroupKeys;
X
Xiaoyu Wang 已提交
387
  SNodeList* pAggFuncs;
388
  bool       mergeDataBlock;
X
Xiaoyu Wang 已提交
389 390
} SAggPhysiNode;

X
Xiaoyu Wang 已提交
391
typedef struct SDownstreamSourceNode {
392
  ENodeType      type;
X
Xiaoyu Wang 已提交
393
  SQueryNodeAddr addr;
394 395
  uint64_t       taskId;
  uint64_t       schedId;
D
dapan1121 已提交
396
  int32_t        execId;
D
dapan1121 已提交
397
  int32_t        fetchMsgType;
X
Xiaoyu Wang 已提交
398
} SDownstreamSourceNode;
X
Xiaoyu Wang 已提交
399 400

typedef struct SExchangePhysiNode {
X
Xiaoyu Wang 已提交
401
  SPhysiNode node;
X
Xiaoyu Wang 已提交
402
  int32_t    srcGroupId;  // group id of datasource suplans
D
dapan1121 已提交
403
  bool       singleChannel;
X
Xiaoyu Wang 已提交
404
  SNodeList* pSrcEndPoints;  // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
X
Xiaoyu Wang 已提交
405 406
} SExchangePhysiNode;

X
Xiaoyu Wang 已提交
407 408 409
typedef struct SMergePhysiNode {
  SPhysiNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
410
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
411 412
  int32_t    numOfChannels;
  int32_t    srcGroupId;
413
  bool       groupSort;
X
Xiaoyu Wang 已提交
414 415
} SMergePhysiNode;

X
Xiaoyu Wang 已提交
416
typedef struct SWinodwPhysiNode {
X
Xiaoyu Wang 已提交
417
  SPhysiNode node;
418
  SNodeList* pExprs;  // these are expression list of parameter expression of function
X
Xiaoyu Wang 已提交
419
  SNodeList* pFuncs;
X
Xiaoyu Wang 已提交
420 421
  SNode*     pTspk;   // timestamp primary key
  SNode*     pTsEnd;  // window end timestamp
422 423
  int8_t     triggerType;
  int64_t    watermark;
424
  int8_t     igExpired;
X
Xiaoyu Wang 已提交
425 426
  EOrder     inputTsOrder;
  EOrder     outputTsOrder;
427
  bool       mergeDataBlock;
X
Xiaoyu Wang 已提交
428 429 430 431
} SWinodwPhysiNode;

typedef struct SIntervalPhysiNode {
  SWinodwPhysiNode window;
432 433 434 435 436
  int64_t          interval;
  int64_t          offset;
  int64_t          sliding;
  int8_t           intervalUnit;
  int8_t           slidingUnit;
X
Xiaoyu Wang 已提交
437 438
} SIntervalPhysiNode;

439
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
440
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
X
Xiaoyu Wang 已提交
441
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
442 443
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode;
X
Xiaoyu Wang 已提交
444

X
Xiaoyu Wang 已提交
445
typedef struct SFillPhysiNode {
X
Xiaoyu Wang 已提交
446 447
  SPhysiNode  node;
  EFillMode   mode;
448 449
  SNodeList*  pFillExprs;
  SNodeList*  pNotFillExprs;
X
Xiaoyu Wang 已提交
450 451 452
  SNode*      pWStartTs;  // SColumnNode
  SNode*      pValues;    // SNodeListNode
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
453
  EOrder      inputTsOrder;
X
Xiaoyu Wang 已提交
454 455
} SFillPhysiNode;

456 457
typedef struct SMultiTableIntervalPhysiNode {
  SIntervalPhysiNode interval;
458
  SNodeList*         pPartitionKeys;
459 460
} SMultiTableIntervalPhysiNode;

X
Xiaoyu Wang 已提交
461 462
typedef struct SSessionWinodwPhysiNode {
  SWinodwPhysiNode window;
463
  int64_t          gap;
X
Xiaoyu Wang 已提交
464 465
} SSessionWinodwPhysiNode;

5
54liuyao 已提交
466
typedef SSessionWinodwPhysiNode SStreamSessionWinodwPhysiNode;
467 468
typedef SSessionWinodwPhysiNode SStreamSemiSessionWinodwPhysiNode;
typedef SSessionWinodwPhysiNode SStreamFinalSessionWinodwPhysiNode;
5
54liuyao 已提交
469

470 471
typedef struct SStateWinodwPhysiNode {
  SWinodwPhysiNode window;
472
  SNode*           pStateKey;
473 474
} SStateWinodwPhysiNode;

5
54liuyao 已提交
475 476
typedef SStateWinodwPhysiNode SStreamStateWinodwPhysiNode;

X
Xiaoyu Wang 已提交
477 478
typedef struct SSortPhysiNode {
  SPhysiNode node;
479 480
  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 已提交
481
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
482 483
} SSortPhysiNode;

S
shenglian zhou 已提交
484 485
typedef SSortPhysiNode SGroupSortPhysiNode;

486 487
typedef struct SPartitionPhysiNode {
  SPhysiNode node;
488
  SNodeList* pExprs;  // these are expression list of partition_by_clause
489
  SNodeList* pPartitionKeys;
X
Xiaoyu Wang 已提交
490
  SNodeList* pTargets;
491 492
} SPartitionPhysiNode;

493 494
typedef SPartitionPhysiNode SStreamPartitionPhysiNode;

X
Xiaoyu Wang 已提交
495
typedef struct SDataSinkNode {
496
  ENodeType           type;
X
Xiaoyu Wang 已提交
497
  SDataBlockDescNode* pInputDataBlockDesc;
X
Xiaoyu Wang 已提交
498 499 500 501 502 503 504 505
} SDataSinkNode;

typedef struct SDataDispatcherNode {
  SDataSinkNode sink;
} SDataDispatcherNode;

typedef struct SDataInserterNode {
  SDataSinkNode sink;
506 507 508
  int32_t       numOfTables;
  uint32_t      size;
  char*         pData;
X
Xiaoyu Wang 已提交
509 510
} SDataInserterNode;

511 512
typedef struct SQueryInserterNode {
  SDataSinkNode sink;
513
  SNodeList*    pCols;
514
  uint64_t      tableId;
515
  uint64_t      stableId;
516
  int8_t        tableType;  // table type
517
  char          tableName[TSDB_TABLE_NAME_LEN];
518 519 520 521
  int32_t       vgId;
  SEpSet        epSet;
} SQueryInserterNode;

X
Xiaoyu Wang 已提交
522 523 524 525
typedef struct SDataDeleterNode {
  SDataSinkNode sink;
  uint64_t      tableId;
  int8_t        tableType;  // table type
526
  char          tableFName[TSDB_TABLE_NAME_LEN];
wmmhello's avatar
wmmhello 已提交
527
  char          tsColName[TSDB_COL_NAME_LEN];
X
Xiaoyu Wang 已提交
528
  STimeWindow   deleteTimeRange;
X
Xiaoyu Wang 已提交
529
  SNode*        pAffectedRows;
530 531
  SNode*        pStartTs;
  SNode*        pEndTs;
X
Xiaoyu Wang 已提交
532 533
} SDataDeleterNode;

X
Xiaoyu Wang 已提交
534
typedef struct SSubplan {
535 536 537 538 539 540
  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 已提交
541
  char           user[TSDB_USER_LEN];
542 543 544 545 546 547
  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 已提交
548
  SNode*         pTagCond;
X
Xiaoyu Wang 已提交
549
  SNode*         pTagIndexCond;
X
Xiaoyu Wang 已提交
550 551
} SSubplan;

552
typedef enum EExplainMode { EXPLAIN_MODE_DISABLE = 1, EXPLAIN_MODE_STATIC, EXPLAIN_MODE_ANALYZE } EExplainMode;
553 554 555

typedef struct SExplainInfo {
  EExplainMode mode;
556 557
  bool         verbose;
  double       ratio;
558
} SExplainInfo;
559

X
Xiaoyu Wang 已提交
560
typedef struct SQueryPlan {
561 562 563 564
  ENodeType    type;
  uint64_t     queryId;
  int32_t      numOfSubplans;
  SNodeList*   pSubplans;  // Element is SNodeListNode. The execution level of subplan, starting from 0.
565
  SExplainInfo explainInfo;
X
Xiaoyu Wang 已提交
566 567
} SQueryPlan;

568 569
void nodesWalkPhysiPlan(SNode* pNode, FNodeWalker walker, void* pContext);

H
Haojun Liao 已提交
570 571
const char* dataOrderStr(EDataOrderLevel order);

X
Xiaoyu Wang 已提交
572 573 574 575 576
#ifdef __cplusplus
}
#endif

#endif /*_TD_PLANN_NODES_H_*/