提交 abb545ef 编写于 作者: S shenglian zhou

fix: first/last can process datablock that has only statistics input

上级 f68a1eca
...@@ -196,6 +196,7 @@ typedef struct SQLFunctionCtx { ...@@ -196,6 +196,7 @@ typedef struct SQLFunctionCtx {
uint32_t order; // asc|desc uint32_t order; // asc|desc
int16_t inputType; int16_t inputType;
int32_t inputBytes; int32_t inputBytes;
bool hasColDataInput; // the input data block has column data
int16_t outputType; int16_t outputType;
int32_t outputBytes; // size of results, determined by function and input column data type int32_t outputBytes; // size of results, determined by function and input column data type
......
...@@ -1322,6 +1322,7 @@ static void doSetInputDataBlockInfo(SOperatorInfo* pOperator, SQLFunctionCtx* pC ...@@ -1322,6 +1322,7 @@ static void doSetInputDataBlockInfo(SOperatorInfo* pOperator, SQLFunctionCtx* pC
pCtx[i].order = order; pCtx[i].order = order;
pCtx[i].size = pBlock->info.rows; pCtx[i].size = pBlock->info.rows;
pCtx[i].currentStage = (uint8_t)pOperator->pRuntimeEnv->scanFlag; pCtx[i].currentStage = (uint8_t)pOperator->pRuntimeEnv->scanFlag;
pCtx[i].hasColDataInput = false;
setBlockStatisInfo(&pCtx[i], pBlock, &pOperator->pExpr[i].base.colInfo); setBlockStatisInfo(&pCtx[i], pBlock, &pOperator->pExpr[i].base.colInfo);
} }
...@@ -1349,6 +1350,7 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, ...@@ -1349,6 +1350,7 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx,
pCtx[i].order = order; pCtx[i].order = order;
pCtx[i].size = pBlock->info.rows; pCtx[i].size = pBlock->info.rows;
pCtx[i].currentStage = (uint8_t)pOperator->pRuntimeEnv->scanFlag; pCtx[i].currentStage = (uint8_t)pOperator->pRuntimeEnv->scanFlag;
pCtx[i].hasColDataInput = (pBlock->pDataBlock != NULL);
setBlockStatisInfo(&pCtx[i], pBlock, &pOperator->pExpr[i].base.colInfo); setBlockStatisInfo(&pCtx[i], pBlock, &pOperator->pExpr[i].base.colInfo);
...@@ -2129,6 +2131,9 @@ static bool functionNeedToExecute(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* ...@@ -2129,6 +2131,9 @@ static bool functionNeedToExecute(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx*
} }
if (functionId == TSDB_FUNC_FIRST_DST || functionId == TSDB_FUNC_FIRST) { if (functionId == TSDB_FUNC_FIRST_DST || functionId == TSDB_FUNC_FIRST) {
if (pCtx->hasColDataInput == false) {
return false;
}
// if param[2] is set value, input data come from client, order is no relation with pQueryAttr->order, so always // if param[2] is set value, input data come from client, order is no relation with pQueryAttr->order, so always
// return true // return true
if (pCtx->param[2].nType == TSDB_DATA_TYPE_INT) return true; if (pCtx->param[2].nType == TSDB_DATA_TYPE_INT) return true;
...@@ -2137,6 +2142,9 @@ static bool functionNeedToExecute(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* ...@@ -2137,6 +2142,9 @@ static bool functionNeedToExecute(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx*
// denote the order type // denote the order type
if ((functionId == TSDB_FUNC_LAST_DST || functionId == TSDB_FUNC_LAST)) { if ((functionId == TSDB_FUNC_LAST_DST || functionId == TSDB_FUNC_LAST)) {
if (pCtx->hasColDataInput == false) {
return false;
}
// if param[2] is set value, input data come from client, order is no relation with pQueryAttr->order, so always // if param[2] is set value, input data come from client, order is no relation with pQueryAttr->order, so always
// return true // return true
if (pCtx->param[2].nType == TSDB_DATA_TYPE_INT) return true; if (pCtx->param[2].nType == TSDB_DATA_TYPE_INT) return true;
...@@ -2259,6 +2267,7 @@ static SQLFunctionCtx* createSQLFunctionCtx(SQueryRuntimeEnv* pRuntimeEnv, SExpr ...@@ -2259,6 +2267,7 @@ static SQLFunctionCtx* createSQLFunctionCtx(SQueryRuntimeEnv* pRuntimeEnv, SExpr
} else { } else {
pCtx->inputBytes = pSqlExpr->colBytes; pCtx->inputBytes = pSqlExpr->colBytes;
} }
pCtx->hasColDataInput = false;
pCtx->ptsOutputBuf = NULL; pCtx->ptsOutputBuf = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册