plannodes.h 16.3 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 98
  SNodeList*    pTags;      // for create stream
  SNode*        pSubtable;  // for create stream
99
  int8_t        cacheLastMode;
100
  bool          hasNormalCols;  // neither tag column nor primary key tag column
X
Xiaoyu Wang 已提交
101
  bool          sortPrimaryKey;
X
Xiaoyu Wang 已提交
102 103 104 105
} SScanLogicNode;

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

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

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

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

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

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

X
Xiaoyu Wang 已提交
168 169
typedef struct SExchangeLogicNode {
  SLogicNode node;
170 171
  int32_t    srcStartGroupId;
  int32_t    srcEndGroupId;
X
Xiaoyu Wang 已提交
172 173
} SExchangeLogicNode;

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

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

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

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

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

X
Xiaoyu Wang 已提交
229 230 231
typedef struct SSortLogicNode {
  SLogicNode node;
  SNodeList* pSortKeys;
232
  bool       groupSort;
X
Xiaoyu Wang 已提交
233 234
} SSortLogicNode;

235 236 237
typedef struct SPartitionLogicNode {
  SLogicNode node;
  SNodeList* pPartitionKeys;
238 239
  SNodeList* pTags;
  SNode*     pSubtable;
240 241
} SPartitionLogicNode;

242 243 244 245
typedef enum ESubplanType {
  SUBPLAN_TYPE_MERGE = 1,
  SUBPLAN_TYPE_PARTIAL,
  SUBPLAN_TYPE_SCAN,
246 247
  SUBPLAN_TYPE_MODIFY,
  SUBPLAN_TYPE_COMPUTE
248 249
} ESubplanType;

X
Xiaoyu Wang 已提交
250 251
typedef struct SSubplanId {
  uint64_t queryId;
252 253
  int32_t  groupId;
  int32_t  subplanId;
X
Xiaoyu Wang 已提交
254 255
} SSubplanId;

X
Xiaoyu Wang 已提交
256
typedef struct SLogicSubplan {
257 258 259 260 261 262
  ENodeType     type;
  SSubplanId    id;
  SNodeList*    pChildren;
  SNodeList*    pParents;
  SLogicNode*   pNode;
  ESubplanType  subplanType;
X
Xiaoyu Wang 已提交
263
  SVgroupsInfo* pVgroupList;
264 265
  int32_t       level;
  int32_t       splitFlag;
266
  int32_t       numOfComputeNodes;
X
Xiaoyu Wang 已提交
267
} SLogicSubplan;
X
Xiaoyu Wang 已提交
268 269

typedef struct SQueryLogicPlan {
270
  ENodeType  type;
X
Xiaoyu Wang 已提交
271
  SNodeList* pTopSubplans;
X
Xiaoyu Wang 已提交
272 273
} SQueryLogicPlan;

X
Xiaoyu Wang 已提交
274 275
typedef struct SSlotDescNode {
  ENodeType type;
276
  int16_t   slotId;
X
Xiaoyu Wang 已提交
277
  SDataType dataType;
278 279 280
  bool      reserve;
  bool      output;
  bool      tag;
281
  char      name[SLOT_NAME_LEN];
X
Xiaoyu Wang 已提交
282 283
} SSlotDescNode;

X
Xiaoyu Wang 已提交
284
typedef struct SDataBlockDescNode {
285 286
  ENodeType  type;
  int16_t    dataBlockId;
X
Xiaoyu Wang 已提交
287
  SNodeList* pSlots;
288 289 290
  int32_t    totalRowSize;
  int32_t    outputRowSize;
  uint8_t    precision;
X
Xiaoyu Wang 已提交
291
} SDataBlockDescNode;
X
Xiaoyu Wang 已提交
292 293

typedef struct SPhysiNode {
294
  ENodeType           type;
X
Xiaoyu Wang 已提交
295
  SDataBlockDescNode* pOutputDataBlockDesc;
296 297 298
  SNode*              pConditions;
  SNodeList*          pChildren;
  struct SPhysiNode*  pParent;
299 300
  SNode*              pLimit;
  SNode*              pSlimit;
X
Xiaoyu Wang 已提交
301 302 303
} SPhysiNode;

typedef struct SScanPhysiNode {
X
Xiaoyu Wang 已提交
304
  SPhysiNode node;
X
Xiaoyu Wang 已提交
305
  SNodeList* pScanCols;
306 307
  SNodeList* pScanPseudoCols;
  uint64_t   uid;  // unique id of the table
X
Xiaoyu Wang 已提交
308
  uint64_t   suid;
309 310
  int8_t     tableType;
  SName      tableName;
X
Xiaoyu Wang 已提交
311 312 313
} SScanPhysiNode;

typedef SScanPhysiNode STagScanPhysiNode;
314
typedef SScanPhysiNode SBlockDistScanPhysiNode;
X
Xiaoyu Wang 已提交
315 316 317 318 319 320

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

X
Xiaoyu Wang 已提交
322 323
typedef struct SSystemTableScanPhysiNode {
  SScanPhysiNode scan;
324 325 326
  SEpSet         mgmtEpSet;
  bool           showRewrite;
  int32_t        accountId;
327
  bool           sysInfo;
X
Xiaoyu Wang 已提交
328 329
} SSystemTableScanPhysiNode;

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

typedef STableScanPhysiNode STableSeqScanPhysiNode;
X
Xiaoyu Wang 已提交
353
typedef STableScanPhysiNode STableMergeScanPhysiNode;
5
54liuyao 已提交
354
typedef STableScanPhysiNode SStreamScanPhysiNode;
X
Xiaoyu Wang 已提交
355 356 357 358

typedef struct SProjectPhysiNode {
  SPhysiNode node;
  SNodeList* pProjections;
359
  bool       mergeDataBlock;
360
  bool       ignoreGroupId;
X
Xiaoyu Wang 已提交
361 362
} SProjectPhysiNode;

363 364 365
typedef struct SIndefRowsFuncPhysiNode {
  SPhysiNode node;
  SNodeList* pExprs;
X
Xiaoyu Wang 已提交
366
  SNodeList* pFuncs;
367 368
} SIndefRowsFuncPhysiNode;

X
Xiaoyu Wang 已提交
369 370 371 372 373 374
typedef struct SInterpFuncPhysiNode {
  SPhysiNode  node;
  SNodeList*  pExprs;
  SNodeList*  pFuncs;
  STimeWindow timeRange;
  int64_t     interval;
D
dapan1121 已提交
375
  int8_t      intervalUnit;
X
Xiaoyu Wang 已提交
376 377 378
  EFillMode   fillMode;
  SNode*      pFillValues;  // SNodeListNode
  SNode*      pTimeSeries;  // SColumnNode
X
Xiaoyu Wang 已提交
379 380
} SInterpFuncPhysiNode;

381
typedef struct SSortMergeJoinPhysiNode {
X
Xiaoyu Wang 已提交
382
  SPhysiNode node;
383
  EJoinType  joinType;
384
  SNode*     pMergeCondition;
X
Xiaoyu Wang 已提交
385
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
386
  SNodeList* pTargets;
387 388
  EOrder     inputTsOrder;
} SSortMergeJoinPhysiNode;
X
Xiaoyu Wang 已提交
389

X
Xiaoyu Wang 已提交
390 391
typedef struct SAggPhysiNode {
  SPhysiNode node;
392
  SNodeList* pExprs;  // these are expression list of group_by_clause and parameter expression of aggregate function
X
Xiaoyu Wang 已提交
393
  SNodeList* pGroupKeys;
X
Xiaoyu Wang 已提交
394
  SNodeList* pAggFuncs;
395
  bool       mergeDataBlock;
X
Xiaoyu Wang 已提交
396 397
} SAggPhysiNode;

X
Xiaoyu Wang 已提交
398
typedef struct SDownstreamSourceNode {
399
  ENodeType      type;
X
Xiaoyu Wang 已提交
400
  SQueryNodeAddr addr;
401 402
  uint64_t       taskId;
  uint64_t       schedId;
D
dapan1121 已提交
403
  int32_t        execId;
D
dapan1121 已提交
404
  int32_t        fetchMsgType;
D
dapan1121 已提交
405
  bool           localExec;
X
Xiaoyu Wang 已提交
406
} SDownstreamSourceNode;
X
Xiaoyu Wang 已提交
407 408

typedef struct SExchangePhysiNode {
X
Xiaoyu Wang 已提交
409
  SPhysiNode node;
410 411 412 413
  // for set operators, there will be multiple execution groups under one exchange, and the ids of these execution
  // groups are consecutive
  int32_t    srcStartGroupId;
  int32_t    srcEndGroupId;
D
dapan1121 已提交
414
  bool       singleChannel;
X
Xiaoyu Wang 已提交
415
  SNodeList* pSrcEndPoints;  // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
X
Xiaoyu Wang 已提交
416 417
} SExchangePhysiNode;

X
Xiaoyu Wang 已提交
418 419 420
typedef struct SMergePhysiNode {
  SPhysiNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
421
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
422 423
  int32_t    numOfChannels;
  int32_t    srcGroupId;
424
  bool       groupSort;
X
Xiaoyu Wang 已提交
425 426
} SMergePhysiNode;

X
Xiaoyu Wang 已提交
427
typedef struct SWinodwPhysiNode {
X
Xiaoyu Wang 已提交
428
  SPhysiNode node;
429
  SNodeList* pExprs;  // these are expression list of parameter expression of function
X
Xiaoyu Wang 已提交
430
  SNodeList* pFuncs;
X
Xiaoyu Wang 已提交
431 432
  SNode*     pTspk;   // timestamp primary key
  SNode*     pTsEnd;  // window end timestamp
433 434
  int8_t     triggerType;
  int64_t    watermark;
435
  int8_t     igExpired;
X
Xiaoyu Wang 已提交
436 437
  EOrder     inputTsOrder;
  EOrder     outputTsOrder;
438
  bool       mergeDataBlock;
X
Xiaoyu Wang 已提交
439 440 441 442
} SWinodwPhysiNode;

typedef struct SIntervalPhysiNode {
  SWinodwPhysiNode window;
443 444 445 446 447
  int64_t          interval;
  int64_t          offset;
  int64_t          sliding;
  int8_t           intervalUnit;
  int8_t           slidingUnit;
X
Xiaoyu Wang 已提交
448 449
} SIntervalPhysiNode;

450
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
451
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
X
Xiaoyu Wang 已提交
452
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
453 454
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode;
X
Xiaoyu Wang 已提交
455

X
Xiaoyu Wang 已提交
456
typedef struct SFillPhysiNode {
X
Xiaoyu Wang 已提交
457 458
  SPhysiNode  node;
  EFillMode   mode;
459 460
  SNodeList*  pFillExprs;
  SNodeList*  pNotFillExprs;
X
Xiaoyu Wang 已提交
461 462 463
  SNode*      pWStartTs;  // SColumnNode
  SNode*      pValues;    // SNodeListNode
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
464
  EOrder      inputTsOrder;
X
Xiaoyu Wang 已提交
465 466
} SFillPhysiNode;

467 468
typedef struct SMultiTableIntervalPhysiNode {
  SIntervalPhysiNode interval;
469
  SNodeList*         pPartitionKeys;
470 471
} SMultiTableIntervalPhysiNode;

X
Xiaoyu Wang 已提交
472 473
typedef struct SSessionWinodwPhysiNode {
  SWinodwPhysiNode window;
474
  int64_t          gap;
X
Xiaoyu Wang 已提交
475 476
} SSessionWinodwPhysiNode;

5
54liuyao 已提交
477
typedef SSessionWinodwPhysiNode SStreamSessionWinodwPhysiNode;
478 479
typedef SSessionWinodwPhysiNode SStreamSemiSessionWinodwPhysiNode;
typedef SSessionWinodwPhysiNode SStreamFinalSessionWinodwPhysiNode;
5
54liuyao 已提交
480

481 482
typedef struct SStateWinodwPhysiNode {
  SWinodwPhysiNode window;
483
  SNode*           pStateKey;
484 485
} SStateWinodwPhysiNode;

5
54liuyao 已提交
486 487
typedef SStateWinodwPhysiNode SStreamStateWinodwPhysiNode;

X
Xiaoyu Wang 已提交
488 489
typedef struct SSortPhysiNode {
  SPhysiNode node;
490 491
  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 已提交
492
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
493 494
} SSortPhysiNode;

S
shenglian zhou 已提交
495 496
typedef SSortPhysiNode SGroupSortPhysiNode;

497 498
typedef struct SPartitionPhysiNode {
  SPhysiNode node;
499
  SNodeList* pExprs;  // these are expression list of partition_by_clause
500
  SNodeList* pPartitionKeys;
X
Xiaoyu Wang 已提交
501
  SNodeList* pTargets;
502 503
} SPartitionPhysiNode;

504 505 506 507 508
typedef struct SStreamPartitionPhysiNode {
  SPartitionPhysiNode part;
  SNodeList*          pTags;
  SNode*              pSubtable;
} SStreamPartitionPhysiNode;
509

X
Xiaoyu Wang 已提交
510
typedef struct SDataSinkNode {
511
  ENodeType           type;
X
Xiaoyu Wang 已提交
512
  SDataBlockDescNode* pInputDataBlockDesc;
X
Xiaoyu Wang 已提交
513 514 515 516 517 518 519 520
} SDataSinkNode;

typedef struct SDataDispatcherNode {
  SDataSinkNode sink;
} SDataDispatcherNode;

typedef struct SDataInserterNode {
  SDataSinkNode sink;
521 522 523
  int32_t       numOfTables;
  uint32_t      size;
  char*         pData;
X
Xiaoyu Wang 已提交
524 525
} SDataInserterNode;

526 527
typedef struct SQueryInserterNode {
  SDataSinkNode sink;
528
  SNodeList*    pCols;
529
  uint64_t      tableId;
530
  uint64_t      stableId;
531
  int8_t        tableType;  // table type
532
  char          tableName[TSDB_TABLE_NAME_LEN];
533 534 535 536
  int32_t       vgId;
  SEpSet        epSet;
} SQueryInserterNode;

X
Xiaoyu Wang 已提交
537 538 539 540
typedef struct SDataDeleterNode {
  SDataSinkNode sink;
  uint64_t      tableId;
  int8_t        tableType;  // table type
541
  char          tableFName[TSDB_TABLE_NAME_LEN];
wmmhello's avatar
wmmhello 已提交
542
  char          tsColName[TSDB_COL_NAME_LEN];
X
Xiaoyu Wang 已提交
543
  STimeWindow   deleteTimeRange;
X
Xiaoyu Wang 已提交
544
  SNode*        pAffectedRows;
545 546
  SNode*        pStartTs;
  SNode*        pEndTs;
X
Xiaoyu Wang 已提交
547 548
} SDataDeleterNode;

X
Xiaoyu Wang 已提交
549
typedef struct SSubplan {
550 551 552 553 554 555
  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 已提交
556
  char           user[TSDB_USER_LEN];
557 558 559 560 561 562
  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 已提交
563
  SNode*         pTagCond;
X
Xiaoyu Wang 已提交
564
  SNode*         pTagIndexCond;
X
Xiaoyu Wang 已提交
565 566
} SSubplan;

567
typedef enum EExplainMode { EXPLAIN_MODE_DISABLE = 1, EXPLAIN_MODE_STATIC, EXPLAIN_MODE_ANALYZE } EExplainMode;
568 569 570

typedef struct SExplainInfo {
  EExplainMode mode;
571 572
  bool         verbose;
  double       ratio;
573
} SExplainInfo;
574

X
Xiaoyu Wang 已提交
575
typedef struct SQueryPlan {
576 577 578 579
  ENodeType    type;
  uint64_t     queryId;
  int32_t      numOfSubplans;
  SNodeList*   pSubplans;  // Element is SNodeListNode. The execution level of subplan, starting from 0.
580
  SExplainInfo explainInfo;
X
Xiaoyu Wang 已提交
581 582
} SQueryPlan;

583 584
void nodesWalkPhysiPlan(SNode* pNode, FNodeWalker walker, void* pContext);

H
Haojun Liao 已提交
585 586
const char* dataOrderStr(EDataOrderLevel order);

X
Xiaoyu Wang 已提交
587 588 589 590 591
#ifdef __cplusplus
}
#endif

#endif /*_TD_PLANN_NODES_H_*/