StarRocks / starrocks

StarRocks, a Linux Foundation project, is a next-generation sub-second MPP OLAP database for full analytics scenarios, including multi-dimensional analytics, real-time analytics, and ad-hoc queries.
https://starrocks.io
Apache License 2.0
8.65k stars 1.75k forks source link

`Value column` should't be supposed to be hash key. #3894

Closed yongbingwang closed 2 years ago

yongbingwang commented 2 years ago

Steps to reproduce the behavior (Required)

  1. create table.
    create table t1 (
    `k1` bigint not null ,
    `k2` int not null ,
    `k3` smallint not null ,
    `k4` date not null ,
    `k5` datetime not null ,
    `v1` varchar not null ,
    `v2` string not null
    )engine=olap duplicate key (k1,k2,k3,k4,k5)
    distributed by hash(v1)
    BUCKETS 10 PROPERTIES ("replication_num" = "1");

    Olojd9ckks

Expected behavior (Required)

create table error.

Real behavior (Required)

mysql> create table t1 (
    -> `k1` bigint not null ,
    -> `k2` int not null ,
    -> `k3` smallint not null ,
    -> `k4` date not null ,
    -> `k5` datetime not null ,
    -> `v1` varchar not null ,
    -> `v2` string not null
    -> )engine=olap duplicate key (k1,k2,k3,k4,k5)
    -> distributed by hash(v1)
    -> BUCKETS 10 PROPERTIES ("replication_num" = "1");
Query OK, 0 rows affected (0.17 sec)

mysql> desc t1;
+-------+----------------+------+-------+---------+-------+
| Field | Type           | Null | Key   | Default | Extra |
+-------+----------------+------+-------+---------+-------+
| k1    | BIGINT         | No   | true  | NULL    |       |
| k2    | INT            | No   | true  | NULL    |       |
| k3    | SMALLINT       | No   | true  | NULL    |       |
| k4    | DATE           | No   | true  | NULL    |       |
| k5    | DATETIME       | No   | true  | NULL    |       |
| v1    | VARCHAR(1)     | No   | false | NULL    |       |
| v2    | VARCHAR(65533) | No   | false | NULL    |       |
+-------+----------------+------+-------+---------+-------+
7 rows in set (0.03 sec)

StarRocks version (Required)

DeepThinker666 commented 2 years ago

why value type column can not be used as a distributed key for duplicate table?