feat(query): INTERP support boolean type
This commit is contained in:
parent
7a832dbca7
commit
3078e2d487
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue