Merge pull request #6957 from taosdata/hotfix/td-5431
[TD-5431]<fix>:fix hashDistinct bug about var_data_type value keys
This commit is contained in:
commit
30a98308fc
|
@ -6594,10 +6594,19 @@ static SSDataBlock* hashDistinct(void* param, bool* newgroup) {
|
||||||
if (isNull(val, type)) {
|
if (isNull(val, type)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t keyLen = 0;
|
||||||
|
if (IS_VAR_DATA_TYPE(pOperator->pExpr->base.colType)) {
|
||||||
|
tstr* var = (tstr*)(val);
|
||||||
|
keyLen = varDataLen(var);
|
||||||
|
} else {
|
||||||
|
keyLen = bytes;
|
||||||
|
}
|
||||||
|
|
||||||
int dummy;
|
int dummy;
|
||||||
void* res = taosHashGet(pInfo->pSet, val, bytes);
|
void* res = taosHashGet(pInfo->pSet, val, keyLen);
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
taosHashPut(pInfo->pSet, val, bytes, &dummy, sizeof(dummy));
|
taosHashPut(pInfo->pSet, val, keyLen, &dummy, sizeof(dummy));
|
||||||
char* start = pResultColInfoData->pData + bytes * pInfo->pRes->info.rows;
|
char* start = pResultColInfoData->pData + bytes * pInfo->pRes->info.rows;
|
||||||
memcpy(start, val, bytes);
|
memcpy(start, val, bytes);
|
||||||
pRes->info.rows += 1;
|
pRes->info.rows += 1;
|
||||||
|
@ -6624,6 +6633,7 @@ SOperatorInfo* createDistinctOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperat
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_IN_EXECUTING;
|
pOperator->status = OP_IN_EXECUTING;
|
||||||
pOperator->operatorType = OP_Distinct;
|
pOperator->operatorType = OP_Distinct;
|
||||||
|
pOperator->pExpr = pExpr;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pRuntimeEnv = pRuntimeEnv;
|
pOperator->pRuntimeEnv = pRuntimeEnv;
|
||||||
|
|
Loading…
Reference in New Issue