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

ALTER of key column column_name must be metadata-only #5604

Closed
simPod opened this issue Jun 13, 2019 · 7 comments · Fixed by #18362
Closed

ALTER of key column column_name must be metadata-only #5604

simPod opened this issue Jun 13, 2019 · 7 comments · Fixed by #18362
Assignees
Labels
comp-lowcardinality LowCardinality data type feature 🎅 🎁 gift🎄 To make people wonder question Question?

Comments

@simPod
Copy link
Contributor

simPod commented Jun 13, 2019

Given this table

CREATE TABLE IF NOT EXISTS table1 (
    column1        DateTime,
    column2        UInt32,
    column3        String,
    packets        AggregateFunction(sum, UInt32)
)
ENGINE = AggregatingMergeTree 
PARTITION BY toDate(column1) 
ORDER BY (column1, column2, column3)

And when running

alter table table1 modify column column3 LowCardinality(String);

ClickHouse gives

DB::Exception: ALTER of key column column3 must be metadata-only (version 19.6.2.11 (official build))

What does it mean and can it be bypassed?

@simPod simPod added the question Question? label Jun 13, 2019
@CurtizJ
Copy link
Member

CurtizJ commented Jun 13, 2019

column3 is included in primary key. You can modify it only if data is not modified during alter. But changing type to LowCardinality causes data modification and this action is not supported.
As a solution you can create new table with column3 LowCardinality(String) and copy the data to it using the INSERT SELECT query.

@simPod
Copy link
Contributor Author

simPod commented Jun 14, 2019

Understand, thanks. Maybe the message could be more explicit?

@stale stale bot added the stale label Oct 20, 2019
@simPod
Copy link
Contributor Author

simPod commented Oct 20, 2019

.

@stale stale bot removed the stale label Oct 20, 2019
@simPod
Copy link
Contributor Author

simPod commented Apr 5, 2020

@blinkov only as a feedback, if you wish to improve the error msg or not. Can be closed.

@ClickHouse ClickHouse deleted a comment from stale bot May 5, 2020
@alexey-milovidov
Copy link
Member

@CurtizJ Changing the type to LowCardinality indeed causes column rewrite.
But the primary.idx is not modified by this transformation.

It means that now we can support it.

@alexey-milovidov
Copy link
Member

I assign to @alesapin because he has recently done a big rewrite of ALTER mechanics and now this task looks easy to implement.

@filimonov filimonov added the comp-lowcardinality LowCardinality data type label Jul 10, 2020
@ralphM78
Copy link

ralphM78 commented Dec 2, 2020

Any news about that ?

Ralph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-lowcardinality LowCardinality data type feature 🎅 🎁 gift🎄 To make people wonder question Question?
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants