Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support partitions when migrating to CH #332

Closed
aadant opened this issue Oct 20, 2023 · 5 comments
Closed

Support partitions when migrating to CH #332

aadant opened this issue Oct 20, 2023 · 5 comments
Labels
enhancement New feature or request GA-1 All the issues that are issues in release(Scheduled Dec 2023) high-priority qa-verified label to mark issues that were verified by QA

Comments

@aadant
Copy link
Collaborator

aadant commented Oct 20, 2023

The DDL parser should detect MySQL partitions and migrate them to CH.

MySQL :

create table t(
id int primary key,
dt date not null
) engine=InnoDB
PARTITION BY RANGE  COLUMNS(dt)
(PARTITION p20201231 VALUES LESS THAN ('2021-01-01') ENGINE = InnoDB,
 PARTITION p20211230 VALUES LESS THAN ('2021-12-31') ENGINE = InnoDB,
 PARTITION p20211231 VALUES LESS THAN ('2022-01-03') ENGINE = InnoDB,
 PARTITION p20220103 VALUES LESS THAN ('2022-01-04') ENGINE = InnoDB,
 PARTITION p20220104 VALUES LESS THAN ('2022-01-05') ENGINE = InnoDB,
 PARTITION p20220105 VALUES LESS THAN ('2022-01-06') ENGINE = InnoDB
);

CH :

CREATE TABLE t (id int NULL,
dt Date32 not null,
`_version` UInt64 DEFAULT 0,
`is_deleted` UInt8 DEFAULT 0
) engine=ReplacingMergeTree(_version,is_deleted)  partition by dt order by id

Please note that clickhouse_loader.py already supports this for the initial migration.

@aadant
Copy link
Collaborator Author

aadant commented Oct 20, 2023

It should be possible to override the partitioning key (see #323)

@aadant aadant added the enhancement New feature or request label Oct 20, 2023
@aadant
Copy link
Collaborator Author

aadant commented Nov 17, 2023

This is already implemented in clickhouse_loader.py
./sink-connector/python/db_load/clickhouse_loader.py

@subkanthi
Copy link
Collaborator

subkanthi commented Nov 20, 2023

Current sink connector parsing logic:

CREATE TABLE t(id Nullable(Int32),dt Date32 NOT NULL ,
`_version` UInt64,`is_deleted` UInt8) Engine=
ReplacingMergeTree(_version,is_deleted) PARTITION BY  (dt) ORDER BY tuple()

@subkanthi
Copy link
Collaborator

Parsing of primary key columns added.
Fixed in #379

@subkanthi subkanthi added the GA-1 All the issues that are issues in release(Scheduled Dec 2023) label Dec 18, 2023
@Selfeer
Copy link
Collaborator

Selfeer commented Feb 16, 2024

The issue was manually verified by the Altinity QA team and marked as qa-verified.

Build used for testing: altinityinfra/clickhouse-sink-connector:443-678d8ae2567c2c1d89f5430fa57ede619d6ea851-lt

We've verified that when creating a partitioned table in ClickHouse it is correctly mapped to the partitioned table in source MySQL table. Partitions are correctly created in ClickHouse based on the specified partition key.

Issue raised during testing is a separate scenario, which is not related to this one.

Link to the issue: #461

@Selfeer Selfeer added the qa-verified label to mark issues that were verified by QA label Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request GA-1 All the issues that are issues in release(Scheduled Dec 2023) high-priority qa-verified label to mark issues that were verified by QA
Projects
None yet
Development

No branches or pull requests

3 participants