plannodes.h 15.2 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;
X
Xiaoyu Wang 已提交
117 118 119 120 121
} SAggLogicNode;

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

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

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

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

X
Xiaoyu Wang 已提交
162 163
typedef struct SExchangeLogicNode {
  SLogicNode node;
164
  int32_t    srcGroupId;
X
Xiaoyu Wang 已提交
165 166
} SExchangeLogicNode;

X
Xiaoyu Wang 已提交
167 168 169
typedef struct SMergeLogicNode {
  SLogicNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
170
  SNodeList* pInputs;
X
Xiaoyu Wang 已提交
171 172
  int32_t    numOfChannels;
  int32_t    srcGroupId;
173
  bool       groupSort;
X
Xiaoyu Wang 已提交
174 175
} SMergeLogicNode;

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

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

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

X
Xiaoyu Wang 已提交
210
typedef struct SFillLogicNode {
X
Xiaoyu Wang 已提交
211 212 213 214 215
  SLogicNode  node;
  EFillMode   mode;
  SNode*      pWStartTs;
  SNode*      pValues;  // SNodeListNode
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
216 217
} SFillLogicNode;

X
Xiaoyu Wang 已提交
218 219 220
typedef struct SSortLogicNode {
  SLogicNode node;
  SNodeList* pSortKeys;
221
  bool       groupSort;
X
Xiaoyu Wang 已提交
222 223
} SSortLogicNode;

224 225 226 227 228
typedef struct SPartitionLogicNode {
  SLogicNode node;
  SNodeList* pPartitionKeys;
} SPartitionLogicNode;

229 230 231 232
typedef enum ESubplanType {
  SUBPLAN_TYPE_MERGE = 1,
  SUBPLAN_TYPE_PARTIAL,
  SUBPLAN_TYPE_SCAN,
233 234
  SUBPLAN_TYPE_MODIFY,
  SUBPLAN_TYPE_COMPUTE
235 236
} ESubplanType;

X
Xiaoyu Wang 已提交
237 238
typedef struct SSubplanId {
  uint64_t queryId;
239 240
  int32_t  groupId;
  int32_t  subplanId;
X
Xiaoyu Wang 已提交
241 242
} SSubplanId;

X
Xiaoyu Wang 已提交
243
typedef struct SLogicSubplan {
244 245 246 247 248 249
  ENodeType     type;
  SSubplanId    id;
  SNodeList*    pChildren;
  SNodeList*    pParents;
  SLogicNode*   pNode;
  ESubplanType  subplanType;
X
Xiaoyu Wang 已提交
250
  SVgroupsInfo* pVgroupList;
251 252
  int32_t       level;
  int32_t       splitFlag;
253
  int32_t       numOfComputeNodes;
X
Xiaoyu Wang 已提交
254
} SLogicSubplan;
X
Xiaoyu Wang 已提交
255 256

typedef struct SQueryLogicPlan {
257
  ENodeType  type;
X
Xiaoyu Wang 已提交
258
  SNodeList* pTopSubplans;
X
Xiaoyu Wang 已提交
259 260
} SQueryLogicPlan;

X
Xiaoyu Wang 已提交
261 262
typedef struct SSlotDescNode {
  ENodeType type;
263
  int16_t   slotId;
X
Xiaoyu Wang 已提交
264
  SDataType dataType;
265 266 267
  bool      reserve;
  bool      output;
  bool      tag;
268
  char      name[SLOT_NAME_LEN];
X
Xiaoyu Wang 已提交
269 270
} SSlotDescNode;

X
Xiaoyu Wang 已提交
271
typedef struct SDataBlockDescNode {
272 273
  ENodeType  type;
  int16_t    dataBlockId;
X
Xiaoyu Wang 已提交
274
  SNodeList* pSlots;
275 276 277
  int32_t    totalRowSize;
  int32_t    outputRowSize;
  uint8_t    precision;
X
Xiaoyu Wang 已提交
278
} SDataBlockDescNode;
X
Xiaoyu Wang 已提交
279 280

typedef struct SPhysiNode {
281
  ENodeType           type;
X
Xiaoyu Wang 已提交
282
  SDataBlockDescNode* pOutputDataBlockDesc;
283 284 285
  SNode*              pConditions;
  SNodeList*          pChildren;
  struct SPhysiNode*  pParent;
286 287
  SNode*              pLimit;
  SNode*              pSlimit;
X
Xiaoyu Wang 已提交
288 289 290
} SPhysiNode;

typedef struct SScanPhysiNode {
X
Xiaoyu Wang 已提交
291
  SPhysiNode node;
X
Xiaoyu Wang 已提交
292
  SNodeList* pScanCols;
293 294
  SNodeList* pScanPseudoCols;
  uint64_t   uid;  // unique id of the table
X
Xiaoyu Wang 已提交
295
  uint64_t   suid;
296 297
  int8_t     tableType;
  SName      tableName;
X
Xiaoyu Wang 已提交
298 299 300
} SScanPhysiNode;

typedef SScanPhysiNode STagScanPhysiNode;
301
typedef SScanPhysiNode SBlockDistScanPhysiNode;
X
Xiaoyu Wang 已提交
302 303 304 305 306 307

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

X
Xiaoyu Wang 已提交
309 310
typedef struct SSystemTableScanPhysiNode {
  SScanPhysiNode scan;
311 312 313
  SEpSet         mgmtEpSet;
  bool           showRewrite;
  int32_t        accountId;
X
Xiaoyu Wang 已提交
314 315
} SSystemTableScanPhysiNode;

X
Xiaoyu Wang 已提交
316 317
typedef struct STableScanPhysiNode {
  SScanPhysiNode scan;
318 319 320 321 322
  uint8_t        scanSeq[2];  // first is scan count, and second is reverse scan count
  STimeWindow    scanRange;
  double         ratio;
  int32_t        dataRequired;
  SNodeList*     pDynamicScanFuncs;
323 324
  SNodeList*     pGroupTags;
  bool           groupSort;
325 326 327 328 329
  int64_t        interval;
  int64_t        offset;
  int64_t        sliding;
  int8_t         intervalUnit;
  int8_t         slidingUnit;
5
54liuyao 已提交
330 331
  int8_t         triggerType;
  int64_t        watermark;
332
  int8_t         igExpired;
X
Xiaoyu Wang 已提交
333
  bool           assignBlockUid;
X
Xiaoyu Wang 已提交
334 335 336
} STableScanPhysiNode;

typedef STableScanPhysiNode STableSeqScanPhysiNode;
X
Xiaoyu Wang 已提交
337
typedef STableScanPhysiNode STableMergeScanPhysiNode;
5
54liuyao 已提交
338
typedef STableScanPhysiNode SStreamScanPhysiNode;
X
Xiaoyu Wang 已提交
339 340 341 342

typedef struct SProjectPhysiNode {
  SPhysiNode node;
  SNodeList* pProjections;
343
  bool       mergeDataBlock;
X
Xiaoyu Wang 已提交
344 345
} SProjectPhysiNode;

346 347 348
typedef struct SIndefRowsFuncPhysiNode {
  SPhysiNode node;
  SNodeList* pExprs;
X
Xiaoyu Wang 已提交
349
  SNodeList* pFuncs;
350 351
} SIndefRowsFuncPhysiNode;

X
Xiaoyu Wang 已提交
352 353 354 355 356 357
typedef struct SInterpFuncPhysiNode {
  SPhysiNode  node;
  SNodeList*  pExprs;
  SNodeList*  pFuncs;
  STimeWindow timeRange;
  int64_t     interval;
D
dapan1121 已提交
358
  int8_t      intervalUnit;
X
Xiaoyu Wang 已提交
359 360 361
  EFillMode   fillMode;
  SNode*      pFillValues;  // SNodeListNode
  SNode*      pTimeSeries;  // SColumnNode
X
Xiaoyu Wang 已提交
362 363
} SInterpFuncPhysiNode;

364
typedef struct SSortMergeJoinPhysiNode {
X
Xiaoyu Wang 已提交
365
  SPhysiNode node;
366
  EJoinType  joinType;
367
  SNode*     pMergeCondition;
X
Xiaoyu Wang 已提交
368
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
369
  SNodeList* pTargets;
370 371
  EOrder     inputTsOrder;
} SSortMergeJoinPhysiNode;
X
Xiaoyu Wang 已提交
372

X
Xiaoyu Wang 已提交
373 374
typedef struct SAggPhysiNode {
  SPhysiNode node;
375
  SNodeList* pExprs;  // these are expression list of group_by_clause and parameter expression of aggregate function
X
Xiaoyu Wang 已提交
376
  SNodeList* pGroupKeys;
X
Xiaoyu Wang 已提交
377 378 379
  SNodeList* pAggFuncs;
} SAggPhysiNode;

X
Xiaoyu Wang 已提交
380
typedef struct SDownstreamSourceNode {
381
  ENodeType      type;
X
Xiaoyu Wang 已提交
382
  SQueryNodeAddr addr;
383 384
  uint64_t       taskId;
  uint64_t       schedId;
D
dapan1121 已提交
385
  int32_t        execId;
D
dapan1121 已提交
386
  int32_t        fetchMsgType;
X
Xiaoyu Wang 已提交
387
} SDownstreamSourceNode;
X
Xiaoyu Wang 已提交
388 389

typedef struct SExchangePhysiNode {
X
Xiaoyu Wang 已提交
390
  SPhysiNode node;
X
Xiaoyu Wang 已提交
391
  int32_t    srcGroupId;  // group id of datasource suplans
D
dapan1121 已提交
392
  bool       singleChannel;
X
Xiaoyu Wang 已提交
393
  SNodeList* pSrcEndPoints;  // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
X
Xiaoyu Wang 已提交
394 395
} SExchangePhysiNode;

X
Xiaoyu Wang 已提交
396 397 398
typedef struct SMergePhysiNode {
  SPhysiNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
399
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
400 401
  int32_t    numOfChannels;
  int32_t    srcGroupId;
402
  bool       groupSort;
X
Xiaoyu Wang 已提交
403 404
} SMergePhysiNode;

X
Xiaoyu Wang 已提交
405
typedef struct SWinodwPhysiNode {
X
Xiaoyu Wang 已提交
406
  SPhysiNode node;
407
  SNodeList* pExprs;  // these are expression list of parameter expression of function
X
Xiaoyu Wang 已提交
408
  SNodeList* pFuncs;
X
Xiaoyu Wang 已提交
409 410
  SNode*     pTspk;   // timestamp primary key
  SNode*     pTsEnd;  // window end timestamp
411 412
  int8_t     triggerType;
  int64_t    watermark;
413
  int8_t     igExpired;
X
Xiaoyu Wang 已提交
414 415 416 417
} SWinodwPhysiNode;

typedef struct SIntervalPhysiNode {
  SWinodwPhysiNode window;
418 419 420 421 422
  int64_t          interval;
  int64_t          offset;
  int64_t          sliding;
  int8_t           intervalUnit;
  int8_t           slidingUnit;
X
Xiaoyu Wang 已提交
423 424
} SIntervalPhysiNode;

425
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
426
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
X
Xiaoyu Wang 已提交
427
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
428 429
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode;
X
Xiaoyu Wang 已提交
430

X
Xiaoyu Wang 已提交
431
typedef struct SFillPhysiNode {
X
Xiaoyu Wang 已提交
432 433 434 435 436 437
  SPhysiNode  node;
  EFillMode   mode;
  SNode*      pWStartTs;  // SColumnNode
  SNode*      pValues;    // SNodeListNode
  SNodeList*  pTargets;
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
438 439
} SFillPhysiNode;

440 441
typedef struct SMultiTableIntervalPhysiNode {
  SIntervalPhysiNode interval;
442
  SNodeList*         pPartitionKeys;
443 444
} SMultiTableIntervalPhysiNode;

X
Xiaoyu Wang 已提交
445 446
typedef struct SSessionWinodwPhysiNode {
  SWinodwPhysiNode window;
447
  int64_t          gap;
X
Xiaoyu Wang 已提交
448 449
} SSessionWinodwPhysiNode;

5
54liuyao 已提交
450
typedef SSessionWinodwPhysiNode SStreamSessionWinodwPhysiNode;
451 452
typedef SSessionWinodwPhysiNode SStreamSemiSessionWinodwPhysiNode;
typedef SSessionWinodwPhysiNode SStreamFinalSessionWinodwPhysiNode;
5
54liuyao 已提交
453

454 455
typedef struct SStateWinodwPhysiNode {
  SWinodwPhysiNode window;
456
  SNode*           pStateKey;
457 458
} SStateWinodwPhysiNode;

5
54liuyao 已提交
459 460
typedef SStateWinodwPhysiNode SStreamStateWinodwPhysiNode;

X
Xiaoyu Wang 已提交
461 462
typedef struct SSortPhysiNode {
  SPhysiNode node;
463 464
  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 已提交
465
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
466 467
} SSortPhysiNode;

S
shenglian zhou 已提交
468 469
typedef SSortPhysiNode SGroupSortPhysiNode;

470 471
typedef struct SPartitionPhysiNode {
  SPhysiNode node;
472
  SNodeList* pExprs;  // these are expression list of partition_by_clause
473
  SNodeList* pPartitionKeys;
X
Xiaoyu Wang 已提交
474
  SNodeList* pTargets;
475 476
} SPartitionPhysiNode;

X
Xiaoyu Wang 已提交
477
typedef struct SDataSinkNode {
478
  ENodeType           type;
X
Xiaoyu Wang 已提交
479
  SDataBlockDescNode* pInputDataBlockDesc;
X
Xiaoyu Wang 已提交
480 481 482 483 484 485 486 487
} SDataSinkNode;

typedef struct SDataDispatcherNode {
  SDataSinkNode sink;
} SDataDispatcherNode;

typedef struct SDataInserterNode {
  SDataSinkNode sink;
488 489 490
  int32_t       numOfTables;
  uint32_t      size;
  char*         pData;
X
Xiaoyu Wang 已提交
491 492
} SDataInserterNode;

493 494
typedef struct SQueryInserterNode {
  SDataSinkNode sink;
495
  SNodeList*    pCols;
496
  uint64_t      tableId;
497
  uint64_t      stableId;
498
  int8_t        tableType;  // table type
499
  char          tableName[TSDB_TABLE_NAME_LEN];
500 501 502 503
  int32_t       vgId;
  SEpSet        epSet;
} SQueryInserterNode;

X
Xiaoyu Wang 已提交
504 505 506 507
typedef struct SDataDeleterNode {
  SDataSinkNode sink;
  uint64_t      tableId;
  int8_t        tableType;  // table type
508
  char          tableFName[TSDB_TABLE_NAME_LEN];
wmmhello's avatar
wmmhello 已提交
509
  char          tsColName[TSDB_COL_NAME_LEN];
X
Xiaoyu Wang 已提交
510
  STimeWindow   deleteTimeRange;
X
Xiaoyu Wang 已提交
511
  SNode*        pAffectedRows;
X
Xiaoyu Wang 已提交
512 513
} SDataDeleterNode;

X
Xiaoyu Wang 已提交
514
typedef struct SSubplan {
515 516 517 518 519 520
  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 已提交
521
  char           user[TSDB_USER_LEN];
522 523 524 525 526 527
  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 已提交
528
  SNode*         pTagCond;
X
Xiaoyu Wang 已提交
529
  SNode*         pTagIndexCond;
X
Xiaoyu Wang 已提交
530 531
} SSubplan;

532
typedef enum EExplainMode { EXPLAIN_MODE_DISABLE = 1, EXPLAIN_MODE_STATIC, EXPLAIN_MODE_ANALYZE } EExplainMode;
533 534 535

typedef struct SExplainInfo {
  EExplainMode mode;
536 537
  bool         verbose;
  double       ratio;
538
} SExplainInfo;
539

X
Xiaoyu Wang 已提交
540
typedef struct SQueryPlan {
541 542 543 544
  ENodeType    type;
  uint64_t     queryId;
  int32_t      numOfSubplans;
  SNodeList*   pSubplans;  // Element is SNodeListNode. The execution level of subplan, starting from 0.
545
  SExplainInfo explainInfo;
X
Xiaoyu Wang 已提交
546 547
} SQueryPlan;

548 549
void nodesWalkPhysiPlan(SNode* pNode, FNodeWalker walker, void* pContext);

X
Xiaoyu Wang 已提交
550 551 552 553 554
#ifdef __cplusplus
}
#endif

#endif /*_TD_PLANN_NODES_H_*/