Skip to content

[Bug] Materialized selector chooses the error index when Count(*) #4065

@EmmyMiao87

Description

@EmmyMiao87

Describe the bug
Query: Select count(*) from table;
Error: errorCode = 2, detailMessage = field name is invalid. field = boolean column

To Reproduce
Steps to reproduce the behavior:

  1. create table
CREATE TABLE `ads_feed_card_pd_info`(
  `member_id` bigint COMMENT '用户的id', 
  `client_id` varchar(36) COMMENT '设备id', 
  `hash_id` varchar(32) COMMENT '用户hashid', 
  `p_date` DATE,
  `is_client_id_day_new` boolean COMMENT '是否是新设备', 
 ...
) 
ENGINE=olap
DUPLICATE KEY(member_id, client_id, hash_id)
PARTITION BY RANGE (p_date)
(
  PARTITION p1 VALUES LESS THAN ("2017-07-01"),
  PARTITION p2 VALUES LESS THAN ("2017-07-02"),
  PARTITION p3 VALUES LESS THAN ("2017-07-03"),
  PARTITION p4 VALUES LESS THAN ("2017-07-04"),
  PARTITION p5 VALUES LESS THAN ("2017-07-06"),
  PARTITION p6 VALUES LESS THAN ("2017-07-07"),
  PARTITION p7 VALUES LESS THAN ("2017-07-08"),
  PARTITION p8 VALUES LESS THAN ("2017-07-09"),
  PARTITION p9 VALUES LESS THAN ("2017-07-10")
)
DISTRIBUTED BY HASH(member_id) BUCKETS 32
ROLLUP(
  user_dim_rollup(
    is_client_id_day_new, is_member_hash_id_day_new,...
  ),
  user_type_rollup(user_type),
  author_type_rollup(author_user_type),
  content_dim_rollup(
    is_good_content, content_type,generator_type,display_type,...
  ),
  user_behavior_rollup(
    is_comment, is_upvote, is_share, is_thank, is_uninterest, is_down_vote, is_unhelp,...
  ),
  region_rollup(city),
  common_rollup(network_type, brand)
)
PROPERTIES(
  "replication_num"="1",
  "storage_type"="column"
);
  1. query
select count(*) from ads_feed_card_pd_info;
ERROR 1064 (HY000): errCode = 2, detailMessage = field name is invalied. field=is_client_id_day_new
  1. explain query
explain select count(*) from ads_feed_card_pd_info;
+---------------------------------------------------------------------------------------------------------------+
| Explain String                                                                                                |
+---------------------------------------------------------------------------------------------------------------+
| PLAN FRAGMENT 0                                                                                               |
|  OUTPUT EXPRS:<slot 0> count(*)                                                                               |
|   PARTITION: UNPARTITIONED                                                                                    |
|                                                                                                               |
|   RESULT SINK                                                                                                 |
|                                                                                                               |
|   3:AGGREGATE (merge finalize)                                                                                |
|   |  output: count(<slot 0> count(*))                                                                         |
|   |  group by:                                                                                                |
|   |  tuple ids: 1                                                                                             |
|   |                                                                                                           |
|   2:EXCHANGE                                                                                                  |
|      tuple ids: 1                                                                                             |
|                                                                                                               |
| PLAN FRAGMENT 1                                                                                               |
|  OUTPUT EXPRS:                                                                                                |
|   PARTITION: RANDOM                                                                                           |
|                                                                                                               |
|   STREAM DATA SINK                                                                                            |
|     EXCHANGE ID: 02                                                                                           |
|     UNPARTITIONED                                                                                             |
|                                                                                                               |
|   1:AGGREGATE (update serialize)                                                                              |
|   |  output: count(*)                                                                                         |
|   |  group by:                                                                                                |
|   |  tuple ids: 1                                                                                             |
|   |                                                                                                           |
|   0:OlapScanNode                                                                                              |
|      TABLE: ads_feed_card_pd_info                                                                             |
|      PREAGGREGATION: ON                                                                                       |
|      partitions=1/9                                                                                           |
|      rollup: region_rollup                                                                                    |
|      tabletRatio=32/32                                                                                        |
|      tabletList=84298373,84298375,84298377,84298379,84298381,84298383,84298385,84298387,84298389,84298391 ... |
|      cardinality=0                                                                                            |
|      avgRowSize=0.0                                                                                           |
|      numNodes=1                                                                                               |
|      tuple ids: 0                                                                                             |
+---------------------------------------------------------------------------------------------------------------+
38 rows in set (0.02 sec)

The incorrect index has been chosen.

Expected behavior

The index which include field is_client_id_day_new should be chosen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/materialized-viewIssues or PRs related to materialized viewkind/fixCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions