arthuryangcs opened a new issue #8111:
URL: https://github.com/apache/incubator-doris/issues/8111


   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/incubator-doris/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### Version
   
   trunk
   
   ### What's Wrong?
   
   Create the table:
   ```
   CREATE TABLE test.result_exprs (
     `aid` int(11) NULL,
     `bid` int(11) NULL
   ) ENGINE=OLAP
   DUPLICATE KEY(`aid`)
   COMMENT "OLAP"
   DISTRIBUTED BY HASH(`aid`) BUCKETS 7
   PROPERTIES (
   "replication_num" = "1",
   "in_memory" = "false",
   "business_key_column_name" = "",
   "storage_medium" = "HDD",
   "storage_format" = "V2"
   );
   ```
   
   insert into data:
   ```
   INSERT INTO result_exprs
   SELECT a.aid,
          b.bid
   FROM
     (SELECT 3 AS aid)a
   RIGHT JOIN
     (SELECT 4 AS bid)b ON (a.aid=b.bid);
   ```
   and then query the result:
   ```
   select * from result_exprs;
   ```
   
   the result is:
   
![image](https://user-images.githubusercontent.com/6555533/154420500-2470c133-df85-49e7-8ae4-b8a3f7a3c168.png)
   
   
   ### What You Expected?
   
   
![image](https://user-images.githubusercontent.com/6555533/154421927-5cdd8bbe-8d91-4c9c-8bd9-a17da804e4c5.png)
   
   
   ### How to Reproduce?
   
   As shown above.
   
   ### Anything Else?
   
   I think the insert plan is wrong, It uses 3 instand of the right exprs.
   
   
![image](https://user-images.githubusercontent.com/6555533/154422337-93ff1a27-5f03-42cb-ac2d-ae340bd80398.png)
   
   Maybe this is right:
   
![image](https://user-images.githubusercontent.com/6555533/154422437-446d4ad9-fc27-402f-a444-81d09336ee1f.png)
   
   When Doris generates resultExprs in InsertStmt, I think using 
`queryStmt.getResultExprs()` is more resonable than 
`queryStmt.getBaseTblResultExprs()`.
   
   ### 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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to