Merge pull request #20595 from taosdata/fix/TD-23283
fix: slimit not work issue
This commit is contained in:
commit
dbca1c0e8c
|
@ -161,10 +161,9 @@ static int32_t discardGroupDataBlock(SSDataBlock* pBlock, SLimitInfo* pLimitInfo
|
||||||
if (pLimitInfo->remainGroupOffset > 0) {
|
if (pLimitInfo->remainGroupOffset > 0) {
|
||||||
return PROJECT_RETRIEVE_CONTINUE;
|
return PROJECT_RETRIEVE_CONTINUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// set current group id of the project operator
|
pLimitInfo->currentGroupId = 0;
|
||||||
pLimitInfo->currentGroupId = pBlock->info.id.groupId;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PROJECT_RETRIEVE_DONE;
|
return PROJECT_RETRIEVE_DONE;
|
||||||
|
@ -175,19 +174,29 @@ static int32_t setInfoForNewGroup(SSDataBlock* pBlock, SLimitInfo* pLimitInfo, S
|
||||||
// here check for a new group data, we need to handle the data of the previous group.
|
// here check for a new group data, we need to handle the data of the previous group.
|
||||||
ASSERT(pLimitInfo->remainGroupOffset == 0 || pLimitInfo->remainGroupOffset == -1);
|
ASSERT(pLimitInfo->remainGroupOffset == 0 || pLimitInfo->remainGroupOffset == -1);
|
||||||
|
|
||||||
if (pLimitInfo->currentGroupId != 0 && pLimitInfo->currentGroupId != pBlock->info.id.groupId) {
|
bool newGroup = false;
|
||||||
|
if (0 == pBlock->info.id.groupId) {
|
||||||
|
pLimitInfo->numOfOutputGroups = 1;
|
||||||
|
} else if (pLimitInfo->currentGroupId != pBlock->info.id.groupId) {
|
||||||
|
pLimitInfo->currentGroupId = pBlock->info.id.groupId;
|
||||||
pLimitInfo->numOfOutputGroups += 1;
|
pLimitInfo->numOfOutputGroups += 1;
|
||||||
if ((pLimitInfo->slimit.limit > 0) && (pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) {
|
newGroup = true;
|
||||||
setOperatorCompleted(pOperator);
|
} else {
|
||||||
return PROJECT_RETRIEVE_DONE;
|
return PROJECT_RETRIEVE_CONTINUE;
|
||||||
}
|
|
||||||
|
|
||||||
// reset the value for a new group data
|
|
||||||
// existing rows that belongs to previous group.
|
|
||||||
resetLimitInfoForNextGroup(pLimitInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return PROJECT_RETRIEVE_DONE;
|
if ((pLimitInfo->slimit.limit >= 0) && (pLimitInfo->slimit.limit < pLimitInfo->numOfOutputGroups)) {
|
||||||
|
setOperatorCompleted(pOperator);
|
||||||
|
return PROJECT_RETRIEVE_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset the value for a new group data
|
||||||
|
// existing rows that belongs to previous group.
|
||||||
|
if (newGroup) {
|
||||||
|
resetLimitInfoForNextGroup(pLimitInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PROJECT_RETRIEVE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo refactor
|
// todo refactor
|
||||||
|
@ -199,7 +208,7 @@ static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SS
|
||||||
if (pBlock->info.rows == 0) {
|
if (pBlock->info.rows == 0) {
|
||||||
return PROJECT_RETRIEVE_CONTINUE;
|
return PROJECT_RETRIEVE_CONTINUE;
|
||||||
} else {
|
} else {
|
||||||
if (limitReached && (pLimitInfo->slimit.limit > 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) {
|
if (limitReached && (pLimitInfo->slimit.limit >= 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) {
|
||||||
setOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -484,6 +484,7 @@ if $rows != 2 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
print === select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) limit 1 offset 0
|
||||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) limit 1 offset 0
|
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) limit 1 offset 0
|
||||||
if $rows != 3 then
|
if $rows != 3 then
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -70,7 +70,7 @@ endi
|
||||||
|
|
||||||
### empty result set
|
### empty result set
|
||||||
sql select count(*) from stb partition by t2,t1 order by t2 asc slimit 0 soffset 0
|
sql select count(*) from stb partition by t2,t1 order by t2 asc slimit 0 soffset 0
|
||||||
if $rows != 9 then
|
if $rows != 0 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue