提交 a8002773 编写于 作者: G Ganlin Zhao

feat(query): add top/bottom function scalar version

上级 7b5a96fa
...@@ -117,6 +117,8 @@ int32_t diffScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam ...@@ -117,6 +117,8 @@ int32_t diffScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam
int32_t stateCountScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t stateCountScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t stateDurationScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t stateDurationScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t topScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t bottomScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -2086,6 +2086,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -2086,6 +2086,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.getEnvFunc = getTopBotFuncEnv, .getEnvFunc = getTopBotFuncEnv,
.initFunc = topBotFunctionSetup, .initFunc = topBotFunctionSetup,
.processFunc = topFunction, .processFunc = topFunction,
.sprocessFunc = topScalarFunction,
.finalizeFunc = topBotFinalize, .finalizeFunc = topBotFinalize,
.combineFunc = topCombine, .combineFunc = topCombine,
.pPartialFunc = "top", .pPartialFunc = "top",
...@@ -2100,6 +2101,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -2100,6 +2101,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.getEnvFunc = getTopBotFuncEnv, .getEnvFunc = getTopBotFuncEnv,
.initFunc = topBotFunctionSetup, .initFunc = topBotFunctionSetup,
.processFunc = bottomFunction, .processFunc = bottomFunction,
.sprocessFunc = bottomScalarFunction,
.finalizeFunc = topBotFinalize, .finalizeFunc = topBotFinalize,
.combineFunc = bottomCombine, .combineFunc = bottomCombine,
.pPartialFunc = "bottom", .pPartialFunc = "bottom",
......
...@@ -2816,3 +2816,32 @@ int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP ...@@ -2816,3 +2816,32 @@ int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
pOutput->numOfRows = numOfBins; pOutput->numOfRows = numOfBins;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t selectScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
SColumnInfoData *pInputData = pInput->columnData;
SColumnInfoData *pOutputData = pOutput->columnData;
int32_t type = GET_PARAM_TYPE(pInput);
for (int32_t i = 0; i < pInput->numOfRows; ++i) {
if (colDataIsNull_s(pInputData, i)) {
colDataAppendNULL(pOutputData, 0);
continue;
}
char* data = colDataGetData(pInputData, i);
colDataAppend(pOutputData, i, data, false);
}
pOutput->numOfRows = 1;
return TSDB_CODE_SUCCESS;
}
int32_t topScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
return selectScalarFunction(pInput, inputNum, pOutput);
}
int32_t bottomScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
return selectScalarFunction(pInput, inputNum, pOutput);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册