From 032c9d7bb313f652454abe366496505609e8ca67 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Mon, 13 Dec 2021 23:57:54 -0500 Subject: [PATCH] TD-12034 Define physical plan data structure. --- include/libs/planner/planner.h | 12 +++---- source/libs/planner/inc/plannerInt.h | 50 +++++++++++++++++++--------- source/libs/planner/src/planner.c | 9 ++--- 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h index 1ff3f02da5..87be26895e 100644 --- a/include/libs/planner/planner.h +++ b/include/libs/planner/planner.h @@ -54,7 +54,7 @@ enum OPERATOR_TYPE_E { struct SEpSet; struct SQueryPlanNode; -struct SQueryDistPlanNode; +struct SQueryPhyPlanNode; struct SQueryStmtInfo; typedef struct SSubquery { @@ -62,7 +62,7 @@ typedef struct SSubquery { int32_t type; // QUERY_TYPE_MERGE|QUERY_TYPE_PARTIAL int32_t level; // the execution level of current subquery, starting from 0. SArray *pUpstream; // the upstream,from which to fetch the result - struct SQueryDistPlanNode *pNode; // physical plan of current subquery + struct SQueryPhyPlanNode *pNode; // physical plan of current subquery } SSubquery; typedef struct SQueryJob { @@ -108,7 +108,7 @@ int32_t qQueryPlanToSql(struct SQueryPlanNode* pQueryNode, char** sql); * @param pPhyNode * @return */ -int32_t qCreatePhysicalPlan(struct SQueryPlanNode* pQueryNode, struct SEpSet* pQnode, struct SQueryDistPlanNode *pPhyNode); +int32_t qCreatePhysicalPlan(struct SQueryPlanNode* pQueryNode, struct SEpSet* pQnode, struct SQueryPhyPlanNode *pPhyNode); /** * Convert to physical plan to string to enable to print it out in the shell. @@ -116,7 +116,7 @@ int32_t qCreatePhysicalPlan(struct SQueryPlanNode* pQueryNode, struct SEpSet* pQ * @param str * @return */ -int32_t qPhyPlanToString(struct SQueryDistPlanNode *pPhyNode, char** str); +int32_t qPhyPlanToString(struct SQueryPhyPlanNode *pPhyNode, char** str); /** * Destroy the query plan object. @@ -129,7 +129,7 @@ void* qDestroyQueryPlan(struct SQueryPlanNode* pQueryNode); * @param pQueryPhyNode * @return */ -void* qDestroyQueryPhyPlan(struct SQueryDistPlanNode* pQueryPhyNode); +void* qDestroyQueryPhyPlan(struct SQueryPhyPlanNode* pQueryPhyNode); /** * Create the query job from the physical execution plan @@ -137,7 +137,7 @@ void* qDestroyQueryPhyPlan(struct SQueryDistPlanNode* pQueryPhyNode); * @param pJob * @return */ -int32_t qCreateQueryJob(const struct SQueryDistPlanNode* pPhyNode, struct SQueryJob** pJob); +int32_t qCreateQueryJob(const struct SQueryPhyPlanNode* pPhyNode, struct SQueryJob** pJob); #ifdef __cplusplus } diff --git a/source/libs/planner/inc/plannerInt.h b/source/libs/planner/inc/plannerInt.h index 6bd89905b1..c51a15509d 100644 --- a/source/libs/planner/inc/plannerInt.h +++ b/source/libs/planner/inc/plannerInt.h @@ -57,20 +57,38 @@ typedef struct SQueryPlanNode { struct SQueryPlanNode *nextNode; } SQueryPlanNode; -typedef struct SQueryDistPlanNode { - SQueryNodeBasicInfo info; - SSchema *pSchema; // the schema of the input SSDatablock - int32_t numOfCols; // number of input columns - SArray *pExpr; // the query functions or sql aggregations - int32_t numOfExpr; // number of result columns, which is also the number of pExprs - void *pExtInfo; // additional information +typedef struct SDataBlockSchema { + int32_t index; + SSchema *pSchema; // the schema of the SSDatablock + int32_t numOfCols; // number of columns +} SDataBlockSchema; - // previous operator to generated result for current node to process - // in case of join, multiple prev nodes exist. - SArray *pPrevNodes; // upstream nodes, or exchange operator to load data from multiple sources. -} SQueryDistPlanNode; - -typedef struct SQueryCostSummary { +typedef struct SQueryPhyPlanNode { + SQueryNodeBasicInfo info; + SArray *pTarget; // target list to be computed at this node + SArray *qual; // implicitly-ANDed qual conditions + SDataBlockSchema targetSchema; + // children plan to generated result for current node to process + // in case of join, multiple plan nodes exist. + SArray *pChildren; +} SQueryPhyPlanNode; + +typedef struct SQueryScanPhyNode { + SQueryPhyPlanNode node; + uint64_t uid; +} SQueryScanPhyNode; + +typedef struct SQueryProjectPhyNode { + SQueryPhyPlanNode node; +} SQueryProjectPhyNode; + +typedef struct SQueryAggPhyNode { + SQueryPhyPlanNode node; + SArray *pGroup; + // SInterval +} SQueryAggPhyNode; + +typedef struct SQueryProfileSummary { int64_t startTs; // Object created and added into the message queue int64_t endTs; // the timestamp when the task is completed int64_t cputime; // total cpu cost, not execute elapsed time @@ -91,14 +109,14 @@ typedef struct SQueryCostSummary { uint32_t loadBlockAgg; uint32_t skipBlocks; uint64_t resultSize; // generated result size in Kb. -} SQueryCostSummary; +} SQueryProfileSummary; typedef struct SQueryTask { uint64_t queryId; // query id uint64_t taskId; // task id - SQueryDistPlanNode *pNode; // operator tree + SQueryPhyPlanNode *pNode; // operator tree uint64_t status; // task status - SQueryCostSummary summary; // task execution summary + SQueryProfileSummary summary; // task execution summary void *pOutputHandle; // result buffer handle, to temporarily keep the output result for next stage } SQueryTask; diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c index 79c7691698..121a7d3c2c 100644 --- a/source/libs/planner/src/planner.c +++ b/source/libs/planner/src/planner.c @@ -66,11 +66,12 @@ int32_t qQueryPlanToSql(struct SQueryPlanNode* pQueryNode, char** sql) { return 0; } -int32_t qCreatePhysicalPlan(struct SQueryPlanNode* pQueryNode, struct SEpSet* pQnode, struct SQueryDistPlanNode *pPhyNode) { +int32_t qCreatePhysicalPlan(struct SQueryPlanNode* pQueryNode, struct SEpSet* pQnode, struct SQueryPhyPlanNode *pPhyNode) { + return 0; } -int32_t qPhyPlanToString(struct SQueryDistPlanNode *pPhyNode, char** str) { +int32_t qPhyPlanToString(struct SQueryPhyPlanNode *pPhyNode, char** str) { return 0; } @@ -83,11 +84,11 @@ void* qDestroyQueryPlan(SQueryPlanNode* pQueryNode) { return NULL; } -void* qDestroyQueryPhyPlan(struct SQueryDistPlanNode* pQueryPhyNode) { +void* qDestroyQueryPhyPlan(struct SQueryPhyPlanNode* pQueryPhyNode) { return NULL; } -int32_t qCreateQueryJob(const struct SQueryDistPlanNode* pPhyNode, struct SQueryJob** pJob) { +int32_t qCreateQueryJob(const struct SQueryPhyPlanNode* pPhyNode, struct SQueryJob** pJob) { return 0; } -- GitLab