Merge pull request #29292 from taosdata/fix/TD-33331
fix: stable inner join for single vgroup plan issue
This commit is contained in:
commit
8da1cac058
|
@ -6060,11 +6060,22 @@ static int32_t stbJoinOptCreateTagScanNode(SLogicNode* pJoin, SNodeList** ppList
|
|||
}
|
||||
|
||||
SNode* pNode = NULL;
|
||||
SName* pPrev = NULL;
|
||||
FOREACH(pNode, pList) {
|
||||
code = stbJoinOptRewriteToTagScan(pJoin, pNode);
|
||||
if (code) {
|
||||
break;
|
||||
}
|
||||
|
||||
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
||||
if (pScan->pVgroupList && 1 == pScan->pVgroupList->numOfVgroups) {
|
||||
if (NULL == pPrev || 0 == strcmp(pPrev->dbname, pScan->tableName.dbname)) {
|
||||
pPrev = &pScan->tableName;
|
||||
continue;
|
||||
}
|
||||
|
||||
pScan->needSplit = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -6156,6 +6167,7 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL
|
|||
}
|
||||
|
||||
int32_t i = 0;
|
||||
SName* pPrev = NULL;
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, pList) {
|
||||
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
||||
|
@ -6173,6 +6185,16 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL
|
|||
*(srcScan + i++) = pScan->pVgroupList->numOfVgroups <= 1;
|
||||
|
||||
pScan->scanType = SCAN_TYPE_TABLE;
|
||||
|
||||
if (pScan->pVgroupList && 1 == pScan->pVgroupList->numOfVgroups) {
|
||||
if (NULL == pPrev || 0 == strcmp(pPrev->dbname, pScan->tableName.dbname)) {
|
||||
pPrev = &pScan->tableName;
|
||||
continue;
|
||||
}
|
||||
|
||||
pScan->needSplit = true;
|
||||
*(srcScan + i - 1) = false;
|
||||
}
|
||||
}
|
||||
|
||||
*ppList = pList;
|
||||
|
|
|
@ -203,3 +203,41 @@ sql select a.ts, b.ts from sta a join sta b on a.ts = b.ts and a.t1 = b.t1;
|
|||
if $rows != 8 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from testb.stb1 a join testb.st2 b where a.ts = b.ts and a.t = b.t;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
sql select * from testb.stb1 a join testb1.stb21 b where a.ts = b.ts and a.t = b.t;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
sql select * from testb.stb1 b join testb1.stb21 a where a.ts = b.ts and a.t = b.t;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
sql select * from testb.stb1 a join testb1.stb21 b where b.ts = a.ts and b.t = a.t;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
sql select * from testb.stb1 b join testb1.stb21 a where b.ts = a.ts and b.t = a.t;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
sql select * from testb.stb1 b join testb1.stb21 a where a.ts = b.ts and b.t = a.t;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
sql select * from testb.stb1 b join testb1.stb21 a where b.ts = a.ts and a.t = b.t;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
sql select * from testb.stb1 a, testb1.stb21 b where a.ts = b.ts and a.t = b.t;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
sql select * from testb.stb1 a join testb1.stb21 b on a.ts = b.ts and a.t = b.t;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
|
|
@ -57,6 +57,22 @@ sql insert into ctb22 using st2 tags(2) values('2023-10-16 09:10:12', 110222, 11
|
|||
sql insert into ctb23 using st2 tags(3) values('2023-10-16 09:10:13', 110223, 1102230);
|
||||
sql insert into ctb24 using st2 tags(4) values('2023-10-16 09:10:14', 110224, 1102240);
|
||||
|
||||
sql drop database if exists testb1;
|
||||
sql create database testb1 vgroups 1 PRECISION 'us';
|
||||
sql use testb1;
|
||||
|
||||
sql create table stb21(ts timestamp, f int,g int) tags (t int);
|
||||
sql insert into ctb11 using stb21 tags(1) values('2023-10-16 09:10:11', 110111, 1101110);
|
||||
sql insert into ctb12 using stb21 tags(2) values('2023-10-16 09:10:12', 110112, 1101120);
|
||||
sql insert into ctb13 using stb21 tags(3) values('2023-10-16 09:10:13', 110113, 1101130);
|
||||
sql insert into ctb14 using stb21 tags(4) values('2023-10-16 09:10:14', 110114, 1101140);
|
||||
|
||||
sql create table st22(ts timestamp, f int, g int) tags (t int);
|
||||
sql insert into ctb21 using st22 tags(1) values('2023-10-16 09:10:11', 110221, 1102210);
|
||||
sql insert into ctb22 using st22 tags(2) values('2023-10-16 09:10:12', 110222, 1102220);
|
||||
sql insert into ctb23 using st22 tags(3) values('2023-10-16 09:10:13', 110223, 1102230);
|
||||
sql insert into ctb24 using st22 tags(4) values('2023-10-16 09:10:14', 110224, 1102240);
|
||||
|
||||
sql drop database if exists testc;
|
||||
sql create database testc vgroups 3;
|
||||
sql use testc;
|
||||
|
|
Loading…
Reference in New Issue