TD-12034 Define physical plan data structure.

This commit is contained in:
Xiaoyu Wang 2021-12-13 23:57:54 -05:00
parent 6031721f46
commit 032c9d7bb3
3 changed files with 43 additions and 24 deletions

View File

@ -54,7 +54,7 @@ enum OPERATOR_TYPE_E {
struct SEpSet; struct SEpSet;
struct SQueryPlanNode; struct SQueryPlanNode;
struct SQueryDistPlanNode; struct SQueryPhyPlanNode;
struct SQueryStmtInfo; struct SQueryStmtInfo;
typedef struct SSubquery { typedef struct SSubquery {
@ -62,7 +62,7 @@ typedef struct SSubquery {
int32_t type; // QUERY_TYPE_MERGE|QUERY_TYPE_PARTIAL int32_t type; // QUERY_TYPE_MERGE|QUERY_TYPE_PARTIAL
int32_t level; // the execution level of current subquery, starting from 0. int32_t level; // the execution level of current subquery, starting from 0.
SArray *pUpstream; // the upstream,from which to fetch the result 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; } SSubquery;
typedef struct SQueryJob { typedef struct SQueryJob {
@ -108,7 +108,7 @@ int32_t qQueryPlanToSql(struct SQueryPlanNode* pQueryNode, char** sql);
* @param pPhyNode * @param pPhyNode
* @return * @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. * 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 * @param str
* @return * @return
*/ */
int32_t qPhyPlanToString(struct SQueryDistPlanNode *pPhyNode, char** str); int32_t qPhyPlanToString(struct SQueryPhyPlanNode *pPhyNode, char** str);
/** /**
* Destroy the query plan object. * Destroy the query plan object.
@ -129,7 +129,7 @@ void* qDestroyQueryPlan(struct SQueryPlanNode* pQueryNode);
* @param pQueryPhyNode * @param pQueryPhyNode
* @return * @return
*/ */
void* qDestroyQueryPhyPlan(struct SQueryDistPlanNode* pQueryPhyNode); void* qDestroyQueryPhyPlan(struct SQueryPhyPlanNode* pQueryPhyNode);
/** /**
* Create the query job from the physical execution plan * Create the query job from the physical execution plan
@ -137,7 +137,7 @@ void* qDestroyQueryPhyPlan(struct SQueryDistPlanNode* pQueryPhyNode);
* @param pJob * @param pJob
* @return * @return
*/ */
int32_t qCreateQueryJob(const struct SQueryDistPlanNode* pPhyNode, struct SQueryJob** pJob); int32_t qCreateQueryJob(const struct SQueryPhyPlanNode* pPhyNode, struct SQueryJob** pJob);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -57,20 +57,38 @@ typedef struct SQueryPlanNode {
struct SQueryPlanNode *nextNode; struct SQueryPlanNode *nextNode;
} SQueryPlanNode; } SQueryPlanNode;
typedef struct SQueryDistPlanNode { typedef struct SDataBlockSchema {
int32_t index;
SSchema *pSchema; // the schema of the SSDatablock
int32_t numOfCols; // number of columns
} SDataBlockSchema;
typedef struct SQueryPhyPlanNode {
SQueryNodeBasicInfo info; SQueryNodeBasicInfo info;
SSchema *pSchema; // the schema of the input SSDatablock SArray *pTarget; // target list to be computed at this node
int32_t numOfCols; // number of input columns SArray *qual; // implicitly-ANDed qual conditions
SArray *pExpr; // the query functions or sql aggregations SDataBlockSchema targetSchema;
int32_t numOfExpr; // number of result columns, which is also the number of pExprs // children plan to generated result for current node to process
void *pExtInfo; // additional information // in case of join, multiple plan nodes exist.
SArray *pChildren;
} SQueryPhyPlanNode;
// previous operator to generated result for current node to process typedef struct SQueryScanPhyNode {
// in case of join, multiple prev nodes exist. SQueryPhyPlanNode node;
SArray *pPrevNodes; // upstream nodes, or exchange operator to load data from multiple sources. uint64_t uid;
} SQueryDistPlanNode; } SQueryScanPhyNode;
typedef struct SQueryCostSummary { 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 startTs; // Object created and added into the message queue
int64_t endTs; // the timestamp when the task is completed int64_t endTs; // the timestamp when the task is completed
int64_t cputime; // total cpu cost, not execute elapsed time int64_t cputime; // total cpu cost, not execute elapsed time
@ -91,14 +109,14 @@ typedef struct SQueryCostSummary {
uint32_t loadBlockAgg; uint32_t loadBlockAgg;
uint32_t skipBlocks; uint32_t skipBlocks;
uint64_t resultSize; // generated result size in Kb. uint64_t resultSize; // generated result size in Kb.
} SQueryCostSummary; } SQueryProfileSummary;
typedef struct SQueryTask { typedef struct SQueryTask {
uint64_t queryId; // query id uint64_t queryId; // query id
uint64_t taskId; // task id uint64_t taskId; // task id
SQueryDistPlanNode *pNode; // operator tree SQueryPhyPlanNode *pNode; // operator tree
uint64_t status; // task status 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 void *pOutputHandle; // result buffer handle, to temporarily keep the output result for next stage
} SQueryTask; } SQueryTask;

View File

@ -66,11 +66,12 @@ int32_t qQueryPlanToSql(struct SQueryPlanNode* pQueryNode, char** sql) {
return 0; 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; return 0;
} }
int32_t qPhyPlanToString(struct SQueryDistPlanNode *pPhyNode, char** str) { int32_t qPhyPlanToString(struct SQueryPhyPlanNode *pPhyNode, char** str) {
return 0; return 0;
} }
@ -83,11 +84,11 @@ void* qDestroyQueryPlan(SQueryPlanNode* pQueryNode) {
return NULL; return NULL;
} }
void* qDestroyQueryPhyPlan(struct SQueryDistPlanNode* pQueryPhyNode) { void* qDestroyQueryPhyPlan(struct SQueryPhyPlanNode* pQueryPhyNode) {
return NULL; return NULL;
} }
int32_t qCreateQueryJob(const struct SQueryDistPlanNode* pPhyNode, struct SQueryJob** pJob) { int32_t qCreateQueryJob(const struct SQueryPhyPlanNode* pPhyNode, struct SQueryJob** pJob) {
return 0; return 0;
} }