Skip to content

Remove CAST from DEFAULT expressions during table creation.#10441

Merged
alexey-milovidov merged 2 commits intomasterfrom
remove_casts_from_defaults
Apr 23, 2020
Merged

Remove CAST from DEFAULT expressions during table creation.#10441
alexey-milovidov merged 2 commits intomasterfrom
remove_casts_from_defaults

Conversation

@alesapin
Copy link
Copy Markdown
Member

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Bug Fix

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix bug when server cannot attach table after column default was altered.

@alesapin alesapin added the pr-bugfix Pull request with bugfix, not backported by default label Apr 22, 2020
@alesapin alesapin changed the title Remove casts from table creation by default Remove CAST from DEFAULT expressions during table creation. Apr 22, 2020
@alesapin
Copy link
Copy Markdown
Member Author

alesapin commented Apr 22, 2020

Actually it's an unfinished part of #9227. We already don't add CAST in alters, after this, we will not add them in create/attach queries.

It's a bug fix because if the user added column with default with ALTER query to the replicated table and executed detach/attach clickhouse will not be able to attach table. Metadata in ZK for the new column stored without CAST both in zookeeper and .sql file, but InterpreterCreateQuery will add cast in memory (before table startup) and after that will try to compare this in-memory struct with data in zookeeper. The check will fail.

@alesapin
Copy link
Copy Markdown
Member Author

If old version created a table with CAST expressions in defaults we will read them from .sql and from the zookeeper. For new tables, we will store defaults without casts also in both places. It should work well.

@alexey-milovidov alexey-milovidov merged commit 1ecfa27 into master Apr 23, 2020
@alexey-milovidov alexey-milovidov deleted the remove_casts_from_defaults branch April 23, 2020 09:36
CurtizJ pushed a commit that referenced this pull request Apr 23, 2020
Remove CAST from DEFAULT expressions during table creation.

(cherry picked from commit 1ecfa27)
@xjewer
Copy link
Copy Markdown
Contributor

xjewer commented Apr 16, 2021

If old version created a table with CAST expressions in defaults we will read them from .sql and from the zookeeper. For new tables, we will store defaults without casts also in both places. It should work well.

in case if the table was created on the old version with the CAST, and adding a replica with a new version will complain:
Table columns structure in ZooKeeper is different from local table structure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-docs-needed pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants