diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index f4c8521b941b4e82e22195e2c42098705dacc251..520ec3a72a5ace93966a3b0faa41b6f3c5ebc4d5 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -44,7 +44,7 @@ static void setNotFillColumn(SFillInfo* pFillInfo, SColumnInfoData* pDstColInfo, } else { p = FILL_IS_ASC_FILL(pFillInfo) ? &pFillInfo->prev : &pFillInfo->next; } - + SGroupKeys* pKey = taosArrayGet(p->pRowVal, colIdx); doSetVal(pDstColInfo, rowIndex, pKey); } @@ -578,7 +578,12 @@ int32_t taosGetLinearInterpolationVal(SPoint* point, int32_t outputType, SPoint* GET_TYPED_DATA(v1, double, inputType, point1->val); GET_TYPED_DATA(v2, double, inputType, point2->val); - double r = DO_INTERPOLATION(v1, v2, point1->key, point2->key, point->key); + double r = 0; + if (!IS_BOOLEAN_TYPE(inputType)) { + r = DO_INTERPOLATION(v1, v2, point1->key, point2->key, point->key); + } else { + r = (v1 < 1 || v2 < 1) ? 0 : 1; + } SET_TYPED_DATA(point->val, outputType, r); return TSDB_CODE_SUCCESS; diff --git a/source/libs/executor/src/timesliceoperator.c b/source/libs/executor/src/timesliceoperator.c index 911700be8534d7b6b7762854b82bd7ceaad12489..02b95f6b5c5d461371de7f66e44d70bdf5350487 100644 --- a/source/libs/executor/src/timesliceoperator.c +++ b/source/libs/executor/src/timesliceoperator.c @@ -156,6 +156,16 @@ static FORCE_INLINE int32_t timeSliceEnsureBlockCapacity(STimeSliceOperatorInfo* return TSDB_CODE_SUCCESS; } +static bool isIrowtsPseudoColumn(SExprInfo* pExprInfo) { + char *name = pExprInfo->pExpr->_function.functionName; + return (IS_TIMESTAMP_TYPE(pExprInfo->base.resSchema.type) && strcasecmp(name, "_irowts") == 0); +} + +static bool isIsfilledPseudoColumn(SExprInfo* pExprInfo) { + char *name = pExprInfo->pExpr->_function.functionName; + return (IS_BOOLEAN_TYPE(pExprInfo->base.resSchema.type) && strcasecmp(name, "_isfilled") == 0); +} + static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pResBlock, bool beforeTs) { int32_t rows = pResBlock->info.rows; @@ -170,10 +180,10 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp int32_t dstSlot = pExprInfo->base.resSchema.slotId; SColumnInfoData* pDst = taosArrayGet(pResBlock->pDataBlock, dstSlot); - if (IS_TIMESTAMP_TYPE(pExprInfo->base.resSchema.type)) { + if (isIrowtsPseudoColumn(pExprInfo)) { colDataSetVal(pDst, rows, (char*)&pSliceInfo->current, false); continue; - } else if (IS_BOOLEAN_TYPE(pExprInfo->base.resSchema.type)) { + } else if (isIsfilledPseudoColumn(pExprInfo)) { bool isFilled = true; colDataAppend(pDst, pResBlock->info.rows, (char*)&isFilled, false); continue; @@ -203,6 +213,14 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp int64_t v = 0; GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i); colDataSetVal(pDst, rows, (char*)&v, false); + } else if (IS_BOOLEAN_TYPE(pDst->info.type)) { + bool v = false; + if (!IS_VAR_DATA_TYPE(pVar->nType)) { + GET_TYPED_DATA(v, bool, pVar->nType, &pVar->i); + } else { + v = taosStr2Int8(varDataVal(pVar->pz), NULL, 10); + } + colDataSetVal(pDst, rows, (char*)&v, false); } break; } @@ -288,9 +306,9 @@ static void addCurrentRowToResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* int32_t dstSlot = pExprInfo->base.resSchema.slotId; SColumnInfoData* pDst = taosArrayGet(pResBlock->pDataBlock, dstSlot); - if (IS_TIMESTAMP_TYPE(pExprInfo->base.resSchema.type)) { + if (isIrowtsPseudoColumn(pExprInfo)) { colDataSetVal(pDst, pResBlock->info.rows, (char*)&pSliceInfo->current, false); - } else if (IS_BOOLEAN_TYPE(pExprInfo->base.resSchema.type)) { + } else if (isIsfilledPseudoColumn(pExprInfo)) { bool isFilled = false; colDataSetVal(pDst, pResBlock->info.rows, (char*)&isFilled, false); } else { diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index a36204bab7c10a67af4ddec40f61b21cde2d2842..69951f680e745a47c6c7e31947f27f67cb37f97c 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1575,7 +1575,7 @@ static int32_t translateInterp(SFunctionNode* pFunc, char* pErrBuf, int32_t len) uint8_t nodeType = nodeType(nodesListGetNode(pFunc->pParameterList, 0)); uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if (!IS_NUMERIC_TYPE(paraType) || QUERY_NODE_VALUE == nodeType) { + if ((!IS_NUMERIC_TYPE(paraType) && !IS_BOOLEAN_TYPE(paraType))|| QUERY_NODE_VALUE == nodeType) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); }