You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/06/18 13:05:11 UTC

[GitHub] [incubator-doris] spaces-X opened a new issue #3908: Column can not be resloved after reorderTable

spaces-X opened a new issue #3908:
URL: https://github.com/apache/incubator-doris/issues/3908


   1. Create two tables:
   
   ```
   CREATE TABLE `s1` (
     `dt` int(11) NULL COMMENT "",
     `id` int(11) NULL COMMENT "",
     `pv` int(11) SUM NULL COMMENT ""
   ) ENGINE=OLAP
   AGGREGATE KEY(`dt`, `id`)
   COMMENT "OLAP"
   DISTRIBUTED BY HASH(`id`) BUCKETS 1
   PROPERTIES (
   "replication_num" = "1",
   "in_memory" = "false",
   "storage_format" = "DEFAULT"
   );
   ```
   
   ```
   CREATE TABLE `s2` (
     `dt` int(11) NULL COMMENT "",
     `id` int(11) NULL COMMENT "",
     `pv` int(11) SUM NULL COMMENT ""
   ) ENGINE=OLAP
   AGGREGATE KEY(`dt`, `id`)
   COMMENT "OLAP"
   DISTRIBUTED BY HASH(`id`) BUCKETS 1
   PROPERTIES (
   "replication_num" = "1",
   "in_memory" = "false",
   "storage_format" = "DEFAULT"
   );
   ```
   2. load some data:
   Actually this step can be ignored, only to simulate normal use.
   ```
   insert into s1 (dt, id, pv) values (20200609, 1, 10), (20200609, 2, 20);
   insert into s2 (dt, id, pv) values (20200609, 1, 10), (20200609, 2, 20);
   ```
   Query sql:
   ```
   SELECT tt1.dt FROM s1 tt1
   INNER JOIN s2  tt2 ON tt2.dt = 20200610
   INNER JOIN (
      SELECT id
      FROM s2 ) tt3
   ON tt3.id = tt2.id
   AND tt1.pv >  1+1
   INNER JOIN s1 tt4 ON tt4.pv = tt1.pv
   ```
   
   ERROR 1054 (42S22): errCode = 2, detailMessage = Unknown column 'id' in 'tt2'
   
   
   This error is caused by reorderTable.
   We expect the order of these tables is that tt3 should be after tt2 because tt3  depends on tt2  with onclause `ON tt3.id = tt2.id`. But actually tt3 is ahead of tt2, which will cause `id` in `tt2` has not been resloved before using.
   
   Expected:      `tt1->tt2->tt3->tt4`    At least tt2 should be ahead of tt3.
   reordered:     `tt3->tt1->tt2->tt4`
   After FromClause#sortTableRefForSubquery:  `tt1->tt3->tt2->tt4`
   
   In SelectStmt#reorderTable, the order of tables depends on their rowcount. Specially, the rowcount of InlineViewRef type will equal to `the following table rowcount +1`. 
   In this case, the rowcount InlineViewRef will be the largest and ordered in the first place. 
   When the first time to do analyze, tt3 is on the head. 
   After expr rewriting , we first reanalyze  tt3 and tt3 depends on tt2.id which can not be used now.
   
   Any suggestions for improving  reorderTable?
   
   
   
   
   


----------------------------------------------------------------
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.

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



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


[GitHub] [incubator-doris] spaces-X commented on issue #3908: Column can not be resloved after reorderTable

Posted by GitBox <gi...@apache.org>.
spaces-X commented on issue #3908:
URL: https://github.com/apache/incubator-doris/issues/3908#issuecomment-651495609


   @liutang123 


----------------------------------------------------------------
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.

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



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