Skip to content

[Bug] Data skew in Hash Bucketing with CRC32 #66231

Description

@zghong

Search before asking

  • I had searched in the issues and found no similar issues.

Version

master / 4.0.5

What's Wrong?

We have a table with 484,862,245,170 rows, and the data is evenly divided according to shard_num.

CREATE TABLE user_label_double_v1
(
    `shard_num`   SMALLINT    NOT NULL
    `label_name`  VARCHAR(64) NOT NULL
    `label_value` DOUBLE      NOT NULL
    `uid`         INT         NOT NULL
    `dt`          Date        NOT NULL
)
DUPLICATE KEY(shard_num, label_name)
AUTO PARTITION BY RANGE (date_trunc(`dt`, 'day')) ()
DISTRIBUTED BY HASH(shard_num) BUCKETS 512
PROPERTIES (
    "replication_num" = "3",
    "compression" = "zstd"
);

Define DISTRIBUTED BY HASH(shard_num) BUCKETS 512 of the table in Doris, but we found there are some empty tablets after importing all data.

Doris root@6.94.183.233:datamill_test2> select shard_num, count() from user_label_double_v1 group by shard_num order by shard_num;
+-----------+-----------+
| shard_num |  count(*) |
+-----------+-----------+
|         0 | 947087198 |
|         1 | 947550670 |
|         2 | 947106194 |
-- ...
|       510 | 947408237 |
|       511 | 946735634 |
+-----------+-----------+
512 rows in set
Time: 46.628s
Image

What You Expected?

Each data bucket is evenly distributed.

How to Reproduce?

No response

Anything Else?

When defining Hash Bucketing, we want to specify a custom hash function instead of using the fixed CRC32.

For example, we can use crc32(col) % bucket_num, or use xxhash64(col) % bucket_num, or even col % bucket_num.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions