merge 3.0
This commit is contained in:
parent
8ed69d2195
commit
f080f321dd
|
@ -177,9 +177,6 @@ bool fmIsDistExecFunc(int32_t funcId);
|
|||
bool fmIsForbidFillFunc(int32_t funcId);
|
||||
bool fmIsForbidStreamFunc(int32_t funcId);
|
||||
|
||||
bool fmNeedRewrite(int32_t funcId);
|
||||
int32_t fmRewriteFunc(SNode** pFunc);
|
||||
|
||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);
|
||||
|
||||
typedef enum EFuncDataRequired {
|
||||
|
|
|
@ -23,7 +23,6 @@ extern "C" {
|
|||
#include "functionMgtInt.h"
|
||||
|
||||
typedef int32_t (*FTranslateFunc)(SFunctionNode* pFunc, char* pErrBuf, int32_t len);
|
||||
typedef int32_t (*FRewriteFunc)(SNode** pFunc);
|
||||
typedef EFuncDataRequired (*FFuncDataRequired)(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||
|
||||
typedef struct SBuiltinFuncDefinition {
|
||||
|
@ -31,7 +30,6 @@ typedef struct SBuiltinFuncDefinition {
|
|||
EFunctionType type;
|
||||
uint64_t classification;
|
||||
FTranslateFunc translateFunc;
|
||||
FRewriteFunc rewriteFunc;
|
||||
FFuncDataRequired dataRequiredFunc;
|
||||
FExecGetEnv getEnvFunc;
|
||||
FExecInit initFunc;
|
||||
|
|
|
@ -1387,49 +1387,6 @@ static bool getBlockDistFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv
|
|||
return true;
|
||||
}
|
||||
|
||||
static int32_t rewriteAvg(SNode** pFunc) {
|
||||
SOperatorNode* pOper = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
if (NULL == pOper) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SFunctionNode* pAvg = (SFunctionNode*)*pFunc;
|
||||
pOper->node.resType = pAvg->node.resType;
|
||||
strcpy(pOper->node.aliasName, pAvg->node.aliasName);
|
||||
pOper->opType = OP_TYPE_DIV;
|
||||
pOper->pLeft = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
pOper->pRight = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == pOper->pLeft || NULL == pOper->pRight) {
|
||||
nodesDestroyNode((SNode*)pOper);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SFunctionNode* pSum = (SFunctionNode*)pOper->pLeft;
|
||||
strcpy(pSum->functionName, "sum");
|
||||
pSum->pParameterList = nodesCloneList(pAvg->pParameterList);
|
||||
if (NULL == pSum->pParameterList) {
|
||||
nodesDestroyNode((SNode*)pOper);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
char msgBuf[64] = {0};
|
||||
int32_t code = fmGetFuncInfo(pSum, msgBuf, sizeof(msgBuf));
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SFunctionNode* pCount = (SFunctionNode*)pOper->pRight;
|
||||
strcpy(pCount->functionName, "count");
|
||||
TSWAP(pCount->pParameterList, pAvg->pParameterList);
|
||||
code = fmGetFuncInfo(pCount, msgBuf, sizeof(msgBuf));
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
nodesDestroyNode((SNode*)pAvg);
|
||||
*pFunc = (SNode*)pOper;
|
||||
} else {
|
||||
nodesDestroyNode((SNode*)pOper);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||
{
|
||||
|
@ -1519,7 +1476,6 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.type = FUNCTION_TYPE_AVG,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
// .rewriteFunc = rewriteAvg,
|
||||
.getEnvFunc = getAvgFuncEnv,
|
||||
.initFunc = avgFunctionSetup,
|
||||
.processFunc = avgFunction,
|
||||
|
|
|
@ -324,12 +324,3 @@ int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc
|
|||
|
||||
return code;
|
||||
}
|
||||
|
||||
bool fmNeedRewrite(int32_t funcId) {
|
||||
if (fmIsUserDefinedFunc(funcId)) {
|
||||
return false;
|
||||
}
|
||||
return NULL != funcMgtBuiltins[funcId].rewriteFunc;
|
||||
}
|
||||
|
||||
int32_t fmRewriteFunc(SNode** pFunc) { return funcMgtBuiltins[((SFunctionNode*)*pFunc)->funcId].rewriteFunc(pFunc); }
|
||||
|
|
|
@ -1076,32 +1076,29 @@ static void setFuncClassification(SSelectStmt* pSelect, SFunctionNode* pFunc) {
|
|||
}
|
||||
}
|
||||
|
||||
static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode** pFunc) {
|
||||
static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
||||
SNode* pParam = NULL;
|
||||
FOREACH(pParam, (*pFunc)->pParameterList) {
|
||||
FOREACH(pParam, pFunc->pParameterList) {
|
||||
if (isMultiResFunc(pParam)) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pParam)->aliasName);
|
||||
}
|
||||
}
|
||||
|
||||
pCxt->errCode = getFuncInfo(pCxt, *pFunc);
|
||||
pCxt->errCode = getFuncInfo(pCxt, pFunc);
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
pCxt->errCode = translateAggFunc(pCxt, *pFunc);
|
||||
pCxt->errCode = translateAggFunc(pCxt, pFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
pCxt->errCode = translateScanPseudoColumnFunc(pCxt, *pFunc);
|
||||
pCxt->errCode = translateScanPseudoColumnFunc(pCxt, pFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
pCxt->errCode = translateIndefiniteRowsFunc(pCxt, *pFunc);
|
||||
pCxt->errCode = translateIndefiniteRowsFunc(pCxt, pFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
pCxt->errCode = translateForbidFillFunc(pCxt, *pFunc);
|
||||
pCxt->errCode = translateForbidFillFunc(pCxt, pFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
setFuncClassification(pCxt->pCurrSelectStmt, *pFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode && fmNeedRewrite((*pFunc)->funcId)) {
|
||||
pCxt->errCode = fmRewriteFunc((SNode**)pFunc);
|
||||
setFuncClassification(pCxt->pCurrSelectStmt, pFunc);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -1126,7 +1123,7 @@ static EDealRes doTranslateExpr(SNode** pNode, void* pContext) {
|
|||
case QUERY_NODE_OPERATOR:
|
||||
return translateOperator(pCxt, (SOperatorNode**)pNode);
|
||||
case QUERY_NODE_FUNCTION:
|
||||
return translateFunction(pCxt, (SFunctionNode**)pNode);
|
||||
return translateFunction(pCxt, (SFunctionNode*)pNode);
|
||||
case QUERY_NODE_LOGIC_CONDITION:
|
||||
return translateLogicCond(pCxt, (SLogicConditionNode*)*pNode);
|
||||
case QUERY_NODE_TEMP_TABLE:
|
||||
|
|
Loading…
Reference in New Issue