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

Constraints are not replicated on table creation but are replicated on new additions #451

Closed
bader-tayeb opened this issue Jan 30, 2024 · 1 comment

Comments

@bader-tayeb
Copy link
Contributor

Note: I am running on latest develop branch with the lightweight connector.

On MySQL when I create a table with constraint it gets replicated to Clickhouse without the constraint.
But when I create a table without a constraint then later add a constraint, the constraint is added to Clickhouse.

Is this a bug or expected behavior?

Below is code to replicate issue:

MySQL Code:

CREATE TABLE `test` (
  `id` int NOT NULL AUTO_INCREMENT,
  `num` int NOT NULL,
  PRIMARY KEY (`id`),
  CONSTRAINT `less_ten` CHECK (num < 10)
) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE `test2` (
  `id` int NOT NULL AUTO_INCREMENT,
  `num` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

alter table test2 add CONSTRAINT `less_ten` CHECK (num < 10);

On Clickhouse:

3694b8a7cbfe :) show create table test;

SHOW CREATE TABLE test

Query id: 04b938f6-c96b-43f4-9e6f-b98b0ff9ee98

┌─statement─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ CREATE TABLE etadb.test
(
    `id` Int32,
    `num` Int32,
    `_version` UInt64,
    `is_deleted` UInt8
)
ENGINE = ReplacingMergeTree(_version, is_deleted)
ORDER BY id
SETTINGS index_granularity = 8192 │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

1 row in set. Elapsed: 0.002 sec. 

3694b8a7cbfe :) show create table test2;

SHOW CREATE TABLE test2

Query id: e635e760-3b39-4a7d-9c25-e76445e12140

┌─statement───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ CREATE TABLE etadb.test2
(
    `id` Int32,
    `num` Int32,
    `_version` UInt64,
    `is_deleted` UInt8,
    CONSTRAINT less_ten_2 CHECK num < 10
)
ENGINE = ReplacingMergeTree(_version, is_deleted)
ORDER BY id
SETTINGS index_granularity = 8192 │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

1 row in set. Elapsed: 0.001 sec. 
@subkanthi
Copy link
Collaborator

closes: #450

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants