fix: create partialfunction
This commit is contained in:
parent
412c10ed94
commit
323088dc71
|
@ -290,6 +290,7 @@ bool fmIsElapsedFunc(int32_t funcId);
|
||||||
|
|
||||||
void getLastCacheDataType(SDataType* pType, int32_t pkBytes);
|
void getLastCacheDataType(SDataType* pType, int32_t pkBytes);
|
||||||
int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNode** pFunc);
|
int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNode** pFunc);
|
||||||
|
int32_t createFunctionWithSrcFunc(const char* pName, const SFunctionNode* pSrcFunc, SNodeList* pParameterList, SFunctionNode** pFunc);
|
||||||
|
|
||||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMidFunc, SFunctionNode** pMergeFunc);
|
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMidFunc, SFunctionNode** pMergeFunc);
|
||||||
|
|
||||||
|
|
|
@ -1648,7 +1648,7 @@ static int32_t translateOutVarchar(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
||||||
bytes = TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE;
|
bytes = TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE;
|
||||||
break;
|
break;
|
||||||
case FUNCTION_TYPE_TIMEZONE:
|
case FUNCTION_TYPE_TIMEZONE:
|
||||||
bytes = TD_TIMEZONE_LEN;
|
bytes = timeZoneStrLen();
|
||||||
break;
|
break;
|
||||||
case FUNCTION_TYPE_IRATE_PARTIAL:
|
case FUNCTION_TYPE_IRATE_PARTIAL:
|
||||||
bytes = getIrateInfoSize((pFunc->hasPk) ? pFunc->pkBytes : 0) + VARSTR_HEADER_SIZE;
|
bytes = getIrateInfoSize((pFunc->hasPk) ? pFunc->pkBytes : 0) + VARSTR_HEADER_SIZE;
|
||||||
|
|
|
@ -412,6 +412,27 @@ int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNo
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t createFunctionWithSrcFunc(const char* pName, const SFunctionNode* pSrcFunc, SNodeList* pParameterList, SFunctionNode** ppFunc) {
|
||||||
|
int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)ppFunc);
|
||||||
|
if (NULL == *ppFunc) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*ppFunc)->hasPk = pSrcFunc->hasPk;
|
||||||
|
(*ppFunc)->pkBytes = pSrcFunc->pkBytes;
|
||||||
|
|
||||||
|
(void)snprintf((*ppFunc)->functionName, sizeof((*ppFunc)->functionName), "%s", pName);
|
||||||
|
(*ppFunc)->pParameterList = pParameterList;
|
||||||
|
code = getFuncInfo((*ppFunc));
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
(*ppFunc)->pParameterList = NULL;
|
||||||
|
nodesDestroyNode((SNode*)*ppFunc);
|
||||||
|
*ppFunc = NULL;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t createColumnByFunc(const SFunctionNode* pFunc, SColumnNode** ppCol) {
|
static int32_t createColumnByFunc(const SFunctionNode* pFunc, SColumnNode** ppCol) {
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)ppCol);
|
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)ppCol);
|
||||||
if (NULL == *ppCol) {
|
if (NULL == *ppCol) {
|
||||||
|
@ -438,7 +459,8 @@ static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNod
|
||||||
if (NULL == pParameterList) {
|
if (NULL == pParameterList) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
code = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pPartialFunc, pParameterList,pPartialFunc );
|
code =
|
||||||
|
createFunctionWithSrcFunc(funcMgtBuiltins[pSrcFunc->funcId].pPartialFunc, pSrcFunc, pParameterList, pPartialFunc);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
nodesDestroyList(pParameterList);
|
nodesDestroyList(pParameterList);
|
||||||
return code;
|
return code;
|
||||||
|
@ -452,8 +474,6 @@ static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNod
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
tstrncpy((*pPartialFunc)->node.aliasName, name, TSDB_COL_NAME_LEN);
|
tstrncpy((*pPartialFunc)->node.aliasName, name, TSDB_COL_NAME_LEN);
|
||||||
(*pPartialFunc)->hasPk = pSrcFunc->hasPk;
|
|
||||||
(*pPartialFunc)->pkBytes = pSrcFunc->pkBytes;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,9 +499,9 @@ static int32_t createMidFunction(const SFunctionNode* pSrcFunc, const SFunctionN
|
||||||
int32_t code = createMergeFuncPara(pSrcFunc, pPartialFunc, &pParameterList);
|
int32_t code = createMergeFuncPara(pSrcFunc, pPartialFunc, &pParameterList);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if(funcMgtBuiltins[pSrcFunc->funcId].pMiddleFunc != NULL){
|
if(funcMgtBuiltins[pSrcFunc->funcId].pMiddleFunc != NULL){
|
||||||
code = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMiddleFunc, pParameterList, &pFunc);
|
code = createFunctionWithSrcFunc(funcMgtBuiltins[pSrcFunc->funcId].pMiddleFunc, pSrcFunc, pParameterList, &pFunc);
|
||||||
}else{
|
}else{
|
||||||
code = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMergeFunc, pParameterList, &pFunc);
|
code = createFunctionWithSrcFunc(funcMgtBuiltins[pSrcFunc->funcId].pMergeFunc, pSrcFunc, pParameterList, &pFunc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -493,8 +513,6 @@ static int32_t createMidFunction(const SFunctionNode* pSrcFunc, const SFunctionN
|
||||||
} else {
|
} else {
|
||||||
nodesDestroyList(pParameterList);
|
nodesDestroyList(pParameterList);
|
||||||
}
|
}
|
||||||
(*pMidFunc)->hasPk = pPartialFunc->hasPk;
|
|
||||||
(*pMidFunc)->pkBytes = pPartialFunc->pkBytes;
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,7 +523,7 @@ static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctio
|
||||||
|
|
||||||
int32_t code = createMergeFuncPara(pSrcFunc, pPartialFunc, &pParameterList);
|
int32_t code = createMergeFuncPara(pSrcFunc, pPartialFunc, &pParameterList);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMergeFunc, pParameterList, &pFunc);
|
code = createFunctionWithSrcFunc(funcMgtBuiltins[pSrcFunc->funcId].pMergeFunc, pSrcFunc, pParameterList, &pFunc);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pFunc->hasOriginalFunc = true;
|
pFunc->hasOriginalFunc = true;
|
||||||
|
@ -522,8 +540,6 @@ static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctio
|
||||||
} else {
|
} else {
|
||||||
nodesDestroyList(pParameterList);
|
nodesDestroyList(pParameterList);
|
||||||
}
|
}
|
||||||
(*pMergeFunc)->hasPk = pPartialFunc->hasPk;
|
|
||||||
(*pMergeFunc)->pkBytes = pPartialFunc->pkBytes;
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue