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/08/18 04:36:48 UTC

[GitHub] [incubator-doris] EmmyMiao87 opened a new issue #4381: Query with `Count distinct` matches the incorrect materialized view

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


   **Describe the bug**
   The `count distinct` in query matches the incorrect materialized view which only has count() function.
   It causes the query result is incorrect.
   
   **To Reproduce**
   Steps to reproduce the behavior:
   1. create base table
   
   ```
   CREATE TABLE test_shoot_tb_dup ( k1 tinyint NULL, k2 smallint NULL, k3 int NULL, k4 bigint NULL, k5 decimal(9, 3) NULL, k6 char(5) NULL, k10 date NULL, k11 datetime NULL, k7 varchar(20) NULL, k8 double NULL, k9 float NULL )  DISTRIBUTED BY HASH(k1) BUCKETS 5
   ```
   2. create materialized view
   
   ```
   CREATE MATERIALIZED VIEW mv6 AS select k2, k1, k3, k4, count(k6), count(k7) from test_shoot_tb_dup group by k2, k1, k3, k4
   ```
   3. load data
   
   4. query
   
   ```
   select count(distinct k6) from test_shoot_tb_dup ;
   ```
   
   query matches the mv
   ```
   MySQL [test]> explain select count(distinct k6) from test_shoot_tb_dup ;
   +------------------------------------------------------------------------------------------+
   | Explain String                                                                           |
   +------------------------------------------------------------------------------------------+
   | PLAN FRAGMENT 0                                                                          |
   |  OUTPUT EXPRS:<slot 2> sum(`default_cluster:test`.`test_shoot_tb_dup`.`mv_count_k6`)     |
   |   PARTITION: UNPARTITIONED                                                               |
   |                                                                                          |
   |   RESULT SINK                                                                            |
   |                                                                                          |
   |   3:AGGREGATE (merge finalize)                                                           |
   |   |  output: sum(<slot 2> sum(`default_cluster:test`.`test_shoot_tb_dup`.`mv_count_k6`)) |
   |   |  group by:                                                                           |
   |   |                                                                                      |
   |   2:EXCHANGE                                                                             |
   |                                                                                          |
   | PLAN FRAGMENT 1                                                                          |
   |  OUTPUT EXPRS:                                                                           |
   |   PARTITION: RANDOM                                                                      |
   |                                                                                          |
   |   STREAM DATA SINK                                                                       |
   |     EXCHANGE ID: 02                                                                      |
   |     UNPARTITIONED                                                                        |
   |                                                                                          |
   |   1:AGGREGATE (update serialize)                                                         |
   |   |  output: sum(`default_cluster:test`.`test_shoot_tb_dup`.`mv_count_k6`)               |
   |   |  group by:                                                                           |
   |   |                                                                                      |
   |   0:OlapScanNode                                                                         |
   |      TABLE: test_shoot_tb_dup                                                            |
   |      PREAGGREGATION: ON                                                                  |
   |      partitions=1/1                                                                      |
   |      rollup: mv6                                                                         |
   |      tabletRatio=5/5                                                                     |
   |      tabletList=33048,33050,33052,33054,33056                                            |
   |      cardinality=0                                                                       |
   |      avgRowSize=0.0                                                                      |
   |      numNodes=1                                                                          |
   +------------------------------------------------------------------------------------------+
   34 rows in set (0.009 sec)
   ```
   
   **Expected behavior**
    
   Query matches the base table and return correct result .
   
   


----------------------------------------------------------------
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] morningman closed issue #4381: Query with `Count distinct` matches the incorrect materialized view

Posted by GitBox <gi...@apache.org>.
morningman closed issue #4381:
URL: https://github.com/apache/incubator-doris/issues/4381


   


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