cambyzju opened a new issue, #36324:
URL: https://github.com/apache/doris/issues/36324

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Version
   
   nereids planner has this problem, all versions.
   
   ### What's Wrong?
   
   colocate group keys do not the same as on condition, we should no use 
colocate join, then make the result do not correctly.
   
   ### What You Expected?
   
   get correct result
   
   ### How to Reproduce?
   
   1. create table a, use k1 as distributed key
   ```
   CREATE TABLE `a` (
     `k1` INT NOT NULL,
     `k2` INT NOT NULL,
     `v` INT SUM NULL
   ) ENGINE=OLAP
   AGGREGATE KEY(`k1`, `k2`)
   COMMENT 'OLAP'
   DISTRIBUTED BY HASH(`k1`) BUCKETS 10
   PROPERTIES (
   "replication_allocation" = "tag.location.default: 1",
   "colocate_with" = "k1_group"
   ); 
   ```
   
   2. create table b, use k2 as distributed key
   ```
   CREATE TABLE `b` (
     `k1` INT NOT NULL,
     `k2` INT NOT NULL,
     `v` INT SUM NULL
   ) ENGINE=OLAP
   AGGREGATE KEY(`k1`, `k2`)
   COMMENT 'OLAP'
   DISTRIBUTED BY HASH(`k2`) BUCKETS 10
   PROPERTIES (
   "replication_allocation" = "tag.location.default: 1",
   "colocate_with" = "k1_group"
   ); 
   ```
   
   3. and table a and b use the same colocate group: `k1_group`
   4. add some data to table and table b
   ```
   insert into a values(1,2,3);
   insert into b values(1,2,3);
   ```
   5. check the planner, we found colocate join is used. Actually in this case, 
we should not use colocate join:
   ```
   explain select * from a join b on a.k1=b.k1 and a.k2=b.k2;
   ```
   
   ### Anything Else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to