This commit is contained in:
Haojun Liao 2021-06-22 14:48:21 +08:00
parent 2eb86a90ac
commit 86f935d4b0
1 changed files with 4 additions and 1 deletions

View File

@ -2675,6 +2675,8 @@ static void col_project_function(SQLFunctionCtx *pCtx) {
if (pCtx->numOfParams == 2) {
return;
}
// only one row is required.
if (pCtx->param[0].i64 == 1) {
SET_VAL(pCtx, pCtx->size, 1);
} else {
@ -2683,7 +2685,8 @@ static void col_project_function(SQLFunctionCtx *pCtx) {
char *pData = GET_INPUT_DATA_LIST(pCtx);
if (pCtx->order == TSDB_ORDER_ASC) {
memcpy(pCtx->pOutput, pData, (size_t) pCtx->size * pCtx->inputBytes);
int32_t numOfRows = (pCtx->param[0].i64 == 1)? 1:pCtx->size;
memcpy(pCtx->pOutput, pData, (size_t) numOfRows * pCtx->inputBytes);
} else {
for(int32_t i = 0; i < pCtx->size; ++i) {
memcpy(pCtx->pOutput + (pCtx->size - 1 - i) * pCtx->inputBytes, pData + i * pCtx->inputBytes,