diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index 082dd4bcdd545997ed17da6db467eeec9a502893..b9a6a156ccd67ea40823210ddb95ea7d0b4d5e37 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -20,6 +20,51 @@ extern "C" { #endif +#include "catalog.h" +#include "common.h" + +struct SQueryStmtInfo; +struct SInsertStmtInfo; + +/** + * True will be returned if the input sql string is insert, false otherwise. + * @param pStr sql string + * @param length length of the sql string + * @return + */ +bool qIsInsertSql(const char* pStr, size_t length); + +/** + * Parse the sql statement and then return the SQueryStmtInfo as the result of bounded AST. + * @param pSql sql string + * @param length length of the sql string + * @param id operator id, generated by uuid generator + * @param msg extended error message if exists. + * @return error code + */ +int32_t qParseQuerySql(const char* pStr, size_t length, struct SQueryStmtInfo** pQueryInfo, int64_t id, char* msg); + +/** + * Parse the insert sql statement. + * @param pStr sql string + * @param length length of the sql string + * @param pInsertParam data in binary format to submit to vnode directly. + * @param id operator id, generated by uuid generator. + * @param msg extended error message if exists to help avoid the problem in sql statement. + * @return + */ +int32_t qParseInsertSql(const char* pStr, size_t length, struct SInsertStmtInfo** pInsertInfo, int64_t id, char* msg); + +/** + * Convert a normal sql statement to only query tags information to enable that the subscribe client can be aware quickly of the true vgroup ids that + * involved in the subscribe procedure. + * @param pSql + * @param length + * @param pConvertSql + * @return + */ +int32_t qParserConvertSql(const char* pStr, size_t length, char** pConvertSql); + #ifdef __cplusplus } #endif diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h index 6de7a5965391897aeace7d9e124d39cb5926feef..33209e5dd280affdbb52e0ee3cae65b36d921f03 100644 --- a/include/libs/planner/planner.h +++ b/include/libs/planner/planner.h @@ -20,6 +20,52 @@ extern "C" { #endif +/** + * Optimize the query execution plan, currently not implement yet. + * @param pQueryNode + * @return + */ +int32_t qOptimizeQueryPlan(SQueryNode* pQueryNode); + +/** + * Create the query plan according to the bound AST, which is in the form of pQueryInfo + * @param pQueryInfo + * @param pQueryNode + * @return + */ +int32_t qCreateQueryPlan(const SQueryInfo* pQueryInfo, SQueryNode* pQueryNode); + +/** + * Convert the query plan to string, in order to display it in the shell. + * @param pQueryNode + * @return + */ +int32_t qQueryPlanToString(SQueryNode* pQueryNode, char** str); + +/** + * Restore the SQL statement according to the logic query plan. + * @param pQueryNode + * @param sql + * @return + */ +int32_t qQueryPlanToSql(SQueryNode* pQueryNode, char** sql); + +/** + * Create the physical plan for the query, according to the logic plan. + * @param pQueryNode + * @param pPhyNode + * @return + */ +int32_t qCreatePhysicalPlan(SQueryNode* pQueryNode, SEpSet* pQnode, SQueryPhyNode *pPhyNode); + +/** + * Convert to physical plan to string to enable to print it out in the shell. + * @param pPhyNode + * @param str + * @return + */ +int32_t qPhyPlanToString(SQueryPhyNode *pPhyNode, char** str); + #ifdef __cplusplus } #endif diff --git a/include/libs/scheduler/scheduler.h b/include/libs/scheduler/scheduler.h index 205d88970f8ef87e54300dd0a5ab3500f28ba0d4..8863e55741c210bc5549da39a438cc0077d3cb30 100644 --- a/include/libs/scheduler/scheduler.h +++ b/include/libs/scheduler/scheduler.h @@ -20,6 +20,41 @@ extern "C" { #endif +#define QUERY_TASK_MERGE 1 +#define QUERY_TASK_PARTIAL 2 + +/** + * create query job from the physical execution plan + * @param pPhyNode + * @param pJob + * @return + */ +int32_t qCreateQueryJob(const SQueryPhyNode* pPhyNode, SQueryJob* pJob); + +/** + * Process the query job, generated according to the query physical plan. + * This is a synchronized API, and is also thread-safety. + * @param pJob + * @return + */ +int32_t qProcessQueryJob(SQueryJob* pJob); + +/** + * The SSqlObj should not be here???? + * @param pSql + * @param pVgroupId + * @param pRetVgroupId + * @return + */ +SArray* qGetInvolvedVgroupIdList(SSqlObj* pSql, SArray* pVgroupId, SArray* pRetVgroupId); + +/** + * Cancel query job + * @param pJob + * @return + */ +int32_t qKillQueryJob(SQueryJob* pJob); + #ifdef __cplusplus } #endif