plannodes.h 17.4 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;
58
  bool               forceCreateNonBlockingOptr;  // true if the operator can use non-blocking(pipeline) mode
X
Xiaoyu Wang 已提交
59 60
} SLogicNode;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

typedef SScanPhysiNode STagScanPhysiNode;
336
typedef SScanPhysiNode SBlockDistScanPhysiNode;
X
Xiaoyu Wang 已提交
337 338 339 340 341

typedef struct SLastRowScanPhysiNode {
  SScanPhysiNode scan;
  SNodeList*     pGroupTags;
  bool           groupSort;
X
Xiaoyu Wang 已提交
342
  bool           ignoreNull;
X
Xiaoyu Wang 已提交
343
} SLastRowScanPhysiNode;
X
Xiaoyu Wang 已提交
344

X
Xiaoyu Wang 已提交
345 346
typedef SLastRowScanPhysiNode STableCountScanPhysiNode;

X
Xiaoyu Wang 已提交
347 348
typedef struct SSystemTableScanPhysiNode {
  SScanPhysiNode scan;
349 350 351
  SEpSet         mgmtEpSet;
  bool           showRewrite;
  int32_t        accountId;
352
  bool           sysInfo;
X
Xiaoyu Wang 已提交
353 354
} SSystemTableScanPhysiNode;

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

typedef STableScanPhysiNode STableSeqScanPhysiNode;
X
Xiaoyu Wang 已提交
379
typedef STableScanPhysiNode STableMergeScanPhysiNode;
5
54liuyao 已提交
380
typedef STableScanPhysiNode SStreamScanPhysiNode;
X
Xiaoyu Wang 已提交
381 382 383 384

typedef struct SProjectPhysiNode {
  SPhysiNode node;
  SNodeList* pProjections;
385
  bool       mergeDataBlock;
386
  bool       ignoreGroupId;
X
Xiaoyu Wang 已提交
387 388
} SProjectPhysiNode;

389 390 391
typedef struct SIndefRowsFuncPhysiNode {
  SPhysiNode node;
  SNodeList* pExprs;
X
Xiaoyu Wang 已提交
392
  SNodeList* pFuncs;
393 394
} SIndefRowsFuncPhysiNode;

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

407
typedef struct SSortMergeJoinPhysiNode {
X
Xiaoyu Wang 已提交
408
  SPhysiNode node;
409
  EJoinType  joinType;
410
  SNode*     pMergeCondition;
X
Xiaoyu Wang 已提交
411
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
412
  SNodeList* pTargets;
S
slzhou 已提交
413
  SNode*     pColEqualOnConditions;
414
} SSortMergeJoinPhysiNode;
X
Xiaoyu Wang 已提交
415

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

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

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

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

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

typedef struct SIntervalPhysiNode {
470
  SWindowPhysiNode window;
471 472 473 474 475
  int64_t          interval;
  int64_t          offset;
  int64_t          sliding;
  int8_t           intervalUnit;
  int8_t           slidingUnit;
X
Xiaoyu Wang 已提交
476 477
} SIntervalPhysiNode;

478
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
479
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
X
Xiaoyu Wang 已提交
480
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
481 482
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode;
X
Xiaoyu Wang 已提交
483

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

5
54liuyao 已提交
494 495
typedef SFillPhysiNode SStreamFillPhysiNode;

496 497
typedef struct SMultiTableIntervalPhysiNode {
  SIntervalPhysiNode interval;
498
  SNodeList*         pPartitionKeys;
499 500
} SMultiTableIntervalPhysiNode;

X
Xiaoyu Wang 已提交
501
typedef struct SSessionWinodwPhysiNode {
502
  SWindowPhysiNode window;
503
  int64_t          gap;
X
Xiaoyu Wang 已提交
504 505
} SSessionWinodwPhysiNode;

5
54liuyao 已提交
506
typedef SSessionWinodwPhysiNode SStreamSessionWinodwPhysiNode;
507 508
typedef SSessionWinodwPhysiNode SStreamSemiSessionWinodwPhysiNode;
typedef SSessionWinodwPhysiNode SStreamFinalSessionWinodwPhysiNode;
5
54liuyao 已提交
509

510
typedef struct SStateWinodwPhysiNode {
511
  SWindowPhysiNode window;
512
  SNode*           pStateKey;
513 514
} SStateWinodwPhysiNode;

5
54liuyao 已提交
515 516
typedef SStateWinodwPhysiNode SStreamStateWinodwPhysiNode;

X
Xiaoyu Wang 已提交
517
typedef struct SEventWinodwPhysiNode {
518
  SWindowPhysiNode window;
X
Xiaoyu Wang 已提交
519 520 521 522
  SNode*           pStartCond;
  SNode*           pEndCond;
} SEventWinodwPhysiNode;

X
Xiaoyu Wang 已提交
523 524
typedef SEventWinodwPhysiNode SStreamEventWinodwPhysiNode;

X
Xiaoyu Wang 已提交
525 526
typedef struct SSortPhysiNode {
  SPhysiNode node;
527 528
  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 已提交
529
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
530 531
} SSortPhysiNode;

S
shenglian zhou 已提交
532 533
typedef SSortPhysiNode SGroupSortPhysiNode;

534 535
typedef struct SPartitionPhysiNode {
  SPhysiNode node;
536
  SNodeList* pExprs;  // these are expression list of partition_by_clause
537
  SNodeList* pPartitionKeys;
X
Xiaoyu Wang 已提交
538
  SNodeList* pTargets;
539 540
} SPartitionPhysiNode;

541 542 543 544 545
typedef struct SStreamPartitionPhysiNode {
  SPartitionPhysiNode part;
  SNodeList*          pTags;
  SNode*              pSubtable;
} SStreamPartitionPhysiNode;
546

X
Xiaoyu Wang 已提交
547
typedef struct SDataSinkNode {
548
  ENodeType           type;
X
Xiaoyu Wang 已提交
549
  SDataBlockDescNode* pInputDataBlockDesc;
X
Xiaoyu Wang 已提交
550 551 552 553 554 555 556 557
} SDataSinkNode;

typedef struct SDataDispatcherNode {
  SDataSinkNode sink;
} SDataDispatcherNode;

typedef struct SDataInserterNode {
  SDataSinkNode sink;
558 559
  int32_t       numOfTables;
  uint32_t      size;
X
Xiaoyu Wang 已提交
560
  void*         pData;
X
Xiaoyu Wang 已提交
561 562
} SDataInserterNode;

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

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

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

606
typedef enum EExplainMode { EXPLAIN_MODE_DISABLE = 1, EXPLAIN_MODE_STATIC, EXPLAIN_MODE_ANALYZE } EExplainMode;
607 608 609

typedef struct SExplainInfo {
  EExplainMode mode;
610 611
  bool         verbose;
  double       ratio;
612
} SExplainInfo;
613

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

H
Haojun Liao 已提交
623 624
const char* dataOrderStr(EDataOrderLevel order);

X
Xiaoyu Wang 已提交
625 626 627 628 629
#ifdef __cplusplus
}
#endif

#endif /*_TD_PLANN_NODES_H_*/