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 2022/04/18 07:33:11 UTC

[GitHub] [incubator-doris] zenoyang opened a new issue, #9079: [Enhancement] Cannot hit rollup even if the `if expr` contains the rollup dimension

zenoyang opened a new issue, #9079:
URL: https://github.com/apache/incubator-doris/issues/9079

   ### 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.
   
   
   ### Description
   
   Cannot hit rollup even if the if expr contains the rollup dimension.
   
   **Reproduce the problem: **
   ```sql
   create database db1;
   use db1;
   
   -- create table
   CREATE TABLE `tbl` (
     `dt` date NULL COMMENT "dt",
     `is_dau` tinyint(4) NULL COMMENT "is_dau",
     `is_intention` tinyint(4) NULL COMMENT "is_intention",
     `city_id` int(11) NULL COMMENT "city_id",
     `device_id` bitmap BITMAP_UNION NULL COMMENT "device_id"
   ) ENGINE=OLAP
   AGGREGATE KEY(`dt`, `is_dau`, `is_intention`, `city_id`)
   PARTITION BY RANGE(`dt`)
   (PARTITION p20220101 VALUES [('1970-01-01'), ('2022-04-10')),
   PARTITION p20220411 VALUES [('2022-04-10'), ('2022-04-11')),
   PARTITION p20220412 VALUES [('2022-04-11'), ('2022-04-12')))
   DISTRIBUTED BY HASH(`city_id`) BUCKETS 10
   PROPERTIES (
   "replication_num" = "1",
   "in_memory" = "false",
   "storage_format" = "V2"
   );
   
   -- load data
   insert into tbl values ('2022-04-11', 1, 1, 1, to_bitmap(1));
   insert into tbl values ('2022-04-11', 0, 1, 2, to_bitmap(2));
   insert into tbl values ('2022-04-11', 1, 1, 2, to_bitmap(3));
   insert into tbl values ('2022-04-11', 0, 1, 3, to_bitmap(4));
   insert into tbl values ('2022-04-11', 1, 1, 3, to_bitmap(5));
   insert into tbl values ('2022-04-11', 0, 1, 4, to_bitmap(6));
   insert into tbl values ('2022-04-11', 1, 1, 4, to_bitmap(7));
   insert into tbl values ('2022-04-11', 0, 1, 5, to_bitmap(8));
   insert into tbl values ('2022-04-11', 1, 1, 5, to_bitmap(9));
   
   -- add rollup
   ALTER TABLE db1.tbl ADD ROLLUP rollup1 (dt, is_intention, city_id, device_id);
   ```
   
   The following sql can hit `rollup1`, as expected:
   ```sql
   select city_id,
          count(distinct device_id)
   from db1.tbl
   where dt='2022-04-11' and is_intention=1
   group by city_id;
   
   -- explain sql: rollup: rollup1
   
   ```
   
   **The following sql fails to hit `rollup1`:**
   ```sql
   select city_id,
          count(distinct if(is_intention=1,device_id,NULL))
   from db1.tbl
   where dt='2022-04-11'
   group by city_id;
   
   -- explain sql: rollup: tbl
   ```
   
   
   
   ### Solution
   
   Can hit rollup.
   
   ### Are you willing to submit PR?
   
   - [ ] 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-unsubscribe@doris.apache.org.apache.org

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] [doris] zenoyang commented on issue #9079: [Enhancement] Cannot hit rollup even if the `if expr` contains the rollup dimension

Posted by GitBox <gi...@apache.org>.
zenoyang commented on issue #9079:
URL: https://github.com/apache/doris/issues/9079#issuecomment-1169524968

   I found that after changing `if` to `case then`, can hit rollup
   
   ```sql
   select city_id,
          count(distinct case WHEN is_intention=1 then device_id end)
   from db1.tbl
   where dt='2022-04-11'
   group by city_id;
   
   -- explain sql: rollup: rollup1
   ```
   
   


-- 
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-unsubscribe@doris.apache.org

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