未验证 提交 a52ee47e 编写于 作者: G Ganlin Zhao 提交者: GitHub

Merge pull request #14226 from taosdata/feat/groupkey_function

refactor(query): refactor _group_key function
......@@ -264,6 +264,7 @@ typedef struct SRateInfo {
typedef struct SGroupKeyInfo{
bool hasResult;
bool isNull;
char data[];
} SGroupKeyInfo;
......@@ -5371,14 +5372,21 @@ int32_t groupKeyFunction(SqlFunctionCtx* pCtx) {
int32_t bytes = pInputCol->info.bytes;
int32_t startIndex = pInput->startRowIndex;
//escape rest of data blocks to avoid first entry be overwritten.
if (pInfo->hasResult) {
goto _group_key_over;
}
if (colDataIsNull_s(pInputCol, startIndex)) {
pInfo->hasResult = false;
pInfo->isNull = true;
pInfo->hasResult = true;
goto _group_key_over;
}
pInfo->hasResult = true;
char* data = colDataGetData(pInputCol, startIndex);
memcpy(pInfo->data, data, bytes);
pInfo->hasResult = true;
_group_key_over:
......@@ -5393,7 +5401,12 @@ int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
SGroupKeyInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
colDataAppend(pCol, pBlock->info.rows, pInfo->data, pInfo->hasResult ? false : true);
if (pInfo->hasResult) {
colDataAppend(pCol, pBlock->info.rows, pInfo->data, pInfo->isNull ? true : false);
} else {
pResInfo->numOfRes = 0;
}
return pResInfo->numOfRes;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册