TDengine/include/libs/nodes/plannodes.h

821 lines
23 KiB
C
Raw Normal View History

2022-02-13 18:31:18 +00:00
/*
* 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
2022-02-28 09:02:43 +00:00
#include "query.h"
#include "querynodes.h"
2022-03-10 02:35:24 +00:00
#include "tname.h"
2022-02-13 18:31:18 +00:00
#define SLOT_NAME_LEN TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN
typedef enum EDataOrderLevel {
DATA_ORDER_LEVEL_NONE = 1,
DATA_ORDER_LEVEL_IN_BLOCK,
DATA_ORDER_LEVEL_IN_GROUP,
DATA_ORDER_LEVEL_GLOBAL
} EDataOrderLevel;
typedef enum EGroupAction {
GROUP_ACTION_NONE = 1,
GROUP_ACTION_SET,
GROUP_ACTION_KEEP,
GROUP_ACTION_CLEAR
} EGroupAction;
2023-11-07 01:23:06 +00:00
typedef enum EMergeType {
MERGE_TYPE_SORT = 1,
MERGE_TYPE_NON_SORT,
MERGE_TYPE_COLUMNS,
MERGE_TYPE_MAX_VALUE
} EMergeType;
2022-02-13 18:31:18 +00:00
typedef struct SLogicNode {
ENodeType type;
2023-06-28 11:39:04 +00:00
bool dynamicOp;
2023-08-16 06:28:39 +00:00
bool stmtRoot;
SNodeList* pTargets; // SColumnNode
SNode* pConditions;
SNodeList* pChildren;
2022-02-13 18:31:18 +00:00
struct SLogicNode* pParent;
2023-08-16 06:28:39 +00:00
SNodeList* pHint;
int32_t optimizedFlag;
2022-05-25 13:20:11 +00:00
uint8_t precision;
SNode* pLimit;
SNode* pSlimit;
EDataOrderLevel requireDataOrder; // requirements for input data
EDataOrderLevel resultDataOrder; // properties of the output data
EGroupAction groupAction;
EOrder inputTsOrder;
EOrder outputTsOrder;
bool forceCreateNonBlockingOptr; // true if the operator can use non-blocking(pipeline) mode
2024-03-19 08:01:14 +00:00
bool splitDone;
2022-02-13 18:31:18 +00:00
} SLogicNode;
2022-06-15 05:49:29 +00:00
typedef enum EScanType {
SCAN_TYPE_TAG = 1,
SCAN_TYPE_TABLE,
SCAN_TYPE_SYSTEM_TABLE,
SCAN_TYPE_STREAM,
SCAN_TYPE_TABLE_MERGE,
2022-06-21 11:52:26 +00:00
SCAN_TYPE_BLOCK_INFO,
SCAN_TYPE_LAST_ROW,
SCAN_TYPE_TABLE_COUNT
2022-06-15 05:49:29 +00:00
} EScanType;
2022-02-23 06:34:18 +00:00
2022-02-13 18:31:18 +00:00
typedef struct SScanLogicNode {
2022-06-05 07:48:06 +00:00
SLogicNode node;
SNodeList* pScanCols;
SNodeList* pScanPseudoCols;
int8_t tableType;
uint64_t tableId;
2022-06-06 09:51:25 +00:00
uint64_t stableId;
2022-06-05 07:48:06 +00:00
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;
2022-06-18 12:15:47 +00:00
SNode* pTagIndexCond;
2022-06-05 07:48:06 +00:00
int8_t triggerType;
int64_t watermark;
2022-12-06 08:07:11 +00:00
int64_t deleteMark;
int8_t igExpired;
int8_t igCheckUpdate;
2022-06-10 02:16:18 +00:00
SArray* pSmaIndexes;
2023-12-15 10:11:22 +00:00
SArray* pTsmas;
2024-03-06 06:50:16 +00:00
SArray* pTsmaTargetTbVgInfo;
SArray* pTsmaTargetTbInfo;
SNodeList* pGroupTags;
bool groupSort;
SNodeList* pTags; // for create stream
SNode* pSubtable; // for create stream
int8_t cacheLastMode;
bool hasNormalCols; // neither tag column nor primary key tag column
2022-07-28 11:27:37 +00:00
bool sortPrimaryKey;
2022-10-12 08:32:29 +00:00
bool igLastNull;
bool groupOrderScan;
bool onlyMetaCtbIdx; // for tag scan with no tbname
2023-12-06 01:39:38 +00:00
bool filesetDelimited; // returned blocks delimited by fileset
2023-12-25 03:54:23 +00:00
bool isCountByTag; // true if selectstmt hasCountFunc & part by tag/tbname
SArray* pFuncTypes; // for last, last_row
bool paraTablesSort; // for table merge scan
bool smallDataTsSort; // disable row id sort for table merge scan
2024-03-06 03:48:32 +00:00
bool needSplit;
2022-02-13 18:31:18 +00:00
} SScanLogicNode;
typedef struct SJoinLogicNode {
2023-06-27 11:36:51 +00:00
SLogicNode node;
EJoinType joinType;
2023-11-29 12:06:30 +00:00
EJoinSubType subType;
SNode* pWindowOffset;
SNode* pJLimit;
2023-06-27 11:36:51 +00:00
EJoinAlgorithm joinAlgo;
2024-02-29 09:52:53 +00:00
SNode* addPrimEqCond;
2023-06-27 11:36:51 +00:00
SNode* pPrimKeyEqCond;
SNode* pColEqCond;
2023-11-30 12:09:49 +00:00
SNode* pColOnCond;
2023-06-27 11:36:51 +00:00
SNode* pTagEqCond;
2023-06-28 11:39:04 +00:00
SNode* pTagOnCond;
2023-11-30 12:09:49 +00:00
SNode* pFullOnCond; // except prim eq cond
2024-02-23 09:59:45 +00:00
SNodeList* pLeftEqNodes;
SNodeList* pRightEqNodes;
2024-02-27 10:18:25 +00:00
bool allEqTags;
2023-06-27 11:36:51 +00:00
bool isSingleTableJoin;
bool hasSubQuery;
2023-08-17 05:50:26 +00:00
bool isLowLevelJoin;
2024-02-22 10:59:10 +00:00
bool seqWinGroup;
2024-02-23 09:59:45 +00:00
bool grpJoin;
2024-04-10 11:27:36 +00:00
bool hashJoinHint;
2024-04-23 01:14:42 +00:00
bool batchScanHint;
2024-04-10 11:27:36 +00:00
// FOR HASH JOIN
2024-04-12 07:44:23 +00:00
int32_t timeRangeTarget; //table onCond filter
STimeWindow timeRange; //table onCond filter
SNode* pLeftOnCond; //table onCond filter
SNode* pRightOnCond; //table onCond filter
2022-02-13 18:31:18 +00:00
} SJoinLogicNode;
typedef struct SAggLogicNode {
SLogicNode node;
SNodeList* pGroupKeys;
SNodeList* pAggFuncs;
bool hasLastRow;
2022-10-12 08:32:29 +00:00
bool hasLast;
bool hasTimeLineFunc;
2022-08-06 07:26:34 +00:00
bool onlyHasKeepOrderFunc;
bool hasGroupKeyOptimized;
bool isGroupTb;
bool isPartTb; // true if partition keys has tbname
bool hasGroup;
2024-03-22 07:25:14 +00:00
SNodeList *pTsmaSubplans;
2022-02-13 18:31:18 +00:00
} SAggLogicNode;
typedef struct SProjectLogicNode {
SLogicNode node;
SNodeList* pProjections;
char stmtName[TSDB_TABLE_NAME_LEN];
bool ignoreGroupId;
2024-01-15 03:58:29 +00:00
bool inputIgnoreGroup;
2024-05-27 08:20:13 +00:00
bool isSetOpProj;
2022-02-13 18:31:18 +00:00
} SProjectLogicNode;
typedef struct SIndefRowsFuncLogicNode {
SLogicNode node;
2022-06-19 11:39:12 +00:00
SNodeList* pFuncs;
bool isTailFunc;
bool isUniqueFunc;
2022-07-01 05:31:22 +00:00
bool isTimeLineFunc;
} SIndefRowsFuncLogicNode;
2022-06-19 11:39:12 +00:00
typedef struct SInterpFuncLogicNode {
SLogicNode node;
SNodeList* pFuncs;
STimeWindow timeRange;
int64_t interval;
2022-06-20 04:00:57 +00:00
EFillMode fillMode;
SNode* pFillValues; // SNodeListNode
SNode* pTimeSeries; // SColumnNode
2022-06-19 11:39:12 +00:00
} SInterpFuncLogicNode;
2023-06-27 11:36:51 +00:00
typedef struct SGroupCacheLogicNode {
SLogicNode node;
2023-06-30 11:20:36 +00:00
bool grpColsMayBeNull;
bool grpByUid;
bool globalGrp;
2023-07-19 02:37:30 +00:00
bool batchFetch;
2023-06-28 11:39:04 +00:00
SNodeList* pGroupCols;
2023-06-27 11:36:51 +00:00
} SGroupCacheLogicNode;
2023-07-19 02:37:30 +00:00
typedef struct SDynQueryCtrlStbJoin {
2023-07-26 11:17:59 +00:00
bool batchFetch;
2023-07-06 11:33:31 +00:00
SNodeList* pVgList;
SNodeList* pUidList;
2023-08-09 02:30:35 +00:00
bool srcScan[2];
2023-07-19 02:37:30 +00:00
} SDynQueryCtrlStbJoin;
typedef struct SDynQueryCtrlLogicNode {
SLogicNode node;
EDynQueryType qType;
SDynQueryCtrlStbJoin stbJoin;
2023-06-28 11:39:04 +00:00
} SDynQueryCtrlLogicNode;
2023-06-27 11:36:51 +00:00
2022-06-05 07:48:06 +00:00
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;
2022-06-06 10:39:23 +00:00
SNode* pAffectedRows; // SColumnNode
SNode* pStartTs; // SColumnNode
SNode* pEndTs; // SColumnNode
2022-06-05 07:48:06 +00:00
uint64_t tableId;
2022-07-06 08:16:54 +00:00
uint64_t stableId;
2022-06-05 07:48:06 +00:00
int8_t tableType; // table type
char tableName[TSDB_TABLE_NAME_LEN];
char tsColName[TSDB_COL_NAME_LEN];
2022-06-05 07:48:06 +00:00
STimeWindow deleteTimeRange;
2022-07-05 13:12:10 +00:00
SVgroupsInfo* pVgroupList;
2022-07-06 08:16:54 +00:00
SNodeList* pInsertCols;
2022-06-05 07:48:06 +00:00
} SVnodeModifyLogicNode;
2022-03-09 09:32:12 +00:00
typedef struct SExchangeLogicNode {
SLogicNode node;
int32_t srcStartGroupId;
int32_t srcEndGroupId;
2022-11-24 07:16:38 +00:00
bool seqRecvData;
2022-03-09 09:32:12 +00:00
} SExchangeLogicNode;
2022-06-02 02:45:27 +00:00
typedef struct SMergeLogicNode {
SLogicNode node;
SNodeList* pMergeKeys;
2022-06-06 09:51:25 +00:00
SNodeList* pInputs;
2022-06-02 02:45:27 +00:00
int32_t numOfChannels;
2023-12-27 06:38:02 +00:00
int32_t numOfSubplans;
2022-06-02 02:45:27 +00:00
int32_t srcGroupId;
2023-12-27 06:38:02 +00:00
int32_t srcEndGroupId;
2023-11-07 01:23:06 +00:00
bool colsMerge;
bool needSort;
bool groupSort;
2023-05-09 03:33:47 +00:00
bool ignoreGroupId;
2023-09-07 05:51:09 +00:00
bool inputWithGroupId;
2022-06-02 02:45:27 +00:00
} SMergeLogicNode;
2022-12-08 01:36:37 +00:00
typedef enum EWindowType {
WINDOW_TYPE_INTERVAL = 1,
WINDOW_TYPE_SESSION,
WINDOW_TYPE_STATE,
2024-01-17 06:22:19 +00:00
WINDOW_TYPE_EVENT,
WINDOW_TYPE_COUNT
2022-12-08 01:36:37 +00:00
} EWindowType;
2022-03-13 19:28:50 +00:00
typedef enum EWindowAlgorithm {
2022-06-05 07:48:06 +00:00
INTERVAL_ALGO_HASH = 1,
2022-06-06 09:51:25 +00:00
INTERVAL_ALGO_MERGE,
2022-06-05 07:48:06 +00:00
INTERVAL_ALGO_STREAM_FINAL,
INTERVAL_ALGO_STREAM_SEMI,
INTERVAL_ALGO_STREAM_SINGLE,
SESSION_ALGO_STREAM_SEMI,
SESSION_ALGO_STREAM_FINAL,
SESSION_ALGO_STREAM_SINGLE,
SESSION_ALGO_MERGE,
INTERVAL_ALGO_STREAM_MID,
} EWindowAlgorithm;
2022-03-11 10:11:25 +00:00
typedef struct SWindowLogicNode {
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;
2022-06-19 11:39:12 +00:00
SNode* pTsEnd;
SNode* pStateExpr;
2022-12-08 01:36:37 +00:00
SNode* pStartCond;
SNode* pEndCond;
int8_t triggerType;
int64_t watermark;
2022-12-06 08:07:11 +00:00
int64_t deleteMark;
int8_t igExpired;
int8_t igCheckUpdate;
EWindowAlgorithm windowAlgo;
bool isPartTb;
2024-01-17 06:22:19 +00:00
int64_t windowCount;
2024-01-26 07:56:26 +00:00
int64_t windowSliding;
2024-03-22 07:25:14 +00:00
SNodeList* pTsmaSubplans;
2022-03-11 10:11:25 +00:00
} SWindowLogicNode;
2022-04-30 03:40:12 +00:00
typedef struct SFillLogicNode {
2022-04-30 06:07:44 +00:00
SLogicNode node;
EFillMode mode;
SNodeList* pFillExprs;
SNodeList* pNotFillExprs;
2022-04-30 06:07:44 +00:00
SNode* pWStartTs;
SNode* pValues; // SNodeListNode
STimeWindow timeRange;
2022-04-30 03:40:12 +00:00
} SFillLogicNode;
2022-03-26 06:58:44 +00:00
typedef struct SSortLogicNode {
SLogicNode node;
SNodeList* pSortKeys;
bool groupSort;
bool skipPKSortOpt;
bool calcGroupId;
bool excludePkCol; // exclude PK ts col when calc group id
2022-03-26 06:58:44 +00:00
} SSortLogicNode;
typedef struct SPartitionLogicNode {
SLogicNode node;
SNodeList* pPartitionKeys;
SNodeList* pTags;
SNode* pSubtable;
SNodeList* pAggFuncs;
bool needBlockOutputTsOrder; // if true, partition output block will have ts order maintained
2023-09-07 05:51:09 +00:00
int32_t pkTsColId;
uint64_t pkTsColTbId;
} SPartitionLogicNode;
typedef enum ESubplanType {
SUBPLAN_TYPE_MERGE = 1,
SUBPLAN_TYPE_PARTIAL,
SUBPLAN_TYPE_SCAN,
2022-06-15 08:47:03 +00:00
SUBPLAN_TYPE_MODIFY,
SUBPLAN_TYPE_COMPUTE
} ESubplanType;
2022-03-09 09:32:12 +00:00
typedef struct SSubplanId {
uint64_t queryId;
int32_t groupId;
int32_t subplanId;
2022-03-09 09:32:12 +00:00
} SSubplanId;
2022-03-23 10:44:02 +00:00
typedef struct SLogicSubplan {
ENodeType type;
SSubplanId id;
SNodeList* pChildren;
SNodeList* pParents;
SLogicNode* pNode;
ESubplanType subplanType;
2022-03-09 09:32:12 +00:00
SVgroupsInfo* pVgroupList;
int32_t level;
int32_t splitFlag;
2022-06-15 08:47:03 +00:00
int32_t numOfComputeNodes;
2022-03-23 10:44:02 +00:00
} SLogicSubplan;
2022-03-02 02:50:51 +00:00
typedef struct SQueryLogicPlan {
ENodeType type;
2022-03-09 11:53:00 +00:00
SNodeList* pTopSubplans;
2022-03-02 02:50:51 +00:00
} SQueryLogicPlan;
2022-02-23 06:34:18 +00:00
typedef struct SSlotDescNode {
ENodeType type;
int16_t slotId;
2022-02-23 06:34:18 +00:00
SDataType dataType;
bool reserve;
bool output;
bool tag;
char name[SLOT_NAME_LEN];
2022-02-23 06:34:18 +00:00
} SSlotDescNode;
2022-02-25 08:29:40 +00:00
typedef struct SDataBlockDescNode {
ENodeType type;
int16_t dataBlockId;
2022-02-23 06:34:18 +00:00
SNodeList* pSlots;
int32_t totalRowSize;
int32_t outputRowSize;
uint8_t precision;
2022-02-25 08:29:40 +00:00
} SDataBlockDescNode;
2022-02-23 06:34:18 +00:00
typedef struct SPhysiNode {
ENodeType type;
2023-07-03 11:29:46 +00:00
bool dynamicOp;
EOrder inputTsOrder;
EOrder outputTsOrder;
2022-03-04 07:17:04 +00:00
SDataBlockDescNode* pOutputDataBlockDesc;
SNode* pConditions;
SNodeList* pChildren;
struct SPhysiNode* pParent;
SNode* pLimit;
SNode* pSlimit;
bool forceCreateNonBlockingOptr;
2022-02-23 06:34:18 +00:00
} SPhysiNode;
typedef struct SScanPhysiNode {
2022-03-19 07:02:31 +00:00
SPhysiNode node;
2022-02-23 06:34:18 +00:00
SNodeList* pScanCols;
SNodeList* pScanPseudoCols;
uint64_t uid; // unique id of the table
2022-06-06 09:51:25 +00:00
uint64_t suid;
int8_t tableType;
SName tableName;
bool groupOrderScan;
2022-02-23 06:34:18 +00:00
} SScanPhysiNode;
typedef struct STagScanPhysiNode {
SScanPhysiNode scan;
bool onlyMetaCtbIdx; //no tbname, tag index not used.
} STagScanPhysiNode;
typedef SScanPhysiNode SBlockDistScanPhysiNode;
2022-07-14 08:06:28 +00:00
typedef struct SLastRowScanPhysiNode {
SScanPhysiNode scan;
SNodeList* pGroupTags;
bool groupSort;
2022-10-12 08:32:29 +00:00
bool ignoreNull;
2023-11-09 06:23:42 +00:00
SNodeList* pTargets;
SArray* pFuncTypes;
2022-07-14 08:06:28 +00:00
} SLastRowScanPhysiNode;
2022-02-23 06:34:18 +00:00
2022-11-22 08:39:30 +00:00
typedef SLastRowScanPhysiNode STableCountScanPhysiNode;
2022-03-11 07:58:29 +00:00
typedef struct SSystemTableScanPhysiNode {
SScanPhysiNode scan;
SEpSet mgmtEpSet;
bool showRewrite;
int32_t accountId;
2022-08-24 09:36:10 +00:00
bool sysInfo;
2022-03-11 07:58:29 +00:00
} SSystemTableScanPhysiNode;
2022-02-23 06:34:18 +00:00
typedef struct STableScanPhysiNode {
SScanPhysiNode scan;
uint8_t scanSeq[2]; // first is scan count, and second is reverse scan count
STimeWindow scanRange;
double ratio;
int32_t dataRequired;
SNodeList* pDynamicScanFuncs;
SNodeList* pGroupTags;
bool groupSort;
SNodeList* pTags;
SNode* pSubtable;
int64_t interval;
int64_t offset;
int64_t sliding;
int8_t intervalUnit;
int8_t slidingUnit;
2022-05-27 08:03:43 +00:00
int8_t triggerType;
int64_t watermark;
int8_t igExpired;
2022-07-27 03:55:19 +00:00
bool assignBlockUid;
2023-02-07 07:29:05 +00:00
int8_t igCheckUpdate;
bool filesetDelimited;
2023-12-13 15:25:37 +00:00
bool needCountEmptyTable;
bool paraTablesSort;
bool smallDataTsSort;
2022-02-23 06:34:18 +00:00
} STableScanPhysiNode;
typedef STableScanPhysiNode STableSeqScanPhysiNode;
2022-06-15 05:49:29 +00:00
typedef STableScanPhysiNode STableMergeScanPhysiNode;
2022-05-10 07:34:41 +00:00
typedef STableScanPhysiNode SStreamScanPhysiNode;
2022-02-23 06:34:18 +00:00
typedef struct SProjectPhysiNode {
SPhysiNode node;
SNodeList* pProjections;
bool mergeDataBlock;
bool ignoreGroupId;
2024-01-16 00:13:47 +00:00
bool inputIgnoreGroup;
2022-02-23 06:34:18 +00:00
} SProjectPhysiNode;
typedef struct SIndefRowsFuncPhysiNode {
SPhysiNode node;
SNodeList* pExprs;
2022-06-19 11:39:12 +00:00
SNodeList* pFuncs;
} SIndefRowsFuncPhysiNode;
2022-06-19 11:39:12 +00:00
typedef struct SInterpFuncPhysiNode {
SPhysiNode node;
SNodeList* pExprs;
SNodeList* pFuncs;
STimeWindow timeRange;
int64_t interval;
2022-07-04 09:40:20 +00:00
int8_t intervalUnit;
2022-06-20 04:00:57 +00:00
EFillMode fillMode;
SNode* pFillValues; // SNodeListNode
SNode* pTimeSeries; // SColumnNode
2022-06-19 11:39:12 +00:00
} SInterpFuncPhysiNode;
typedef struct SSortMergeJoinPhysiNode {
2023-12-01 10:33:50 +00:00
SPhysiNode node;
EJoinType joinType;
EJoinSubType subType;
SNode* pWindowOffset;
SNode* pJLimit;
2024-01-12 10:29:27 +00:00
int32_t asofOpType;
SNode* leftPrimExpr;
SNode* rightPrimExpr;
2023-12-01 10:33:50 +00:00
int32_t leftPrimSlotId;
int32_t rightPrimSlotId;
SNodeList* pEqLeft;
SNodeList* pEqRight;
SNode* pPrimKeyCond; //remove
SNode* pColEqCond; //remove
SNode* pColOnCond;
SNode* pFullOnCond;
SNodeList* pTargets;
2023-12-14 06:13:01 +00:00
SQueryStat inputStat[2];
2024-02-22 10:59:10 +00:00
bool seqWinGroup;
2024-02-23 09:59:45 +00:00
bool grpJoin;
} SSortMergeJoinPhysiNode;
2022-04-30 03:40:12 +00:00
2023-06-15 11:34:15 +00:00
typedef struct SHashJoinPhysiNode {
2023-12-01 10:33:50 +00:00
SPhysiNode node;
EJoinType joinType;
EJoinSubType subType;
SNode* pWindowOffset;
SNode* pJLimit;
SNodeList* pOnLeft;
SNodeList* pOnRight;
2024-04-12 07:44:23 +00:00
SNode* leftPrimExpr;
SNode* rightPrimExpr;
int32_t leftPrimSlotId;
int32_t rightPrimSlotId;
int32_t timeRangeTarget; //table onCond filter
STimeWindow timeRange; //table onCond filter
SNode* pLeftOnCond; //table onCond filter
SNode* pRightOnCond; //table onCond filter
SNode* pFullOnCond; //preFilter
2023-12-01 10:33:50 +00:00
SNodeList* pTargets;
SQueryStat inputStat[2];
2024-04-10 11:27:36 +00:00
// only in planner internal
2023-12-01 10:33:50 +00:00
SNode* pPrimKeyCond;
SNode* pColEqCond;
SNode* pTagEqCond;
2023-06-15 11:34:15 +00:00
} SHashJoinPhysiNode;
2023-06-29 11:28:32 +00:00
typedef struct SGroupCachePhysiNode {
SPhysiNode node;
2023-06-30 11:20:36 +00:00
bool grpColsMayBeNull;
2023-07-11 11:34:03 +00:00
bool grpByUid;
bool globalGrp;
2023-07-19 02:37:30 +00:00
bool batchFetch;
2023-06-29 11:28:32 +00:00
SNodeList* pGroupCols;
} SGroupCachePhysiNode;
2023-07-05 03:07:08 +00:00
typedef struct SStbJoinDynCtrlBasic {
2023-07-26 11:17:59 +00:00
bool batchFetch;
2023-07-03 11:29:46 +00:00
int32_t vgSlot[2];
int32_t uidSlot[2];
2023-08-09 02:30:35 +00:00
bool srcScan[2];
2023-07-05 03:07:08 +00:00
} SStbJoinDynCtrlBasic;
2023-07-03 11:29:46 +00:00
2023-06-29 11:28:32 +00:00
typedef struct SDynQueryCtrlPhysiNode {
SPhysiNode node;
EDynQueryType qType;
2023-07-03 11:29:46 +00:00
union {
2023-07-05 03:07:08 +00:00
SStbJoinDynCtrlBasic stbJoin;
2023-07-03 11:29:46 +00:00
};
2023-06-29 11:28:32 +00:00
} SDynQueryCtrlPhysiNode;
2022-02-24 10:18:41 +00:00
typedef struct SAggPhysiNode {
SPhysiNode node;
SNodeList* pExprs; // these are expression list of group_by_clause and parameter expression of aggregate function
2022-03-26 06:58:44 +00:00
SNodeList* pGroupKeys;
2022-02-24 10:18:41 +00:00
SNodeList* pAggFuncs;
bool mergeDataBlock;
bool groupKeyOptimized;
2024-03-11 11:29:08 +00:00
bool hasCountLikeFunc;
2022-02-24 10:18:41 +00:00
} SAggPhysiNode;
2022-03-09 09:32:12 +00:00
typedef struct SDownstreamSourceNode {
ENodeType type;
2022-02-28 09:02:43 +00:00
SQueryNodeAddr addr;
uint64_t taskId;
uint64_t schedId;
2022-06-30 03:04:49 +00:00
int32_t execId;
2022-07-06 12:33:23 +00:00
int32_t fetchMsgType;
2022-09-09 11:03:42 +00:00
bool localExec;
2022-03-09 09:32:12 +00:00
} SDownstreamSourceNode;
2022-02-28 09:02:43 +00:00
typedef struct SExchangePhysiNode {
2022-03-09 09:32:12 +00:00
SPhysiNode node;
// 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;
2022-06-09 07:17:10 +00:00
bool singleChannel;
2022-03-09 09:32:12 +00:00
SNodeList* pSrcEndPoints; // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
2022-11-24 07:16:38 +00:00
bool seqRecvData;
2022-02-28 09:02:43 +00:00
} SExchangePhysiNode;
2022-06-02 02:45:27 +00:00
typedef struct SMergePhysiNode {
SPhysiNode node;
2023-11-07 01:23:06 +00:00
EMergeType type;
2022-06-02 02:45:27 +00:00
SNodeList* pMergeKeys;
2022-06-06 09:51:25 +00:00
SNodeList* pTargets;
2022-06-02 02:45:27 +00:00
int32_t numOfChannels;
2023-12-27 06:38:02 +00:00
int32_t numOfSubplans;
2022-06-02 02:45:27 +00:00
int32_t srcGroupId;
2023-12-27 06:38:02 +00:00
int32_t srcEndGroupId;
bool groupSort;
2023-05-09 03:33:47 +00:00
bool ignoreGroupId;
2023-09-07 05:51:09 +00:00
bool inputWithGroupId;
2022-06-02 02:45:27 +00:00
} SMergePhysiNode;
typedef struct SWindowPhysiNode {
2022-03-11 10:11:25 +00:00
SPhysiNode node;
SNodeList* pExprs; // these are expression list of parameter expression of function
2022-03-13 19:28:50 +00:00
SNodeList* pFuncs;
2022-06-19 11:39:12 +00:00
SNode* pTspk; // timestamp primary key
SNode* pTsEnd; // window end timestamp
int8_t triggerType;
int64_t watermark;
2022-12-06 08:07:11 +00:00
int64_t deleteMark;
int8_t igExpired;
2024-03-21 02:50:07 +00:00
int8_t destHasPrimayKey;
bool mergeDataBlock;
} SWindowPhysiNode;
2022-03-23 10:44:02 +00:00
typedef struct SIntervalPhysiNode {
SWindowPhysiNode window;
int64_t interval;
int64_t offset;
int64_t sliding;
int8_t intervalUnit;
int8_t slidingUnit;
2022-03-11 10:11:25 +00:00
} SIntervalPhysiNode;
typedef SIntervalPhysiNode SMergeIntervalPhysiNode;
typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode;
2022-05-09 12:20:05 +00:00
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode;
typedef SIntervalPhysiNode SStreamMidIntervalPhysiNode;
2022-05-09 12:20:05 +00:00
2022-04-30 03:40:12 +00:00
typedef struct SFillPhysiNode {
2022-04-30 06:07:44 +00:00
SPhysiNode node;
EFillMode mode;
SNodeList* pFillExprs;
SNodeList* pNotFillExprs;
2022-04-30 06:07:44 +00:00
SNode* pWStartTs; // SColumnNode
SNode* pValues; // SNodeListNode
STimeWindow timeRange;
2022-04-30 03:40:12 +00:00
} SFillPhysiNode;
2022-09-27 10:11:44 +00:00
typedef SFillPhysiNode SStreamFillPhysiNode;
typedef struct SMultiTableIntervalPhysiNode {
SIntervalPhysiNode interval;
SNodeList* pPartitionKeys;
} SMultiTableIntervalPhysiNode;
2022-03-23 10:44:02 +00:00
typedef struct SSessionWinodwPhysiNode {
SWindowPhysiNode window;
int64_t gap;
2022-03-23 10:44:02 +00:00
} SSessionWinodwPhysiNode;
2022-05-20 11:34:39 +00:00
typedef SSessionWinodwPhysiNode SStreamSessionWinodwPhysiNode;
typedef SSessionWinodwPhysiNode SStreamSemiSessionWinodwPhysiNode;
typedef SSessionWinodwPhysiNode SStreamFinalSessionWinodwPhysiNode;
2022-05-20 11:34:39 +00:00
typedef struct SStateWinodwPhysiNode {
SWindowPhysiNode window;
SNode* pStateKey;
} SStateWinodwPhysiNode;
2022-06-04 12:06:07 +00:00
typedef SStateWinodwPhysiNode SStreamStateWinodwPhysiNode;
2022-12-08 01:36:37 +00:00
typedef struct SEventWinodwPhysiNode {
SWindowPhysiNode window;
2022-12-08 01:36:37 +00:00
SNode* pStartCond;
SNode* pEndCond;
} SEventWinodwPhysiNode;
2022-12-13 06:18:03 +00:00
typedef SEventWinodwPhysiNode SStreamEventWinodwPhysiNode;
2024-01-17 06:22:19 +00:00
typedef struct SCountWinodwPhysiNode {
SWindowPhysiNode window;
int64_t windowCount;
2024-01-26 07:56:26 +00:00
int64_t windowSliding;
2024-01-17 06:22:19 +00:00
} SCountWinodwPhysiNode;
typedef SCountWinodwPhysiNode SStreamCountWinodwPhysiNode;
2022-03-26 06:58:44 +00:00
typedef struct SSortPhysiNode {
SPhysiNode node;
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
2022-04-07 11:08:28 +00:00
SNodeList* pTargets;
bool calcGroupId;
bool excludePkCol;
2022-03-26 06:58:44 +00:00
} SSortPhysiNode;
2022-06-22 15:01:55 +00:00
typedef SSortPhysiNode SGroupSortPhysiNode;
typedef struct SPartitionPhysiNode {
SPhysiNode node;
SNodeList* pExprs; // these are expression list of partition_by_clause
SNodeList* pPartitionKeys;
2022-04-07 11:08:28 +00:00
SNodeList* pTargets;
bool needBlockOutputTsOrder;
int32_t tsSlotId;
} SPartitionPhysiNode;
typedef struct SStreamPartitionPhysiNode {
SPartitionPhysiNode part;
SNodeList* pTags;
SNode* pSubtable;
} SStreamPartitionPhysiNode;
2022-02-28 09:02:43 +00:00
typedef struct SDataSinkNode {
ENodeType type;
2022-03-04 07:17:04 +00:00
SDataBlockDescNode* pInputDataBlockDesc;
2022-02-28 09:02:43 +00:00
} SDataSinkNode;
typedef struct SDataDispatcherNode {
SDataSinkNode sink;
} SDataDispatcherNode;
typedef struct SDataInserterNode {
SDataSinkNode sink;
int32_t numOfTables;
uint32_t size;
2022-10-17 07:43:42 +00:00
void* pData;
2022-02-28 09:02:43 +00:00
} SDataInserterNode;
2022-07-05 13:12:10 +00:00
typedef struct SQueryInserterNode {
SDataSinkNode sink;
2022-07-06 08:16:54 +00:00
SNodeList* pCols;
2022-07-05 13:12:10 +00:00
uint64_t tableId;
2022-07-06 08:16:54 +00:00
uint64_t stableId;
2022-07-05 13:12:10 +00:00
int8_t tableType; // table type
char tableName[TSDB_TABLE_NAME_LEN];
2022-07-05 13:12:10 +00:00
int32_t vgId;
SEpSet epSet;
2023-02-07 10:35:42 +00:00
bool explain;
2022-07-05 13:12:10 +00:00
} SQueryInserterNode;
2022-06-05 07:48:06 +00:00
typedef struct SDataDeleterNode {
SDataSinkNode sink;
uint64_t tableId;
int8_t tableType; // table type
char tableFName[TSDB_TABLE_NAME_LEN];
2022-07-26 09:43:22 +00:00
char tsColName[TSDB_COL_NAME_LEN];
2022-06-05 07:48:06 +00:00
STimeWindow deleteTimeRange;
2022-06-06 10:39:23 +00:00
SNode* pAffectedRows;
SNode* pStartTs;
SNode* pEndTs;
2022-06-05 07:48:06 +00:00
} SDataDeleterNode;
2022-03-02 02:50:51 +00:00
typedef struct SSubplan {
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];
2022-06-24 09:27:43 +00:00
char user[TSDB_USER_LEN];
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
2022-05-23 11:50:08 +00:00
SNode* pTagCond;
2022-06-18 12:15:47 +00:00
SNode* pTagIndexCond;
bool showRewrite;
2024-02-04 04:28:00 +00:00
bool isView;
bool isAudit;
bool dynamicRowThreshold;
2024-02-04 04:28:00 +00:00
int32_t rowsThreshold;
2022-03-02 02:50:51 +00:00
} SSubplan;
typedef enum EExplainMode { EXPLAIN_MODE_DISABLE = 1, EXPLAIN_MODE_STATIC, EXPLAIN_MODE_ANALYZE } EExplainMode;
typedef struct SExplainInfo {
EExplainMode mode;
bool verbose;
double ratio;
} SExplainInfo;
2022-03-02 02:50:51 +00:00
typedef struct SQueryPlan {
ENodeType type;
uint64_t queryId;
int32_t numOfSubplans;
SNodeList* pSubplans; // Element is SNodeListNode. The execution level of subplan, starting from 0.
SExplainInfo explainInfo;
void* pPostPlan;
2022-03-02 02:50:51 +00:00
} SQueryPlan;
2022-08-06 07:26:34 +00:00
const char* dataOrderStr(EDataOrderLevel order);
2022-02-13 18:31:18 +00:00
#ifdef __cplusplus
}
#endif
#endif /*_TD_PLANN_NODES_H_*/