[td-14493] support distinct.
This commit is contained in:
parent
6f26d1771c
commit
d4d210af5b
|
@ -113,7 +113,7 @@ typedef struct SResultRowEntryInfo {
|
||||||
int8_t hasResult; // result generated, not NULL value
|
int8_t hasResult; // result generated, not NULL value
|
||||||
bool initialized; // output buffer has been initialized
|
bool initialized; // output buffer has been initialized
|
||||||
bool complete; // query has completed
|
bool complete; // query has completed
|
||||||
uint32_t numOfRes; // num of output result in current buffer
|
uint16_t numOfRes; // num of output result in current buffer
|
||||||
} SResultRowEntryInfo;
|
} SResultRowEntryInfo;
|
||||||
|
|
||||||
// determine the real data need to calculated the result
|
// determine the real data need to calculated the result
|
||||||
|
|
|
@ -976,7 +976,7 @@ void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData*
|
||||||
for (int32_t k = 0; k < numOfOutput; ++k) {
|
for (int32_t k = 0; k < numOfOutput; ++k) {
|
||||||
pCtx[k].startTs = pWin->skey;
|
pCtx[k].startTs = pWin->skey;
|
||||||
|
|
||||||
// keep it temporarialy
|
// keep it temporarily
|
||||||
bool hasAgg = pCtx[k].input.colDataAggIsSet;
|
bool hasAgg = pCtx[k].input.colDataAggIsSet;
|
||||||
int32_t numOfRows = pCtx[k].input.numOfRows;
|
int32_t numOfRows = pCtx[k].input.numOfRows;
|
||||||
int32_t startOffset = pCtx[k].input.startRowIndex;
|
int32_t startOffset = pCtx[k].input.startRowIndex;
|
||||||
|
|
|
@ -106,7 +106,7 @@ static bool groupKeyCompare(SGroupbyOperatorInfo* pInfo, SSDataBlock* pBlock, in
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keepGroupKeys(SGroupbyOperatorInfo* pInfo, SSDataBlock* pBlock, int32_t rowIndex, int32_t numOfGroupCols) {
|
static void recordGroupKeys(SGroupbyOperatorInfo* pInfo, SSDataBlock* pBlock, int32_t rowIndex, int32_t numOfGroupCols) {
|
||||||
SColumnDataAgg* pColAgg = NULL;
|
SColumnDataAgg* pColAgg = NULL;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfGroupCols; ++i) {
|
for (int32_t i = 0; i < numOfGroupCols; ++i) {
|
||||||
|
@ -197,7 +197,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
|
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
|
||||||
// Compare with the previous row of this column, and do not set the output buffer again if they are identical.
|
// Compare with the previous row of this column, and do not set the output buffer again if they are identical.
|
||||||
if (!pInfo->isInit) {
|
if (!pInfo->isInit) {
|
||||||
keepGroupKeys(pInfo, pBlock, j, numOfGroupCols);
|
recordGroupKeys(pInfo, pBlock, j, numOfGroupCols);
|
||||||
pInfo->isInit = true;
|
pInfo->isInit = true;
|
||||||
num++;
|
num++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -209,6 +209,12 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!equal && j == 0) {
|
||||||
|
num++;
|
||||||
|
recordGroupKeys(pInfo, pBlock, j, numOfGroupCols);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/*int32_t ret = */ generatedHashKey(pInfo->keyBuf, &len, pInfo->pGroupColVals);
|
/*int32_t ret = */ generatedHashKey(pInfo->keyBuf, &len, pInfo->pGroupColVals);
|
||||||
int32_t ret = setGroupResultOutputBuf_rv(&(pInfo->binfo), pOperator->numOfOutput, pInfo->keyBuf, TSDB_DATA_TYPE_VARCHAR, len, 0, pInfo->aggSup.pResultBuf, pTaskInfo, &pInfo->aggSup);
|
int32_t ret = setGroupResultOutputBuf_rv(&(pInfo->binfo), pOperator->numOfOutput, pInfo->keyBuf, TSDB_DATA_TYPE_VARCHAR, len, 0, pInfo->aggSup.pResultBuf, pTaskInfo, &pInfo->aggSup);
|
||||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||||
|
@ -220,7 +226,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
|
|
||||||
// assign the group keys or user input constant values if required
|
// assign the group keys or user input constant values if required
|
||||||
doAssignGroupKeys(pCtx, pOperator->numOfOutput, pBlock->info.rows, rowIndex);
|
doAssignGroupKeys(pCtx, pOperator->numOfOutput, pBlock->info.rows, rowIndex);
|
||||||
keepGroupKeys(pInfo, pBlock, j, numOfGroupCols);
|
recordGroupKeys(pInfo, pBlock, j, numOfGroupCols);
|
||||||
num = 1;
|
num = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue