plannodes.h 17.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;
56 57
  EOrder             inputTsOrder;
  EOrder             outputTsOrder;
X
Xiaoyu Wang 已提交
58 59
} SLogicNode;

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

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

typedef struct SJoinLogicNode {
  SLogicNode node;
112
  EJoinType  joinType;
113
  SNode*     pMergeCondition;
114
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
115
  bool       isSingleTableJoin;
S
slzhou 已提交
116
  SNode*     pColEqualOnConditions;
X
Xiaoyu Wang 已提交
117 118 119 120 121 122
} SJoinLogicNode;

typedef struct SAggLogicNode {
  SLogicNode node;
  SNodeList* pGroupKeys;
  SNodeList* pAggFuncs;
123
  bool       hasLastRow;
X
Xiaoyu Wang 已提交
124
  bool       hasLast;
125
  bool       hasTimeLineFunc;
H
Haojun Liao 已提交
126
  bool       onlyHasKeepOrderFunc;
127
  bool       hasGroupKeyOptimized;
X
Xiaoyu Wang 已提交
128 129 130 131 132
} SAggLogicNode;

typedef struct SProjectLogicNode {
  SLogicNode node;
  SNodeList* pProjections;
133
  char       stmtName[TSDB_TABLE_NAME_LEN];
134
  bool       ignoreGroupId;
X
Xiaoyu Wang 已提交
135 136
} SProjectLogicNode;

137 138
typedef struct SIndefRowsFuncLogicNode {
  SLogicNode node;
X
Xiaoyu Wang 已提交
139
  SNodeList* pFuncs;
140
  bool       isTailFunc;
141
  bool       isUniqueFunc;
142
  bool       isTimeLineFunc;
143 144
} SIndefRowsFuncLogicNode;

X
Xiaoyu Wang 已提交
145 146 147 148 149
typedef struct SInterpFuncLogicNode {
  SLogicNode  node;
  SNodeList*  pFuncs;
  STimeWindow timeRange;
  int64_t     interval;
X
Xiaoyu Wang 已提交
150 151 152
  EFillMode   fillMode;
  SNode*      pFillValues;  // SNodeListNode
  SNode*      pTimeSeries;  // SColumnNode
X
Xiaoyu Wang 已提交
153 154
} SInterpFuncLogicNode;

X
Xiaoyu Wang 已提交
155 156 157 158 159 160 161 162
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 已提交
163
  SNode*           pAffectedRows;  // SColumnNode
164 165
  SNode*           pStartTs;       // SColumnNode
  SNode*           pEndTs;         // SColumnNode
X
Xiaoyu Wang 已提交
166
  uint64_t         tableId;
167
  uint64_t         stableId;
X
Xiaoyu Wang 已提交
168
  int8_t           tableType;  // table type
169
  char             tableName[TSDB_TABLE_NAME_LEN];
170
  char             tsColName[TSDB_COL_NAME_LEN];
X
Xiaoyu Wang 已提交
171
  STimeWindow      deleteTimeRange;
172
  SVgroupsInfo*    pVgroupList;
173
  SNodeList*       pInsertCols;
X
Xiaoyu Wang 已提交
174
} SVnodeModifyLogicNode;
175

X
Xiaoyu Wang 已提交
176 177
typedef struct SExchangeLogicNode {
  SLogicNode node;
178 179
  int32_t    srcStartGroupId;
  int32_t    srcEndGroupId;
X
Xiaoyu Wang 已提交
180
  bool       seqRecvData;
X
Xiaoyu Wang 已提交
181 182
} SExchangeLogicNode;

X
Xiaoyu Wang 已提交
183 184 185
typedef struct SMergeLogicNode {
  SLogicNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
186
  SNodeList* pInputs;
X
Xiaoyu Wang 已提交
187 188
  int32_t    numOfChannels;
  int32_t    srcGroupId;
189
  bool       groupSort;
D
dapan1121 已提交
190
  bool       ignoreGroupId;
X
Xiaoyu Wang 已提交
191 192
} SMergeLogicNode;

X
Xiaoyu Wang 已提交
193 194 195 196 197 198
typedef enum EWindowType {
  WINDOW_TYPE_INTERVAL = 1,
  WINDOW_TYPE_SESSION,
  WINDOW_TYPE_STATE,
  WINDOW_TYPE_EVENT
} EWindowType;
X
Xiaoyu Wang 已提交
199

200
typedef enum EWindowAlgorithm {
X
Xiaoyu Wang 已提交
201
  INTERVAL_ALGO_HASH = 1,
X
Xiaoyu Wang 已提交
202
  INTERVAL_ALGO_MERGE,
X
Xiaoyu Wang 已提交
203 204 205
  INTERVAL_ALGO_STREAM_FINAL,
  INTERVAL_ALGO_STREAM_SEMI,
  INTERVAL_ALGO_STREAM_SINGLE,
206 207 208 209 210
  SESSION_ALGO_STREAM_SEMI,
  SESSION_ALGO_STREAM_FINAL,
  SESSION_ALGO_STREAM_SINGLE,
  SESSION_ALGO_MERGE,
} EWindowAlgorithm;
211

X
Xiaoyu Wang 已提交
212
typedef struct SWindowLogicNode {
213 214 215 216 217 218 219 220 221 222
  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 已提交
223
  SNode*           pTsEnd;
224
  SNode*           pStateExpr;
X
Xiaoyu Wang 已提交
225 226
  SNode*           pStartCond;
  SNode*           pEndCond;
227 228
  int8_t           triggerType;
  int64_t          watermark;
229
  int64_t          deleteMark;
230
  int8_t           igExpired;
231
  int8_t           igCheckUpdate;
232
  EWindowAlgorithm windowAlgo;
X
Xiaoyu Wang 已提交
233 234
} SWindowLogicNode;

X
Xiaoyu Wang 已提交
235
typedef struct SFillLogicNode {
X
Xiaoyu Wang 已提交
236 237
  SLogicNode  node;
  EFillMode   mode;
238 239
  SNodeList*  pFillExprs;
  SNodeList*  pNotFillExprs;
X
Xiaoyu Wang 已提交
240 241 242
  SNode*      pWStartTs;
  SNode*      pValues;  // SNodeListNode
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
243 244
} SFillLogicNode;

X
Xiaoyu Wang 已提交
245 246 247
typedef struct SSortLogicNode {
  SLogicNode node;
  SNodeList* pSortKeys;
248
  bool       groupSort;
X
Xiaoyu Wang 已提交
249 250
} SSortLogicNode;

251 252 253
typedef struct SPartitionLogicNode {
  SLogicNode node;
  SNodeList* pPartitionKeys;
254 255
  SNodeList* pTags;
  SNode*     pSubtable;
256 257
} SPartitionLogicNode;

258 259 260 261
typedef enum ESubplanType {
  SUBPLAN_TYPE_MERGE = 1,
  SUBPLAN_TYPE_PARTIAL,
  SUBPLAN_TYPE_SCAN,
262 263
  SUBPLAN_TYPE_MODIFY,
  SUBPLAN_TYPE_COMPUTE
264 265
} ESubplanType;

X
Xiaoyu Wang 已提交
266 267
typedef struct SSubplanId {
  uint64_t queryId;
268 269
  int32_t  groupId;
  int32_t  subplanId;
X
Xiaoyu Wang 已提交
270 271
} SSubplanId;

X
Xiaoyu Wang 已提交
272
typedef struct SLogicSubplan {
273 274 275 276 277 278
  ENodeType     type;
  SSubplanId    id;
  SNodeList*    pChildren;
  SNodeList*    pParents;
  SLogicNode*   pNode;
  ESubplanType  subplanType;
X
Xiaoyu Wang 已提交
279
  SVgroupsInfo* pVgroupList;
280 281
  int32_t       level;
  int32_t       splitFlag;
282
  int32_t       numOfComputeNodes;
X
Xiaoyu Wang 已提交
283
} SLogicSubplan;
X
Xiaoyu Wang 已提交
284 285

typedef struct SQueryLogicPlan {
286
  ENodeType  type;
X
Xiaoyu Wang 已提交
287
  SNodeList* pTopSubplans;
X
Xiaoyu Wang 已提交
288 289
} SQueryLogicPlan;

X
Xiaoyu Wang 已提交
290 291
typedef struct SSlotDescNode {
  ENodeType type;
292
  int16_t   slotId;
X
Xiaoyu Wang 已提交
293
  SDataType dataType;
294 295 296
  bool      reserve;
  bool      output;
  bool      tag;
297
  char      name[SLOT_NAME_LEN];
X
Xiaoyu Wang 已提交
298 299
} SSlotDescNode;

X
Xiaoyu Wang 已提交
300
typedef struct SDataBlockDescNode {
301 302
  ENodeType  type;
  int16_t    dataBlockId;
X
Xiaoyu Wang 已提交
303
  SNodeList* pSlots;
304 305 306
  int32_t    totalRowSize;
  int32_t    outputRowSize;
  uint8_t    precision;
X
Xiaoyu Wang 已提交
307
} SDataBlockDescNode;
X
Xiaoyu Wang 已提交
308 309

typedef struct SPhysiNode {
310
  ENodeType           type;
311 312
  EOrder              inputTsOrder;
  EOrder              outputTsOrder;
X
Xiaoyu Wang 已提交
313
  SDataBlockDescNode* pOutputDataBlockDesc;
314 315 316
  SNode*              pConditions;
  SNodeList*          pChildren;
  struct SPhysiNode*  pParent;
317 318
  SNode*              pLimit;
  SNode*              pSlimit;
X
Xiaoyu Wang 已提交
319 320 321
} SPhysiNode;

typedef struct SScanPhysiNode {
X
Xiaoyu Wang 已提交
322
  SPhysiNode node;
X
Xiaoyu Wang 已提交
323
  SNodeList* pScanCols;
324 325
  SNodeList* pScanPseudoCols;
  uint64_t   uid;  // unique id of the table
X
Xiaoyu Wang 已提交
326
  uint64_t   suid;
327 328
  int8_t     tableType;
  SName      tableName;
X
Xiaoyu Wang 已提交
329 330 331
} SScanPhysiNode;

typedef SScanPhysiNode STagScanPhysiNode;
332
typedef SScanPhysiNode SBlockDistScanPhysiNode;
X
Xiaoyu Wang 已提交
333 334 335 336 337

typedef struct SLastRowScanPhysiNode {
  SScanPhysiNode scan;
  SNodeList*     pGroupTags;
  bool           groupSort;
X
Xiaoyu Wang 已提交
338
  bool           ignoreNull;
X
Xiaoyu Wang 已提交
339
} SLastRowScanPhysiNode;
X
Xiaoyu Wang 已提交
340

X
Xiaoyu Wang 已提交
341 342
typedef SLastRowScanPhysiNode STableCountScanPhysiNode;

X
Xiaoyu Wang 已提交
343 344
typedef struct SSystemTableScanPhysiNode {
  SScanPhysiNode scan;
345 346 347
  SEpSet         mgmtEpSet;
  bool           showRewrite;
  int32_t        accountId;
348
  bool           sysInfo;
X
Xiaoyu Wang 已提交
349 350
} SSystemTableScanPhysiNode;

X
Xiaoyu Wang 已提交
351 352
typedef struct STableScanPhysiNode {
  SScanPhysiNode scan;
353 354 355 356 357
  uint8_t        scanSeq[2];  // first is scan count, and second is reverse scan count
  STimeWindow    scanRange;
  double         ratio;
  int32_t        dataRequired;
  SNodeList*     pDynamicScanFuncs;
358 359
  SNodeList*     pGroupTags;
  bool           groupSort;
360 361
  SNodeList*     pTags;
  SNode*         pSubtable;
362 363 364 365 366
  int64_t        interval;
  int64_t        offset;
  int64_t        sliding;
  int8_t         intervalUnit;
  int8_t         slidingUnit;
5
54liuyao 已提交
367 368
  int8_t         triggerType;
  int64_t        watermark;
369
  int8_t         igExpired;
X
Xiaoyu Wang 已提交
370
  bool           assignBlockUid;
5
54liuyao 已提交
371
  int8_t         igCheckUpdate;
X
Xiaoyu Wang 已提交
372 373 374
} STableScanPhysiNode;

typedef STableScanPhysiNode STableSeqScanPhysiNode;
X
Xiaoyu Wang 已提交
375
typedef STableScanPhysiNode STableMergeScanPhysiNode;
5
54liuyao 已提交
376
typedef STableScanPhysiNode SStreamScanPhysiNode;
X
Xiaoyu Wang 已提交
377 378 379 380

typedef struct SProjectPhysiNode {
  SPhysiNode node;
  SNodeList* pProjections;
381
  bool       mergeDataBlock;
382
  bool       ignoreGroupId;
X
Xiaoyu Wang 已提交
383 384
} SProjectPhysiNode;

385 386 387
typedef struct SIndefRowsFuncPhysiNode {
  SPhysiNode node;
  SNodeList* pExprs;
X
Xiaoyu Wang 已提交
388
  SNodeList* pFuncs;
389 390
} SIndefRowsFuncPhysiNode;

X
Xiaoyu Wang 已提交
391 392 393 394 395 396
typedef struct SInterpFuncPhysiNode {
  SPhysiNode  node;
  SNodeList*  pExprs;
  SNodeList*  pFuncs;
  STimeWindow timeRange;
  int64_t     interval;
D
dapan1121 已提交
397
  int8_t      intervalUnit;
X
Xiaoyu Wang 已提交
398 399 400
  EFillMode   fillMode;
  SNode*      pFillValues;  // SNodeListNode
  SNode*      pTimeSeries;  // SColumnNode
X
Xiaoyu Wang 已提交
401 402
} SInterpFuncPhysiNode;

403
typedef struct SSortMergeJoinPhysiNode {
X
Xiaoyu Wang 已提交
404
  SPhysiNode node;
405
  EJoinType  joinType;
406
  SNode*     pMergeCondition;
X
Xiaoyu Wang 已提交
407
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
408
  SNodeList* pTargets;
S
slzhou 已提交
409
  SNode*     pColEqualOnConditions;
410
} SSortMergeJoinPhysiNode;
X
Xiaoyu Wang 已提交
411

X
Xiaoyu Wang 已提交
412 413
typedef struct SAggPhysiNode {
  SPhysiNode node;
414
  SNodeList* pExprs;  // these are expression list of group_by_clause and parameter expression of aggregate function
X
Xiaoyu Wang 已提交
415
  SNodeList* pGroupKeys;
X
Xiaoyu Wang 已提交
416
  SNodeList* pAggFuncs;
417
  bool       mergeDataBlock;
418
  bool       groupKeyOptimized;
X
Xiaoyu Wang 已提交
419 420
} SAggPhysiNode;

X
Xiaoyu Wang 已提交
421
typedef struct SDownstreamSourceNode {
422
  ENodeType      type;
X
Xiaoyu Wang 已提交
423
  SQueryNodeAddr addr;
424 425
  uint64_t       taskId;
  uint64_t       schedId;
D
dapan1121 已提交
426
  int32_t        execId;
D
dapan1121 已提交
427
  int32_t        fetchMsgType;
D
dapan1121 已提交
428
  bool           localExec;
X
Xiaoyu Wang 已提交
429
} SDownstreamSourceNode;
X
Xiaoyu Wang 已提交
430 431

typedef struct SExchangePhysiNode {
X
Xiaoyu Wang 已提交
432
  SPhysiNode node;
433 434 435 436
  // 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 已提交
437
  bool       singleChannel;
X
Xiaoyu Wang 已提交
438
  SNodeList* pSrcEndPoints;  // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
X
Xiaoyu Wang 已提交
439
  bool       seqRecvData;
X
Xiaoyu Wang 已提交
440 441
} SExchangePhysiNode;

X
Xiaoyu Wang 已提交
442 443 444
typedef struct SMergePhysiNode {
  SPhysiNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
445
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
446 447
  int32_t    numOfChannels;
  int32_t    srcGroupId;
448
  bool       groupSort;
D
dapan1121 已提交
449
  bool       ignoreGroupId;
X
Xiaoyu Wang 已提交
450 451
} SMergePhysiNode;

452
typedef struct SWindowPhysiNode {
X
Xiaoyu Wang 已提交
453
  SPhysiNode node;
454
  SNodeList* pExprs;  // these are expression list of parameter expression of function
X
Xiaoyu Wang 已提交
455
  SNodeList* pFuncs;
X
Xiaoyu Wang 已提交
456 457
  SNode*     pTspk;   // timestamp primary key
  SNode*     pTsEnd;  // window end timestamp
458 459
  int8_t     triggerType;
  int64_t    watermark;
460
  int64_t    deleteMark;
461
  int8_t     igExpired;
462
  bool       mergeDataBlock;
463
} SWindowPhysiNode;
X
Xiaoyu Wang 已提交
464 465

typedef struct SIntervalPhysiNode {
466
  SWindowPhysiNode window;
467 468 469 470 471
  int64_t          interval;
  int64_t          offset;
  int64_t          sliding;
  int8_t           intervalUnit;
  int8_t           slidingUnit;
X
Xiaoyu Wang 已提交
472 473
} SIntervalPhysiNode;

474
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
475
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
X
Xiaoyu Wang 已提交
476
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
477 478
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode;
X
Xiaoyu Wang 已提交
479

X
Xiaoyu Wang 已提交
480
typedef struct SFillPhysiNode {
X
Xiaoyu Wang 已提交
481 482
  SPhysiNode  node;
  EFillMode   mode;
483 484
  SNodeList*  pFillExprs;
  SNodeList*  pNotFillExprs;
X
Xiaoyu Wang 已提交
485 486 487
  SNode*      pWStartTs;  // SColumnNode
  SNode*      pValues;    // SNodeListNode
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
488 489
} SFillPhysiNode;

5
54liuyao 已提交
490 491
typedef SFillPhysiNode SStreamFillPhysiNode;

492 493
typedef struct SMultiTableIntervalPhysiNode {
  SIntervalPhysiNode interval;
494
  SNodeList*         pPartitionKeys;
495 496
} SMultiTableIntervalPhysiNode;

X
Xiaoyu Wang 已提交
497
typedef struct SSessionWinodwPhysiNode {
498
  SWindowPhysiNode window;
499
  int64_t          gap;
X
Xiaoyu Wang 已提交
500 501
} SSessionWinodwPhysiNode;

5
54liuyao 已提交
502
typedef SSessionWinodwPhysiNode SStreamSessionWinodwPhysiNode;
503 504
typedef SSessionWinodwPhysiNode SStreamSemiSessionWinodwPhysiNode;
typedef SSessionWinodwPhysiNode SStreamFinalSessionWinodwPhysiNode;
5
54liuyao 已提交
505

506
typedef struct SStateWinodwPhysiNode {
507
  SWindowPhysiNode window;
508
  SNode*           pStateKey;
509 510
} SStateWinodwPhysiNode;

5
54liuyao 已提交
511 512
typedef SStateWinodwPhysiNode SStreamStateWinodwPhysiNode;

X
Xiaoyu Wang 已提交
513
typedef struct SEventWinodwPhysiNode {
514
  SWindowPhysiNode window;
X
Xiaoyu Wang 已提交
515 516 517 518
  SNode*           pStartCond;
  SNode*           pEndCond;
} SEventWinodwPhysiNode;

X
Xiaoyu Wang 已提交
519 520
typedef SEventWinodwPhysiNode SStreamEventWinodwPhysiNode;

X
Xiaoyu Wang 已提交
521 522
typedef struct SSortPhysiNode {
  SPhysiNode node;
523 524
  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 已提交
525
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
526 527
} SSortPhysiNode;

S
shenglian zhou 已提交
528 529
typedef SSortPhysiNode SGroupSortPhysiNode;

530 531
typedef struct SPartitionPhysiNode {
  SPhysiNode node;
532
  SNodeList* pExprs;  // these are expression list of partition_by_clause
533
  SNodeList* pPartitionKeys;
X
Xiaoyu Wang 已提交
534
  SNodeList* pTargets;
535 536
} SPartitionPhysiNode;

537 538 539 540 541
typedef struct SStreamPartitionPhysiNode {
  SPartitionPhysiNode part;
  SNodeList*          pTags;
  SNode*              pSubtable;
} SStreamPartitionPhysiNode;
542

X
Xiaoyu Wang 已提交
543
typedef struct SDataSinkNode {
544
  ENodeType           type;
X
Xiaoyu Wang 已提交
545
  SDataBlockDescNode* pInputDataBlockDesc;
X
Xiaoyu Wang 已提交
546 547 548 549 550 551 552 553
} SDataSinkNode;

typedef struct SDataDispatcherNode {
  SDataSinkNode sink;
} SDataDispatcherNode;

typedef struct SDataInserterNode {
  SDataSinkNode sink;
554 555
  int32_t       numOfTables;
  uint32_t      size;
X
Xiaoyu Wang 已提交
556
  void*         pData;
X
Xiaoyu Wang 已提交
557 558
} SDataInserterNode;

559 560
typedef struct SQueryInserterNode {
  SDataSinkNode sink;
561
  SNodeList*    pCols;
562
  uint64_t      tableId;
563
  uint64_t      stableId;
564
  int8_t        tableType;  // table type
565
  char          tableName[TSDB_TABLE_NAME_LEN];
566 567
  int32_t       vgId;
  SEpSet        epSet;
X
Xiaoyu Wang 已提交
568
  bool          explain;
569 570
} SQueryInserterNode;

X
Xiaoyu Wang 已提交
571 572 573 574
typedef struct SDataDeleterNode {
  SDataSinkNode sink;
  uint64_t      tableId;
  int8_t        tableType;  // table type
575
  char          tableFName[TSDB_TABLE_NAME_LEN];
wmmhello's avatar
wmmhello 已提交
576
  char          tsColName[TSDB_COL_NAME_LEN];
X
Xiaoyu Wang 已提交
577
  STimeWindow   deleteTimeRange;
X
Xiaoyu Wang 已提交
578
  SNode*        pAffectedRows;
579 580
  SNode*        pStartTs;
  SNode*        pEndTs;
X
Xiaoyu Wang 已提交
581 582
} SDataDeleterNode;

X
Xiaoyu Wang 已提交
583
typedef struct SSubplan {
584 585 586 587 588 589
  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 已提交
590
  char           user[TSDB_USER_LEN];
591 592 593 594 595 596
  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 已提交
597
  SNode*         pTagCond;
X
Xiaoyu Wang 已提交
598
  SNode*         pTagIndexCond;
599
  bool           showRewrite;
X
Xiaoyu Wang 已提交
600 601
} SSubplan;

602
typedef enum EExplainMode { EXPLAIN_MODE_DISABLE = 1, EXPLAIN_MODE_STATIC, EXPLAIN_MODE_ANALYZE } EExplainMode;
603 604 605

typedef struct SExplainInfo {
  EExplainMode mode;
606 607
  bool         verbose;
  double       ratio;
608
} SExplainInfo;
609

X
Xiaoyu Wang 已提交
610
typedef struct SQueryPlan {
611 612 613 614
  ENodeType    type;
  uint64_t     queryId;
  int32_t      numOfSubplans;
  SNodeList*   pSubplans;  // Element is SNodeListNode. The execution level of subplan, starting from 0.
615
  SExplainInfo explainInfo;
616
  void*        pPostPlan;
X
Xiaoyu Wang 已提交
617 618
} SQueryPlan;

H
Haojun Liao 已提交
619 620
const char* dataOrderStr(EDataOrderLevel order);

X
Xiaoyu Wang 已提交
621 622 623 624 625
#ifdef __cplusplus
}
#endif

#endif /*_TD_PLANN_NODES_H_*/