TDengine/include/libs/nodes/querynodes.h

664 lines
20 KiB
C
Raw Normal View History

/*
* 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_QUERY_NODES_H_
#define _TD_QUERY_NODES_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "nodes.h"
2022-02-28 09:02:43 +00:00
#include "tmsg.h"
2022-04-06 07:20:38 +00:00
#include "tvariant.h"
2023-12-01 10:33:50 +00:00
#include "tsimplehash.h"
2022-03-19 07:02:31 +00:00
#define TABLE_TOTAL_COL_NUM(pMeta) ((pMeta)->tableInfo.numOfColumns + (pMeta)->tableInfo.numOfTags)
2022-04-26 03:50:35 +00:00
#define TABLE_META_SIZE(pMeta) \
(NULL == (pMeta) ? 0 : (sizeof(STableMeta) + TABLE_TOTAL_COL_NUM((pMeta)) * sizeof(SSchema)))
#define VGROUPS_INFO_SIZE(pInfo) \
(NULL == (pInfo) ? 0 : (sizeof(SVgroupsInfo) + (pInfo)->numOfVgroups * sizeof(SVgroupInfo)))
2022-03-18 09:44:08 +00:00
2023-10-27 03:36:17 +00:00
typedef struct SAssociationNode {
SNode** pPlace;
SNode* pAssociationNode;
} SAssociationNode;
typedef struct SRawExprNode {
ENodeType nodeType;
2022-04-26 03:50:35 +00:00
char* p;
uint32_t n;
SNode* pNode;
bool isPseudoColumn;
} SRawExprNode;
typedef struct SDataType {
uint8_t type;
uint8_t precision;
uint8_t scale;
int32_t bytes;
} SDataType;
typedef struct SExprNode {
2022-02-11 14:19:31 +00:00
ENodeType type;
SDataType resType;
2022-04-26 03:50:35 +00:00
char aliasName[TSDB_COL_NAME_LEN];
char userAlias[TSDB_COL_NAME_LEN];
2022-04-26 03:50:35 +00:00
SArray* pAssociation;
bool orderAlias;
bool asAlias;
bool asParam;
bool asPosition;
} SExprNode;
typedef enum EColumnType {
COLUMN_TYPE_COLUMN = 1,
COLUMN_TYPE_TAG,
COLUMN_TYPE_TBNAME,
COLUMN_TYPE_WINDOW_START,
COLUMN_TYPE_WINDOW_END,
COLUMN_TYPE_WINDOW_DURATION,
COLUMN_TYPE_GROUP_KEY
} EColumnType;
typedef struct SColumnNode {
2022-04-26 03:50:35 +00:00
SExprNode node; // QUERY_NODE_COLUMN
uint64_t tableId;
int8_t tableType;
col_id_t colId;
uint16_t projIdx; // the idx in project list, start from 1
2022-04-26 03:50:35 +00:00
EColumnType colType; // column or tag
2022-06-04 11:54:55 +00:00
bool hasIndex;
2024-03-15 10:10:08 +00:00
bool isPrimTs;
2022-04-26 03:50:35 +00:00
char dbName[TSDB_DB_NAME_LEN];
char tableName[TSDB_TABLE_NAME_LEN];
char tableAlias[TSDB_TABLE_NAME_LEN];
char colName[TSDB_COL_NAME_LEN];
2022-11-14 08:53:01 +00:00
int16_t dataBlockId;
int16_t slotId;
int16_t numOfPKs;
bool tableHasPk;
2024-03-20 05:09:59 +00:00
bool isPk;
2022-02-24 10:18:41 +00:00
} SColumnNode;
typedef struct SColumnRefNode {
ENodeType type;
2024-01-03 10:30:57 +00:00
SDataType resType;
char colName[TSDB_COL_NAME_LEN];
} SColumnRefNode;
2022-02-23 06:34:18 +00:00
typedef struct STargetNode {
ENodeType type;
2022-04-26 03:50:35 +00:00
int16_t dataBlockId;
int16_t slotId;
SNode* pExpr;
2022-02-23 06:34:18 +00:00
} STargetNode;
2023-11-28 06:35:11 +00:00
#define VALUE_FLAG_IS_DURATION (1 << 0)
#define VALUE_FLAG_IS_TIME_OFFSET (1 << 1)
#define IS_DURATION_VAL(_flag) ((_flag) & VALUE_FLAG_IS_DURATION)
#define IS_TIME_OFFSET_VAL(_flag) ((_flag) & VALUE_FLAG_IS_TIME_OFFSET)
typedef struct SValueNode {
2022-04-26 03:50:35 +00:00
SExprNode node; // QUERY_NODE_VALUE
char* literal;
2023-11-28 06:35:11 +00:00
int32_t flag;
2022-04-26 03:50:35 +00:00
bool translate;
bool notReserved;
bool isNull;
2022-04-26 03:50:35 +00:00
int16_t placeholderNo;
union {
2022-04-26 03:50:35 +00:00
bool b;
int64_t i;
uint64_t u;
2022-04-26 03:50:35 +00:00
double d;
char* p;
} datum;
2022-04-28 12:24:21 +00:00
int64_t typeData;
2022-11-29 08:43:12 +00:00
int8_t unit;
} SValueNode;
typedef struct SLeftValueNode {
ENodeType type;
} SLeftValueNode;
2023-08-14 09:21:15 +00:00
typedef enum EHintOption {
HINT_NO_BATCH_SCAN = 1,
HINT_BATCH_SCAN,
HINT_SORT_FOR_GROUP,
HINT_PARTITION_FIRST,
HINT_PARA_TABLES_SORT,
HINT_SMALLDATA_TS_SORT,
2024-04-10 11:27:36 +00:00
HINT_HASH_JOIN,
HINT_SKIP_TSMA,
2023-08-14 09:21:15 +00:00
} EHintOption;
typedef struct SHintNode {
ENodeType type;
EHintOption option;
void* value;
} SHintNode;
typedef struct SOperatorNode {
2022-04-26 03:50:35 +00:00
SExprNode node; // QUERY_NODE_OPERATOR
EOperatorType opType;
2022-04-26 03:50:35 +00:00
SNode* pLeft;
SNode* pRight;
} SOperatorNode;
typedef struct SLogicConditionNode {
2022-04-26 03:50:35 +00:00
SExprNode node; // QUERY_NODE_LOGIC_CONDITION
ELogicConditionType condType;
2022-04-26 03:50:35 +00:00
SNodeList* pParameterList;
} SLogicConditionNode;
typedef struct SNodeListNode {
SExprNode node; // QUERY_NODE_NODE_LIST
SNodeList* pNodeList;
} SNodeListNode;
typedef struct SFunctionNode {
2022-04-26 03:50:35 +00:00
SExprNode node; // QUERY_NODE_FUNCTION
char functionName[TSDB_FUNC_NAME_LEN];
int32_t funcId;
int32_t funcType;
SNodeList* pParameterList;
2022-04-26 03:50:35 +00:00
int32_t udfBufSize;
2024-03-15 10:34:41 +00:00
bool hasPk;
int32_t pkBytes;
2024-03-11 11:29:08 +00:00
bool hasOriginalFunc;
int32_t originalFuncId;
} SFunctionNode;
typedef struct STableNode {
2022-02-11 14:19:31 +00:00
SExprNode node;
2022-04-26 03:50:35 +00:00
char dbName[TSDB_DB_NAME_LEN];
char tableName[TSDB_TABLE_NAME_LEN];
char tableAlias[TSDB_TABLE_NAME_LEN];
uint8_t precision;
2022-05-25 13:20:11 +00:00
bool singleTable;
} STableNode;
struct STableMeta;
2024-02-28 02:06:14 +00:00
typedef struct STsmaTargetCTbInfo {
2024-03-06 06:50:16 +00:00
char tableName[TSDB_TABLE_NAME_LEN]; // child table or normal table name
2024-02-28 02:06:14 +00:00
uint64_t uid;
2024-03-06 06:50:16 +00:00
} STsmaTargetTbInfo;
2024-02-28 02:06:14 +00:00
typedef struct SRealTableNode {
2022-04-26 03:50:35 +00:00
STableNode table; // QUERY_NODE_REAL_TABLE
struct STableMeta* pMeta;
2022-04-26 03:50:35 +00:00
SVgroupsInfo* pVgroupList;
char qualDbName[TSDB_DB_NAME_LEN]; // SHOW qualDbName.TABLES
double ratio;
2022-06-10 02:16:18 +00:00
SArray* pSmaIndexes;
int8_t cacheLastMode;
2023-12-15 10:11:22 +00:00
SArray* pTsmas;
2024-03-06 06:50:16 +00:00
SArray* tsmaTargetTbVgInfo; // SArray<SVgroupsInfo*>, used for child table or normal table only
SArray* tsmaTargetTbInfo; // SArray<STsmaTargetTbInfo>, used for child table or normal table only
} SRealTableNode;
typedef struct STempTableNode {
2022-04-26 03:50:35 +00:00
STableNode table; // QUERY_NODE_TEMP_TABLE
SNode* pSubquery;
} STempTableNode;
2023-09-19 06:19:54 +00:00
typedef struct SViewNode {
STableNode table; // QUERY_NODE_REAL_TABLE
struct STableMeta* pMeta;
SVgroupsInfo* pVgroupList;
char qualDbName[TSDB_DB_NAME_LEN]; // SHOW qualDbName.TABLES
double ratio;
SArray* pSmaIndexes;
int8_t cacheLastMode;
} SViewNode;
2024-03-06 03:18:57 +00:00
#define JOIN_JLIMIT_MAX_VALUE 1024
2023-11-29 12:06:30 +00:00
#define IS_INNER_NONE_JOIN(_type, _stype) ((_type) == JOIN_TYPE_INNER && (_stype) == JOIN_STYPE_NONE)
2024-03-15 10:10:08 +00:00
#define IS_SEMI_JOIN(_stype) ((_stype) == JOIN_STYPE_SEMI)
2024-01-30 11:19:44 +00:00
#define IS_WINDOW_JOIN(_stype) ((_stype) == JOIN_STYPE_WIN)
2024-02-01 06:58:08 +00:00
#define IS_ASOF_JOIN(_stype) ((_stype) == JOIN_STYPE_ASOF)
2023-11-29 12:06:30 +00:00
typedef enum EJoinType {
2023-11-29 12:06:30 +00:00
JOIN_TYPE_INNER = 0,
2023-06-21 11:33:27 +00:00
JOIN_TYPE_LEFT,
JOIN_TYPE_RIGHT,
2023-11-27 12:01:00 +00:00
JOIN_TYPE_FULL,
2023-11-29 12:06:30 +00:00
JOIN_TYPE_MAX_VALUE
2023-06-21 11:33:27 +00:00
} EJoinType;
2023-11-27 12:01:00 +00:00
typedef enum EJoinSubType {
2023-11-29 12:06:30 +00:00
JOIN_STYPE_NONE = 0,
2023-11-27 12:01:00 +00:00
JOIN_STYPE_OUTER,
JOIN_STYPE_SEMI,
JOIN_STYPE_ANTI,
JOIN_STYPE_ASOF,
JOIN_STYPE_WIN,
2023-11-29 12:06:30 +00:00
JOIN_STYPE_MAX_VALUE
2023-11-27 12:01:00 +00:00
} EJoinSubType;
typedef enum EJoinAlgorithm {
2023-06-27 11:36:51 +00:00
JOIN_ALGO_UNKNOWN = 0,
JOIN_ALGO_MERGE,
JOIN_ALGO_HASH,
} EJoinAlgorithm;
2023-06-28 11:39:04 +00:00
typedef enum EDynQueryType {
DYN_QTYPE_STB_HASH = 1,
} EDynQueryType;
typedef struct SJoinTableNode {
2023-11-27 12:01:00 +00:00
STableNode table; // QUERY_NODE_JOIN_TABLE
EJoinType joinType;
EJoinSubType subType;
SNode* pWindowOffset;
SNode* pJLimit;
2024-02-29 09:52:53 +00:00
SNode* addPrimCond;
2023-11-27 12:01:00 +00:00
bool hasSubQuery;
bool isLowLevelJoin;
SNode* pLeft;
SNode* pRight;
SNode* pOnCond;
} SJoinTableNode;
2022-04-26 03:50:35 +00:00
typedef enum EGroupingSetType { GP_TYPE_NORMAL = 1 } EGroupingSetType;
typedef struct SGroupingSetNode {
2022-04-26 03:50:35 +00:00
ENodeType type; // QUERY_NODE_GROUPING_SET
EGroupingSetType groupingSetType;
2022-04-26 03:50:35 +00:00
SNodeList* pParameterList;
} SGroupingSetNode;
2022-04-26 03:50:35 +00:00
typedef enum EOrder { ORDER_ASC = 1, ORDER_DESC } EOrder;
2022-04-26 03:50:35 +00:00
typedef enum ENullOrder { NULL_ORDER_DEFAULT = 1, NULL_ORDER_FIRST, NULL_ORDER_LAST } ENullOrder;
typedef struct SOrderByExprNode {
2022-04-26 03:50:35 +00:00
ENodeType type; // QUERY_NODE_ORDER_BY_EXPR
SNode* pExpr;
EOrder order;
ENullOrder nullOrder;
} SOrderByExprNode;
typedef struct SLimitNode {
2022-04-26 03:50:35 +00:00
ENodeType type; // QUERY_NODE_LIMIT
int64_t limit;
int64_t offset;
} SLimitNode;
typedef struct SStateWindowNode {
2022-04-26 03:50:35 +00:00
ENodeType type; // QUERY_NODE_STATE_WINDOW
SNode* pCol; // timestamp primary key
SNode* pExpr;
} SStateWindowNode;
typedef struct SSessionWindowNode {
2022-04-26 03:50:35 +00:00
ENodeType type; // QUERY_NODE_SESSION_WINDOW
SColumnNode* pCol; // timestamp primary key
SValueNode* pGap; // gap between two session window(in microseconds)
} SSessionWindowNode;
typedef struct SIntervalWindowNode {
2022-04-26 03:50:35 +00:00
ENodeType type; // QUERY_NODE_INTERVAL_WINDOW
SNode* pCol; // timestamp primary key
SNode* pInterval; // SValueNode
SNode* pOffset; // SValueNode
SNode* pSliding; // SValueNode
SNode* pFill;
} SIntervalWindowNode;
2022-12-08 01:36:37 +00:00
typedef struct SEventWindowNode {
ENodeType type; // QUERY_NODE_EVENT_WINDOW
SNode* pCol; // timestamp primary key
SNode* pStartCond;
SNode* pEndCond;
} SEventWindowNode;
2024-01-17 06:22:19 +00:00
typedef struct SCountWindowNode {
ENodeType type; // QUERY_NODE_EVENT_WINDOW
SNode* pCol; // timestamp primary key
int64_t windowCount;
2024-01-26 07:56:26 +00:00
int64_t windowSliding;
2024-01-17 06:22:19 +00:00
} SCountWindowNode;
typedef enum EFillMode {
FILL_MODE_NONE = 1,
FILL_MODE_VALUE,
2023-02-02 09:16:30 +00:00
FILL_MODE_VALUE_F,
FILL_MODE_PREV,
FILL_MODE_NULL,
2023-02-02 09:16:30 +00:00
FILL_MODE_NULL_F,
FILL_MODE_LINEAR,
FILL_MODE_NEXT
} EFillMode;
typedef enum ETimeLineMode {
TIME_LINE_NONE = 1,
2024-03-15 10:10:08 +00:00
TIME_LINE_BLOCK,
TIME_LINE_MULTI,
TIME_LINE_GLOBAL,
} ETimeLineMode;
2023-09-19 06:03:06 +00:00
typedef enum EShowKind {
SHOW_KIND_ALL = 1,
2023-09-19 06:03:06 +00:00
SHOW_KIND_TABLES_NORMAL,
SHOW_KIND_TABLES_CHILD,
SHOW_KIND_DATABASES_USER,
SHOW_KIND_DATABASES_SYSTEM
} EShowKind;
typedef struct SFillNode {
2022-04-30 06:07:44 +00:00
ENodeType type; // QUERY_NODE_FILL
EFillMode mode;
SNode* pValues; // SNodeListNode
SNode* pWStartTs; // _wstart pseudo column
2022-04-30 06:07:44 +00:00
STimeWindow timeRange;
} SFillNode;
2022-09-22 11:20:21 +00:00
typedef struct SWhenThenNode {
SExprNode node; // QUERY_NODE_WHEN_THEN
SNode* pWhen;
SNode* pThen;
} SWhenThenNode;
typedef struct SCaseWhenNode {
SExprNode node; // QUERY_NODE_CASE_WHEN
SNode* pCase;
SNode* pElse;
SNodeList* pWhenThenList;
} SCaseWhenNode;
2023-11-27 12:01:00 +00:00
typedef struct SWindowOffsetNode {
ENodeType type; // QUERY_NODE_WINDOW_OFFSET
SNode* pStartOffset; // SValueNode
SNode* pEndOffset; // SValueNode
} SWindowOffsetNode;
typedef struct SSelectStmt {
ENodeType type; // QUERY_NODE_SELECT_STMT
bool isDistinct;
SNodeList* pProjectionList;
SNode* pFromTable;
SNode* pWhere;
SNodeList* pPartitionByList;
SNodeList* pTags; // for create stream
SNode* pSubtable; // for create stream
SNode* pWindow;
SNodeList* pGroupByList; // SGroupingSetNode
SNode* pHaving;
SNode* pRange;
SNode* pEvery;
SNode* pFill;
SNodeList* pOrderByList; // SOrderByExprNode
SLimitNode* pLimit;
SLimitNode* pSlimit;
STimeWindow timeRange;
2023-08-14 09:21:15 +00:00
SNodeList* pHint;
char stmtName[TSDB_TABLE_NAME_LEN];
uint8_t precision;
int32_t selectFuncNum;
int32_t returnRows; // EFuncReturnRows
2024-03-23 12:24:50 +00:00
ETimeLineMode timeLineCurMode;
ETimeLineMode timeLineResMode;
2024-07-09 06:48:21 +00:00
int32_t lastProcessByRowFuncId;
bool timeLineFromOrderBy;
bool isEmptyResult;
bool isSubquery;
bool hasAggFuncs;
bool hasRepeatScanFuncs;
bool hasIndefiniteRowsFunc;
bool hasMultiRowsFunc;
bool hasSelectFunc;
bool hasSelectValFunc;
bool hasOtherVectorFunc;
bool hasUniqueFunc;
bool hasTailFunc;
bool hasInterpFunc;
bool hasInterpPseudoColFunc;
bool hasLastRowFunc;
bool hasLastFunc;
bool hasTimeLineFunc;
2023-12-13 15:25:37 +00:00
bool hasCountFunc;
bool hasUdaf;
bool hasStateKey;
bool onlyHasKeepOrderFunc;
bool groupSort;
bool tagScan;
2024-03-15 10:10:08 +00:00
bool joinContains;
} SSelectStmt;
2022-04-26 03:50:35 +00:00
typedef enum ESetOperatorType { SET_OP_TYPE_UNION_ALL = 1, SET_OP_TYPE_UNION } ESetOperatorType;
typedef struct SSetOperator {
2022-04-26 03:50:35 +00:00
ENodeType type; // QUERY_NODE_SET_OPERATOR
ESetOperatorType opType;
2022-04-26 03:50:35 +00:00
SNodeList* pProjectionList;
SNode* pLeft;
SNode* pRight;
SNodeList* pOrderByList; // SOrderByExprNode
SNode* pLimit;
char stmtName[TSDB_TABLE_NAME_LEN];
2022-06-04 11:54:55 +00:00
uint8_t precision;
ETimeLineMode timeLineResMode;
bool timeLineFromOrderBy;
2024-03-15 10:10:08 +00:00
bool joinContains;
} SSetOperator;
2022-02-12 01:59:23 +00:00
typedef enum ESqlClause {
SQL_CLAUSE_FROM = 1,
SQL_CLAUSE_WHERE,
SQL_CLAUSE_PARTITION_BY,
SQL_CLAUSE_WINDOW,
SQL_CLAUSE_FILL,
2022-02-12 01:59:23 +00:00
SQL_CLAUSE_GROUP_BY,
SQL_CLAUSE_HAVING,
2022-04-07 11:08:28 +00:00
SQL_CLAUSE_DISTINCT,
2022-02-12 01:59:23 +00:00
SQL_CLAUSE_SELECT,
SQL_CLAUSE_ORDER_BY
} ESqlClause;
2022-06-04 11:54:55 +00:00
typedef struct SDeleteStmt {
2022-06-18 12:15:47 +00:00
ENodeType type; // QUERY_NODE_DELETE_STMT
SNode* pFromTable; // FROM clause
SNode* pWhere; // WHERE clause
SNode* pCountFunc; // count the number of rows affected
SNode* pFirstFunc; // the start timestamp when the data was actually deleted
SNode* pLastFunc; // the end timestamp when the data was actually deleted
2022-06-18 12:15:47 +00:00
SNode* pTagCond; // pWhere divided into pTagCond and timeRange
2022-06-04 11:54:55 +00:00
STimeWindow timeRange;
uint8_t precision;
bool deleteZeroRows;
} SDeleteStmt;
2022-07-05 13:12:10 +00:00
typedef struct SInsertStmt {
ENodeType type; // QUERY_NODE_INSERT_STMT
SNode* pTable;
SNodeList* pCols;
SNode* pQuery;
uint8_t precision;
} SInsertStmt;
2022-02-28 09:02:43 +00:00
typedef struct SVgDataBlocks {
SVgroupInfo vg;
int32_t numOfTables; // number of tables in current submit block
uint32_t size;
2022-11-17 02:35:25 +00:00
void* pData; // SSubmitReq + SSubmitBlk + ...
2022-02-28 09:02:43 +00:00
} SVgDataBlocks;
2022-11-27 09:09:02 +00:00
typedef void (*FFreeTableBlockHash)(SHashObj*);
typedef void (*FFreeVgourpBlockArray)(SArray*);
struct SStbRowsDataContext;
typedef void (*FFreeStbRowsDataContext)(struct SStbRowsDataContext*);
struct SCreateTbInfo;
struct SParseFileContext;
typedef void (*FDestroyParseFileContext)(struct SParseFileContext**);
2022-12-20 08:53:08 +00:00
typedef struct SVnodeModifyOpStmt {
2022-11-27 09:09:02 +00:00
ENodeType nodeType;
ENodeType sqlNodeType;
SArray* pDataBlocks; // data block for each vgroup, SArray<SVgDataBlocks*>.
uint32_t insertType; // insert data from [file|sql statement| bound statement]
const char* pSql; // current sql statement position
int32_t totalRowsNum;
int32_t totalTbNum;
SName targetTableName;
SName usingTableName;
const char* pBoundCols;
struct STableMeta* pTableMeta;
2023-04-25 09:39:28 +00:00
SNode* pTagCond;
SArray* pTableTag;
SHashObj* pVgroupsHashObj; // SHashObj<vgId, SVgInfo>
2022-11-27 09:09:02 +00:00
SHashObj* pTableBlockHashObj; // SHashObj<tuid, STableDataCxt*>
SHashObj* pSubTableHashObj; // SHashObj<table_name, STableMeta*>
2023-10-24 08:08:08 +00:00
SHashObj* pTableNameHashObj; // set of table names for refreshing meta, sync mode
SHashObj* pDbFNameHashObj; // set of db names for refreshing meta, sync mode
2023-11-28 17:53:13 +00:00
SHashObj* pTableCxtHashObj; // temp SHashObj<tuid, STableDataCxt*> for single request
SArray* pVgDataBlocks; // SArray<SVgroupDataCxt*>
2022-11-27 09:09:02 +00:00
SVCreateTbReq* pCreateTblReq;
TdFilePtr fp;
FFreeTableBlockHash freeHashFunc;
FFreeVgourpBlockArray freeArrayFunc;
bool usingTableProcessing;
bool fileProcessing;
2023-10-20 09:16:45 +00:00
bool stbSyntax;
struct SStbRowsDataContext* pStbRowsCxt;
FFreeStbRowsDataContext freeStbRowsCxtFunc;
struct SCreateTbInfo* pCreateTbInfo;
struct SParseFileContext* pParFileCxt;
FDestroyParseFileContext destroyParseFileCxt;
2022-12-20 08:53:08 +00:00
} SVnodeModifyOpStmt;
2022-02-28 09:02:43 +00:00
typedef struct SExplainOptions {
ENodeType type;
2022-04-26 03:50:35 +00:00
bool verbose;
double ratio;
} SExplainOptions;
typedef struct SExplainStmt {
2022-04-26 03:50:35 +00:00
ENodeType type;
bool analyze;
SExplainOptions* pOptions;
2022-04-26 03:50:35 +00:00
SNode* pQuery;
} SExplainStmt;
2022-05-10 12:59:10 +00:00
typedef struct SCmdMsgInfo {
int16_t msgType;
SEpSet epSet;
void* pMsg;
int32_t msgLen;
} SCmdMsgInfo;
typedef enum EQueryExecMode {
QUERY_EXEC_MODE_LOCAL = 1,
QUERY_EXEC_MODE_RPC,
QUERY_EXEC_MODE_SCHEDULE,
QUERY_EXEC_MODE_EMPTY_RESULT
} EQueryExecMode;
2022-11-04 07:21:38 +00:00
typedef enum EQueryExecStage {
QUERY_EXEC_STAGE_PARSE = 1,
QUERY_EXEC_STAGE_ANALYSE,
QUERY_EXEC_STAGE_SCHEDULE,
QUERY_EXEC_STAGE_END
} EQueryExecStage;
2022-05-10 12:59:10 +00:00
typedef struct SQuery {
2022-11-04 07:21:38 +00:00
ENodeType type;
EQueryExecStage execStage;
EQueryExecMode execMode;
bool haveResultSet;
SNode* pPrevRoot;
2022-11-04 07:21:38 +00:00
SNode* pRoot;
SNode* pPostRoot;
2022-11-04 07:21:38 +00:00
int32_t numOfResCols;
SSchema* pResSchema;
int8_t precision;
SCmdMsgInfo* pCmdMsg;
int32_t msgType;
SArray* pTargetTableList;
SArray* pTableList;
SArray* pDbList;
bool showRewrite;
int32_t placeholderNum;
SArray* pPlaceholderValues;
SNode* pPrepareRoot;
bool stableQuery;
2022-05-10 12:59:10 +00:00
} SQuery;
2023-12-01 10:33:50 +00:00
void nodesWalkSelectStmtImpl(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext);
2022-02-12 01:59:23 +00:00
void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext);
void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewriter rewriter, void* pContext);
typedef enum ECollectColType { COLLECT_COL_TYPE_COL = 1, COLLECT_COL_TYPE_TAG, COLLECT_COL_TYPE_ALL } ECollectColType;
int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char* pTableAlias, ECollectColType type,
SNodeList** pCols);
2023-12-01 10:33:50 +00:00
int32_t nodesCollectColumnsExt(SSelectStmt* pSelect, ESqlClause clause, SSHashObj* pMultiTableAlias, ECollectColType type,
SNodeList** pCols);
int32_t nodesCollectColumnsFromNode(SNode* node, const char* pTableAlias, ECollectColType type, SNodeList** pCols);
2022-02-12 01:59:23 +00:00
typedef bool (*FFuncClassifier)(int32_t funcId);
2023-08-18 05:57:17 +00:00
int32_t nodesCollectFuncs(SSelectStmt* pSelect, ESqlClause clause, char* tableAlias, FFuncClassifier classifier, SNodeList** pFuncs);
2024-01-10 11:07:21 +00:00
int32_t nodesCollectSelectFuncs(SSelectStmt* pSelect, ESqlClause clause, char* tableAlias, FFuncClassifier classifier, SNodeList* pFuncs);
2022-02-12 01:59:23 +00:00
int32_t nodesCollectSpecialNodes(SSelectStmt* pSelect, ESqlClause clause, ENodeType type, SNodeList** pNodes);
bool nodesIsExprNode(const SNode* pNode);
2022-04-02 05:13:20 +00:00
bool nodesIsUnaryOp(const SOperatorNode* pOp);
bool nodesIsArithmeticOp(const SOperatorNode* pOp);
bool nodesIsComparisonOp(const SOperatorNode* pOp);
bool nodesIsJsonOp(const SOperatorNode* pOp);
2022-05-14 01:42:52 +00:00
bool nodesIsRegularOp(const SOperatorNode* pOp);
2024-07-12 03:48:48 +00:00
bool nodesIsMatchRegularOp(const SOperatorNode* pOp);
2022-06-22 08:35:14 +00:00
bool nodesIsBitwiseOp(const SOperatorNode* pOp);
bool nodesExprHasColumn(SNode* pNode);
bool nodesExprsHasColumn(SNodeList* pList);
2022-04-30 03:40:12 +00:00
void* nodesGetValueFromNode(SValueNode* pNode);
int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value);
char* nodesGetStrValueFromNode(SValueNode* pNode);
2022-06-04 11:54:55 +00:00
void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
2024-07-21 10:20:30 +00:00
int32_t nodesMakeValueNodeFromString(char* literal, SValueNode** ppValNode);
int32_t nodesMakeValueNodeFromBool(bool b, SValueNode** ppValNode);
int32_t nodesMakeValueNodeFromInt32(int32_t value, SNode** ppNode);
2022-06-04 11:54:55 +00:00
char* nodesGetFillModeString(EFillMode mode);
int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc);
const char* operatorTypeStr(EOperatorType type);
const char* logicConditionTypeStr(ELogicConditionType type);
2023-09-22 07:26:39 +00:00
bool nodesIsStar(SNode* pNode);
bool nodesIsTableStar(SNode* pNode);
2023-11-27 12:01:00 +00:00
char* getJoinTypeString(EJoinType type);
char* getJoinSTypeString(EJoinSubType type);
char* getFullJoinTypeString(EJoinType type, EJoinSubType stype);
2023-12-26 11:28:19 +00:00
int32_t mergeJoinConds(SNode** ppDst, SNode** ppSrc);
2023-11-27 12:01:00 +00:00
#ifdef __cplusplus
}
#endif
2022-02-17 01:34:55 +00:00
#endif /*_TD_QUERY_NODES_H_*/