fix: irate on super table merge phase and translate
This commit is contained in:
parent
47410db46a
commit
595ae2c5b8
|
@ -1632,7 +1632,7 @@ static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
||||||
static int32_t translateIrateImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isPartial) {
|
static int32_t translateIrateImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isPartial) {
|
||||||
uint8_t colType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
uint8_t colType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||||
if (isPartial) {
|
if (isPartial) {
|
||||||
if (3 != LIST_LENGTH(pFunc->pParameterList)) {
|
if (3 != LIST_LENGTH(pFunc->pParameterList) && 4 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
if (!IS_NUMERIC_TYPE(colType)) {
|
if (!IS_NUMERIC_TYPE(colType)) {
|
||||||
|
|
|
@ -6223,12 +6223,17 @@ static void doSaveRateInfo(SRateInfo* pRateInfo, bool isFirst, int64_t ts, char*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initializeRateInfo(SqlFunctionCtx* pCtx, SRateInfo* pRateInfo) {
|
static void initializeRateInfo(SqlFunctionCtx* pCtx, SRateInfo* pRateInfo, bool isMerge) {
|
||||||
if (pCtx->hasPrimaryKey) {
|
if (pCtx->hasPrimaryKey) {
|
||||||
pRateInfo->pkType = pCtx->input.pPrimaryKey->info.type;
|
if (!isMerge) {
|
||||||
pRateInfo->pkBytes = pCtx->input.pPrimaryKey->info.bytes;
|
pRateInfo->pkType = pCtx->input.pPrimaryKey->info.type;
|
||||||
pRateInfo->firstPk = pRateInfo->pkData;
|
pRateInfo->pkBytes = pCtx->input.pPrimaryKey->info.bytes;
|
||||||
pRateInfo->lastPk = pRateInfo->pkData + pRateInfo->pkBytes;
|
pRateInfo->firstPk = pRateInfo->pkData;
|
||||||
|
pRateInfo->lastPk = pRateInfo->pkData + pRateInfo->pkBytes;
|
||||||
|
} else {
|
||||||
|
pRateInfo->firstPk = pRateInfo->pkData;
|
||||||
|
pRateInfo->lastPk = pRateInfo->pkData + pRateInfo->pkBytes;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pRateInfo->firstPk = NULL;
|
pRateInfo->firstPk = NULL;
|
||||||
pRateInfo->lastPk = NULL;
|
pRateInfo->lastPk = NULL;
|
||||||
|
@ -6246,7 +6251,7 @@ int32_t irateFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
funcInputUpdate(pCtx);
|
funcInputUpdate(pCtx);
|
||||||
|
|
||||||
initializeRateInfo(pCtx, pRateInfo);
|
initializeRateInfo(pCtx, pRateInfo, false);
|
||||||
|
|
||||||
int32_t numOfElems = 0;
|
int32_t numOfElems = 0;
|
||||||
int32_t type = pInputCol->info.type;
|
int32_t type = pInputCol->info.type;
|
||||||
|
@ -6368,13 +6373,13 @@ int32_t irateFunctionMerge(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SRateInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
SRateInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||||
initializeRateInfo(pCtx, pInfo);
|
initializeRateInfo(pCtx, pInfo, true);
|
||||||
|
|
||||||
int32_t start = pInput->startRowIndex;
|
int32_t start = pInput->startRowIndex;
|
||||||
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
||||||
char* data = colDataGetData(pCol, i);
|
char* data = colDataGetData(pCol, i);
|
||||||
SRateInfo* pInputInfo = (SRateInfo*)varDataVal(data);
|
SRateInfo* pInputInfo = (SRateInfo*)varDataVal(data);
|
||||||
initializeRateInfo(pCtx, pInfo);
|
initializeRateInfo(pCtx, pInfo, true);
|
||||||
if (pInputInfo->hasResult) {
|
if (pInputInfo->hasResult) {
|
||||||
int32_t code = irateTransferInfo(pInputInfo, pInfo);
|
int32_t code = irateTransferInfo(pInputInfo, pInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
Loading…
Reference in New Issue