FriendsOfDoctrine / dbal-clickhouse

Doctrine DBAL driver for ClickHouse database
GNU General Public License v3.0
98 stars 80 forks source link

Troubles with primary key on import MergeTree table #18

Open demenkov opened 5 years ago

demenkov commented 5 years ago

ORDER BY — Primary key.

A tuple of columns or arbitrary expressions. Example: ORDER BY (CounterID, EventDate). If a sampling expression is used, the primary key must contain it. Example: ORDER BY (CounerID, EventDate, intHash32(UserID)).

CREATE TABLE client_work_interval
(
uuid String,
timestamp DateTime,
date Date,
manager_id UInt32,
user_id UInt32,
status Int8
)
ENGINE=MergeTree() PARTITION BY toYYYYMM(date) ORDER BY (date, intHash32(user_id), intHash32(manager_id)) SAMPLE BY intHash32(user_id) SETTINGS index_granularity=8192
php bin/console doctrine:mapping:import 'App\Entity' annotation --path=src/Entity --em=clickhouse

In DatabaseDriver.php line 288:

  Table client_work_interval has no primary key. Doctrine does not support reverse engineering   
  from tables that don't have a primary key.