enh(query): add selectivity support for statecount/stateduration
functions TD-18050
This commit is contained in:
parent
590e586163
commit
b4fa0d61b4
|
@ -2465,7 +2465,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "statecount",
|
||||
.type = FUNCTION_TYPE_STATE_COUNT,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||
.translateFunc = translateStateCount,
|
||||
.getEnvFunc = getStateFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
|
@ -2476,7 +2476,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "stateduration",
|
||||
.type = FUNCTION_TYPE_STATE_DURATION,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||
.classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||
.translateFunc = translateStateDuration,
|
||||
.getEnvFunc = getStateFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
|
|
|
@ -4651,10 +4651,15 @@ int32_t stateCountFunction(SqlFunctionCtx* pCtx) {
|
|||
numOfElems++;
|
||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
colDataAppendNULL(pOutput, i);
|
||||
// handle selectivity
|
||||
if (pCtx->subsidiaries.num > 0) {
|
||||
appendSelectivityValue(pCtx, i, i);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
bool ret = checkStateOp(op, pInputCol, i, pCtx->param[2].param);
|
||||
bool ret = checkStateOp(op, pInputCol, i, pCtx->param[2].param);
|
||||
|
||||
int64_t output = -1;
|
||||
if (ret) {
|
||||
output = ++pInfo->count;
|
||||
|
@ -4662,6 +4667,11 @@ int32_t stateCountFunction(SqlFunctionCtx* pCtx) {
|
|||
pInfo->count = 0;
|
||||
}
|
||||
colDataAppend(pOutput, i, (char*)&output, false);
|
||||
|
||||
// handle selectivity
|
||||
if (pCtx->subsidiaries.num > 0) {
|
||||
appendSelectivityValue(pCtx, i, i);
|
||||
}
|
||||
}
|
||||
|
||||
return numOfElems;
|
||||
|
@ -4694,6 +4704,10 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) {
|
|||
numOfElems++;
|
||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||
colDataAppendNULL(pOutput, i);
|
||||
// handle selectivity
|
||||
if (pCtx->subsidiaries.num > 0) {
|
||||
appendSelectivityValue(pCtx, i, i);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -4710,6 +4724,11 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) {
|
|||
pInfo->durationStart = 0;
|
||||
}
|
||||
colDataAppend(pOutput, i, (char*)&output, false);
|
||||
|
||||
// handle selectivity
|
||||
if (pCtx->subsidiaries.num > 0) {
|
||||
appendSelectivityValue(pCtx, i, i);
|
||||
}
|
||||
}
|
||||
|
||||
return numOfElems;
|
||||
|
|
Loading…
Reference in New Issue