plannodes.h 16.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;
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
  bool          igLastNull;
X
Xiaoyu Wang 已提交
103 104 105 106
} SScanLogicNode;

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

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

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

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

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

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

X
Xiaoyu Wang 已提交
170 171
typedef struct SExchangeLogicNode {
  SLogicNode node;
172 173
  int32_t    srcStartGroupId;
  int32_t    srcEndGroupId;
X
Xiaoyu Wang 已提交
174
  bool       seqRecvData;
X
Xiaoyu Wang 已提交
175 176
} SExchangeLogicNode;

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

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

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

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

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

X
Xiaoyu Wang 已提交
232 233 234
typedef struct SSortLogicNode {
  SLogicNode node;
  SNodeList* pSortKeys;
235
  bool       groupSort;
X
Xiaoyu Wang 已提交
236 237
} SSortLogicNode;

238 239 240
typedef struct SPartitionLogicNode {
  SLogicNode node;
  SNodeList* pPartitionKeys;
241 242
  SNodeList* pTags;
  SNode*     pSubtable;
243 244
} SPartitionLogicNode;

245 246 247 248
typedef enum ESubplanType {
  SUBPLAN_TYPE_MERGE = 1,
  SUBPLAN_TYPE_PARTIAL,
  SUBPLAN_TYPE_SCAN,
249 250
  SUBPLAN_TYPE_MODIFY,
  SUBPLAN_TYPE_COMPUTE
251 252
} ESubplanType;

X
Xiaoyu Wang 已提交
253 254
typedef struct SSubplanId {
  uint64_t queryId;
255 256
  int32_t  groupId;
  int32_t  subplanId;
X
Xiaoyu Wang 已提交
257 258
} SSubplanId;

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

typedef struct SQueryLogicPlan {
273
  ENodeType  type;
X
Xiaoyu Wang 已提交
274
  SNodeList* pTopSubplans;
X
Xiaoyu Wang 已提交
275 276
} SQueryLogicPlan;

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

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

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

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

typedef SScanPhysiNode STagScanPhysiNode;
317
typedef SScanPhysiNode SBlockDistScanPhysiNode;
X
Xiaoyu Wang 已提交
318 319 320 321 322

typedef struct SLastRowScanPhysiNode {
  SScanPhysiNode scan;
  SNodeList*     pGroupTags;
  bool           groupSort;
X
Xiaoyu Wang 已提交
323
  bool           ignoreNull;
X
Xiaoyu Wang 已提交
324
} SLastRowScanPhysiNode;
X
Xiaoyu Wang 已提交
325

X
Xiaoyu Wang 已提交
326 327
typedef struct SSystemTableScanPhysiNode {
  SScanPhysiNode scan;
328 329 330
  SEpSet         mgmtEpSet;
  bool           showRewrite;
  int32_t        accountId;
331
  bool           sysInfo;
X
Xiaoyu Wang 已提交
332 333
} SSystemTableScanPhysiNode;

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

typedef STableScanPhysiNode STableSeqScanPhysiNode;
X
Xiaoyu Wang 已提交
357
typedef STableScanPhysiNode STableMergeScanPhysiNode;
5
54liuyao 已提交
358
typedef STableScanPhysiNode SStreamScanPhysiNode;
X
Xiaoyu Wang 已提交
359 360 361 362

typedef struct SProjectPhysiNode {
  SPhysiNode node;
  SNodeList* pProjections;
363
  bool       mergeDataBlock;
364
  bool       ignoreGroupId;
X
Xiaoyu Wang 已提交
365 366
} SProjectPhysiNode;

367 368 369
typedef struct SIndefRowsFuncPhysiNode {
  SPhysiNode node;
  SNodeList* pExprs;
X
Xiaoyu Wang 已提交
370
  SNodeList* pFuncs;
371 372
} SIndefRowsFuncPhysiNode;

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

385
typedef struct SSortMergeJoinPhysiNode {
X
Xiaoyu Wang 已提交
386
  SPhysiNode node;
387
  EJoinType  joinType;
388
  SNode*     pMergeCondition;
X
Xiaoyu Wang 已提交
389
  SNode*     pOnConditions;
X
Xiaoyu Wang 已提交
390
  SNodeList* pTargets;
391 392
  EOrder     inputTsOrder;
} SSortMergeJoinPhysiNode;
X
Xiaoyu Wang 已提交
393

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

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

typedef struct SExchangePhysiNode {
X
Xiaoyu Wang 已提交
413
  SPhysiNode node;
414 415 416 417
  // 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 已提交
418
  bool       singleChannel;
X
Xiaoyu Wang 已提交
419
  SNodeList* pSrcEndPoints;  // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
X
Xiaoyu Wang 已提交
420
  bool       seqRecvData;
X
Xiaoyu Wang 已提交
421 422
} SExchangePhysiNode;

X
Xiaoyu Wang 已提交
423 424 425
typedef struct SMergePhysiNode {
  SPhysiNode node;
  SNodeList* pMergeKeys;
X
Xiaoyu Wang 已提交
426
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
427 428
  int32_t    numOfChannels;
  int32_t    srcGroupId;
429
  bool       groupSort;
X
Xiaoyu Wang 已提交
430 431
} SMergePhysiNode;

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

typedef struct SIntervalPhysiNode {
  SWinodwPhysiNode window;
448 449 450 451 452
  int64_t          interval;
  int64_t          offset;
  int64_t          sliding;
  int8_t           intervalUnit;
  int8_t           slidingUnit;
X
Xiaoyu Wang 已提交
453 454
} SIntervalPhysiNode;

455
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
456
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
X
Xiaoyu Wang 已提交
457
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
458 459
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode;
X
Xiaoyu Wang 已提交
460

X
Xiaoyu Wang 已提交
461
typedef struct SFillPhysiNode {
X
Xiaoyu Wang 已提交
462 463
  SPhysiNode  node;
  EFillMode   mode;
464 465
  SNodeList*  pFillExprs;
  SNodeList*  pNotFillExprs;
X
Xiaoyu Wang 已提交
466 467 468
  SNode*      pWStartTs;  // SColumnNode
  SNode*      pValues;    // SNodeListNode
  STimeWindow timeRange;
X
Xiaoyu Wang 已提交
469
  EOrder      inputTsOrder;
X
Xiaoyu Wang 已提交
470 471
} SFillPhysiNode;

5
54liuyao 已提交
472 473
typedef SFillPhysiNode SStreamFillPhysiNode;

474 475
typedef struct SMultiTableIntervalPhysiNode {
  SIntervalPhysiNode interval;
476
  SNodeList*         pPartitionKeys;
477 478
} SMultiTableIntervalPhysiNode;

X
Xiaoyu Wang 已提交
479 480
typedef struct SSessionWinodwPhysiNode {
  SWinodwPhysiNode window;
481
  int64_t          gap;
X
Xiaoyu Wang 已提交
482 483
} SSessionWinodwPhysiNode;

5
54liuyao 已提交
484
typedef SSessionWinodwPhysiNode SStreamSessionWinodwPhysiNode;
485 486
typedef SSessionWinodwPhysiNode SStreamSemiSessionWinodwPhysiNode;
typedef SSessionWinodwPhysiNode SStreamFinalSessionWinodwPhysiNode;
5
54liuyao 已提交
487

488 489
typedef struct SStateWinodwPhysiNode {
  SWinodwPhysiNode window;
490
  SNode*           pStateKey;
491 492
} SStateWinodwPhysiNode;

5
54liuyao 已提交
493 494
typedef SStateWinodwPhysiNode SStreamStateWinodwPhysiNode;

X
Xiaoyu Wang 已提交
495 496
typedef struct SSortPhysiNode {
  SPhysiNode node;
497 498
  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 已提交
499
  SNodeList* pTargets;
X
Xiaoyu Wang 已提交
500 501
} SSortPhysiNode;

S
shenglian zhou 已提交
502 503
typedef SSortPhysiNode SGroupSortPhysiNode;

504 505
typedef struct SPartitionPhysiNode {
  SPhysiNode node;
506
  SNodeList* pExprs;  // these are expression list of partition_by_clause
507
  SNodeList* pPartitionKeys;
X
Xiaoyu Wang 已提交
508
  SNodeList* pTargets;
509 510
} SPartitionPhysiNode;

511 512 513 514 515
typedef struct SStreamPartitionPhysiNode {
  SPartitionPhysiNode part;
  SNodeList*          pTags;
  SNode*              pSubtable;
} SStreamPartitionPhysiNode;
516

X
Xiaoyu Wang 已提交
517
typedef struct SDataSinkNode {
518
  ENodeType           type;
X
Xiaoyu Wang 已提交
519
  SDataBlockDescNode* pInputDataBlockDesc;
X
Xiaoyu Wang 已提交
520 521 522 523 524 525 526 527
} SDataSinkNode;

typedef struct SDataDispatcherNode {
  SDataSinkNode sink;
} SDataDispatcherNode;

typedef struct SDataInserterNode {
  SDataSinkNode sink;
528 529
  int32_t       numOfTables;
  uint32_t      size;
X
Xiaoyu Wang 已提交
530
  void*         pData;
X
Xiaoyu Wang 已提交
531 532
} SDataInserterNode;

533 534
typedef struct SQueryInserterNode {
  SDataSinkNode sink;
535
  SNodeList*    pCols;
536
  uint64_t      tableId;
537
  uint64_t      stableId;
538
  int8_t        tableType;  // table type
539
  char          tableName[TSDB_TABLE_NAME_LEN];
540 541 542 543
  int32_t       vgId;
  SEpSet        epSet;
} SQueryInserterNode;

X
Xiaoyu Wang 已提交
544 545 546 547
typedef struct SDataDeleterNode {
  SDataSinkNode sink;
  uint64_t      tableId;
  int8_t        tableType;  // table type
548
  char          tableFName[TSDB_TABLE_NAME_LEN];
wmmhello's avatar
wmmhello 已提交
549
  char          tsColName[TSDB_COL_NAME_LEN];
X
Xiaoyu Wang 已提交
550
  STimeWindow   deleteTimeRange;
X
Xiaoyu Wang 已提交
551
  SNode*        pAffectedRows;
552 553
  SNode*        pStartTs;
  SNode*        pEndTs;
X
Xiaoyu Wang 已提交
554 555
} SDataDeleterNode;

X
Xiaoyu Wang 已提交
556
typedef struct SSubplan {
557 558 559 560 561 562
  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 已提交
563
  char           user[TSDB_USER_LEN];
564 565 566 567 568 569
  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 已提交
570
  SNode*         pTagCond;
X
Xiaoyu Wang 已提交
571
  SNode*         pTagIndexCond;
572
  bool           showRewrite;
X
Xiaoyu Wang 已提交
573 574
} SSubplan;

575
typedef enum EExplainMode { EXPLAIN_MODE_DISABLE = 1, EXPLAIN_MODE_STATIC, EXPLAIN_MODE_ANALYZE } EExplainMode;
576 577 578

typedef struct SExplainInfo {
  EExplainMode mode;
579 580
  bool         verbose;
  double       ratio;
581
} SExplainInfo;
582

X
Xiaoyu Wang 已提交
583
typedef struct SQueryPlan {
584 585 586 587
  ENodeType    type;
  uint64_t     queryId;
  int32_t      numOfSubplans;
  SNodeList*   pSubplans;  // Element is SNodeListNode. The execution level of subplan, starting from 0.
588
  SExplainInfo explainInfo;
X
Xiaoyu Wang 已提交
589 590
} SQueryPlan;

H
Haojun Liao 已提交
591 592
const char* dataOrderStr(EDataOrderLevel order);

X
Xiaoyu Wang 已提交
593 594 595 596 597
#ifdef __cplusplus
}
#endif

#endif /*_TD_PLANN_NODES_H_*/