feat: the function manager adds an interface for manually configuring the parameters of the merge function

This commit is contained in:
Xiaoyu Wang 2022-06-19 10:06:46 +08:00
parent 04e9996db6
commit 7db6081c72
3 changed files with 9 additions and 5 deletions

View File

@ -1737,7 +1737,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.combineFunc = topCombine, .combineFunc = topCombine,
.pPartialFunc = "_top_partial", .pPartialFunc = "_top_partial",
.pMergeFunc = "_top_merge", .pMergeFunc = "_top_merge",
.createMergeParaFuc = topCreateMergePara // .createMergeParaFuc = topCreateMergePara
}, },
{ {
.name = "_top_partial", .name = "_top_partial",

View File

@ -321,16 +321,18 @@ static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctio
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
// overwrite function restype set by translate function // overwrite function restype set by translate function
if (fmIsSameInOutType(pSrcFunc->funcId)) { if (fmIsSameInOutType(pSrcFunc->funcId)) {
(*pMergeFunc)->node.resType = pSrcFunc->node.resType; pFunc->node.resType = pSrcFunc->node.resType;
} }
strcpy((*pMergeFunc)->node.aliasName, pSrcFunc->node.aliasName); strcpy(pFunc->node.aliasName, pSrcFunc->node.aliasName);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
*pMergeFunc = pFunc; *pMergeFunc = pFunc;
} else { } else {
pFunc->pParameterList = NULL; if (NULL != pFunc) {
nodesDestroyNode((SNode*)pFunc); pFunc->pParameterList = NULL;
nodesDestroyNode((SNode*)pFunc);
}
nodesDestroyList(pParameterList); nodesDestroyList(pParameterList);
} }

View File

@ -52,6 +52,8 @@ TEST_F(PlanBasicTest, func) {
run("SELECT PERCENTILE(c1, 60) FROM t1"); run("SELECT PERCENTILE(c1, 60) FROM t1");
run("SELECT TOP(c1, 60) FROM t1"); run("SELECT TOP(c1, 60) FROM t1");
run("SELECT TOP(c1, 60) FROM st1");
} }
TEST_F(PlanBasicTest, uniqueFunc) { TEST_F(PlanBasicTest, uniqueFunc) {