plannodes.h 17.0 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
  SCAN_TYPE_BLOCK_INFO,
65 66
  SCAN_TYPE_LAST_ROW,
  SCAN_TYPE_TABLE_COUNT
X
Xiaoyu Wang 已提交
67
} EScanType;
X
Xiaoyu Wang 已提交
68

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

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

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

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

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

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

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

X
Xiaoyu Wang 已提交
173 174
typedef struct SExchangeLogicNode {
  SLogicNode node;
175 176
  int32_t    srcStartGroupId;
  int32_t    srcEndGroupId;
X
Xiaoyu Wang 已提交
177
  bool       seqRecvData;
X
Xiaoyu Wang 已提交
178 179
} SExchangeLogicNode;

X
Xiaoyu Wang 已提交
180 181 182
typedef struct SMergeLogicNode {
  SLogicNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
183
  SNodeList* pInputs;
X
Xiaoyu Wang 已提交
184 185
  int32_t    numOfChannels;
  int32_t    srcGroupId;
186
  bool       groupSort;
X
Xiaoyu Wang 已提交
187 188
} SMergeLogicNode;

X
Xiaoyu Wang 已提交
189 190 191 192 193 194
typedef enum EWindowType {
  WINDOW_TYPE_INTERVAL = 1,
  WINDOW_TYPE_SESSION,
  WINDOW_TYPE_STATE,
  WINDOW_TYPE_EVENT
} EWindowType;
X
Xiaoyu Wang 已提交
195

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

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

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

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

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

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

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

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

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

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

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

typedef struct SPhysiNode {
308
  ENodeType           type;
X
Xiaoyu Wang 已提交
309
  SDataBlockDescNode* pOutputDataBlockDesc;
310 311 312
  SNode*              pConditions;
  SNodeList*          pChildren;
  struct SPhysiNode*  pParent;
313 314
  SNode*              pLimit;
  SNode*              pSlimit;
X
Xiaoyu Wang 已提交
315 316 317
} SPhysiNode;

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

typedef SScanPhysiNode STagScanPhysiNode;
328
typedef SScanPhysiNode SBlockDistScanPhysiNode;
X
Xiaoyu Wang 已提交
329 330 331 332 333

typedef struct SLastRowScanPhysiNode {
  SScanPhysiNode scan;
  SNodeList*     pGroupTags;
  bool           groupSort;
X
Xiaoyu Wang 已提交
334
  bool           ignoreNull;
X
Xiaoyu Wang 已提交
335
} SLastRowScanPhysiNode;
X
Xiaoyu Wang 已提交
336

X
Xiaoyu Wang 已提交
337 338
typedef SLastRowScanPhysiNode STableCountScanPhysiNode;

X
Xiaoyu Wang 已提交
339 340
typedef struct SSystemTableScanPhysiNode {
  SScanPhysiNode scan;
341 342 343
  SEpSet         mgmtEpSet;
  bool           showRewrite;
  int32_t        accountId;
344
  bool           sysInfo;
X
Xiaoyu Wang 已提交
345 346
} SSystemTableScanPhysiNode;

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

typedef STableScanPhysiNode STableSeqScanPhysiNode;
X
Xiaoyu Wang 已提交
370
typedef STableScanPhysiNode STableMergeScanPhysiNode;
5
54liuyao 已提交
371
typedef STableScanPhysiNode SStreamScanPhysiNode;
X
Xiaoyu Wang 已提交
372 373 374 375

typedef struct SProjectPhysiNode {
  SPhysiNode node;
  SNodeList* pProjections;
376
  bool       mergeDataBlock;
377
  bool       ignoreGroupId;
X
Xiaoyu Wang 已提交
378 379
} SProjectPhysiNode;

380 381 382
typedef struct SIndefRowsFuncPhysiNode {
  SPhysiNode node;
  SNodeList* pExprs;
X
Xiaoyu Wang 已提交
383
  SNodeList* pFuncs;
384 385
} SIndefRowsFuncPhysiNode;

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

398
typedef struct SSortMergeJoinPhysiNode {
X
Xiaoyu Wang 已提交
399
  SPhysiNode node;
400
  EJoinType  joinType;
401
  SNode*     pMergeCondition;
X
Xiaoyu Wang 已提交
402
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
403
  SNodeList* pTargets;
404 405
  EOrder     inputTsOrder;
} SSortMergeJoinPhysiNode;
X
Xiaoyu Wang 已提交
406

X
Xiaoyu Wang 已提交
407 408
typedef struct SAggPhysiNode {
  SPhysiNode node;
409
  SNodeList* pExprs;  // these are expression list of group_by_clause and parameter expression of aggregate function
X
Xiaoyu Wang 已提交
410
  SNodeList* pGroupKeys;
X
Xiaoyu Wang 已提交
411
  SNodeList* pAggFuncs;
412
  bool       mergeDataBlock;
413
  bool       groupKeyOptimized;
X
Xiaoyu Wang 已提交
414 415
} SAggPhysiNode;

X
Xiaoyu Wang 已提交
416
typedef struct SDownstreamSourceNode {
417
  ENodeType      type;
X
Xiaoyu Wang 已提交
418
  SQueryNodeAddr addr;
419 420
  uint64_t       taskId;
  uint64_t       schedId;
D
dapan1121 已提交
421
  int32_t        execId;
D
dapan1121 已提交
422
  int32_t        fetchMsgType;
D
dapan1121 已提交
423
  bool           localExec;
X
Xiaoyu Wang 已提交
424
} SDownstreamSourceNode;
X
Xiaoyu Wang 已提交
425 426

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

X
Xiaoyu Wang 已提交
437 438 439
typedef struct SMergePhysiNode {
  SPhysiNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
440
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
441 442
  int32_t    numOfChannels;
  int32_t    srcGroupId;
443
  bool       groupSort;
X
Xiaoyu Wang 已提交
444 445
} SMergePhysiNode;

X
Xiaoyu Wang 已提交
446
typedef struct SWinodwPhysiNode {
X
Xiaoyu Wang 已提交
447
  SPhysiNode node;
448
  SNodeList* pExprs;  // these are expression list of parameter expression of function
X
Xiaoyu Wang 已提交
449
  SNodeList* pFuncs;
X
Xiaoyu Wang 已提交
450 451
  SNode*     pTspk;   // timestamp primary key
  SNode*     pTsEnd;  // window end timestamp
452 453
  int8_t     triggerType;
  int64_t    watermark;
454
  int64_t    deleteMark;
455
  int8_t     igExpired;
X
Xiaoyu Wang 已提交
456 457
  EOrder     inputTsOrder;
  EOrder     outputTsOrder;
458
  bool       mergeDataBlock;
X
Xiaoyu Wang 已提交
459 460 461 462
} SWinodwPhysiNode;

typedef struct SIntervalPhysiNode {
  SWinodwPhysiNode window;
463 464 465 466 467
  int64_t          interval;
  int64_t          offset;
  int64_t          sliding;
  int8_t           intervalUnit;
  int8_t           slidingUnit;
X
Xiaoyu Wang 已提交
468 469
} SIntervalPhysiNode;

470
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
471
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
X
Xiaoyu Wang 已提交
472
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
473 474
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode;
X
Xiaoyu Wang 已提交
475

X
Xiaoyu Wang 已提交
476
typedef struct SFillPhysiNode {
X
Xiaoyu Wang 已提交
477 478
  SPhysiNode  node;
  EFillMode   mode;
479 480
  SNodeList*  pFillExprs;
  SNodeList*  pNotFillExprs;
X
Xiaoyu Wang 已提交
481 482 483
  SNode*      pWStartTs;  // SColumnNode
  SNode*      pValues;    // SNodeListNode
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
484
  EOrder      inputTsOrder;
X
Xiaoyu Wang 已提交
485 486
} SFillPhysiNode;

5
54liuyao 已提交
487 488
typedef SFillPhysiNode SStreamFillPhysiNode;

489 490
typedef struct SMultiTableIntervalPhysiNode {
  SIntervalPhysiNode interval;
491
  SNodeList*         pPartitionKeys;
492 493
} SMultiTableIntervalPhysiNode;

X
Xiaoyu Wang 已提交
494 495
typedef struct SSessionWinodwPhysiNode {
  SWinodwPhysiNode window;
496
  int64_t          gap;
X
Xiaoyu Wang 已提交
497 498
} SSessionWinodwPhysiNode;

5
54liuyao 已提交
499
typedef SSessionWinodwPhysiNode SStreamSessionWinodwPhysiNode;
500 501
typedef SSessionWinodwPhysiNode SStreamSemiSessionWinodwPhysiNode;
typedef SSessionWinodwPhysiNode SStreamFinalSessionWinodwPhysiNode;
5
54liuyao 已提交
502

503 504
typedef struct SStateWinodwPhysiNode {
  SWinodwPhysiNode window;
505
  SNode*           pStateKey;
506 507
} SStateWinodwPhysiNode;

5
54liuyao 已提交
508 509
typedef SStateWinodwPhysiNode SStreamStateWinodwPhysiNode;

X
Xiaoyu Wang 已提交
510 511 512 513 514 515
typedef struct SEventWinodwPhysiNode {
  SWinodwPhysiNode window;
  SNode*           pStartCond;
  SNode*           pEndCond;
} SEventWinodwPhysiNode;

X
Xiaoyu Wang 已提交
516 517
typedef SEventWinodwPhysiNode SStreamEventWinodwPhysiNode;

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

S
shenglian zhou 已提交
525 526
typedef SSortPhysiNode SGroupSortPhysiNode;

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

534 535 536 537 538
typedef struct SStreamPartitionPhysiNode {
  SPartitionPhysiNode part;
  SNodeList*          pTags;
  SNode*              pSubtable;
} SStreamPartitionPhysiNode;
539

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

typedef struct SDataDispatcherNode {
  SDataSinkNode sink;
} SDataDispatcherNode;

typedef struct SDataInserterNode {
  SDataSinkNode sink;
551 552
  int32_t       numOfTables;
  uint32_t      size;
X
Xiaoyu Wang 已提交
553
  void*         pData;
X
Xiaoyu Wang 已提交
554 555
} SDataInserterNode;

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

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

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

599
typedef enum EExplainMode { EXPLAIN_MODE_DISABLE = 1, EXPLAIN_MODE_STATIC, EXPLAIN_MODE_ANALYZE } EExplainMode;
600 601 602

typedef struct SExplainInfo {
  EExplainMode mode;
603 604
  bool         verbose;
  double       ratio;
605
} SExplainInfo;
606

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

H
Haojun Liao 已提交
615 616
const char* dataOrderStr(EDataOrderLevel order);

X
Xiaoyu Wang 已提交
617 618 619 620 621
#ifdef __cplusplus
}
#endif

#endif /*_TD_PLANN_NODES_H_*/