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

Execution of ALTER queries on materialized views #1226

Open
bgaifullin opened this issue Sep 11, 2017 · 5 comments
Open

Execution of ALTER queries on materialized views #1226

bgaifullin opened this issue Sep 11, 2017 · 5 comments
Labels
comp-matview Materialized views feature

Comments

@bgaifullin
Copy link
Contributor

Currently execution of ALTER queries on materialized views has not been fully developed.
(according to documentation)

It will be very convenient if materialized view supports:

  • ALTER commands which are supported by underlaying table (with the same limitations).
  • ALTER to modify the query, which is used to transform data.
@arctica
Copy link

arctica commented Jan 31, 2018

This feature would be very useful. I learned (via google groups search result) that the best way right now is:

  1. DETACH view
  2. ALTER the .inner. table of the view
  3. ATTACH the view with the updated table definition and select query

These steps are not atomic and if 2. or 3. fail, then you might have a problem. It's also not trivial to block all running clients from accessing the relevant tables while this is happening.

A full fletched ALTER on materialized views would solve these issues.

@nvartolomei
Copy link
Contributor

@alexey-milovidov do you have a preference for alter materialized view query syntax? I might give it a try.

@gelin
Copy link

gelin commented Aug 5, 2022

ATTACH MATERIALIZED VIEW is not documented. Both here and here. I cannot guess the correct syntax :( And it looks like for Ordinary and Atomic database engines this syntax also differs.
These instructions doesn't work with ClickHouse 21.12.

The same issue is described here.

@gelin
Copy link

gelin commented Aug 10, 2022

The instructions work well on Ordinary database. But with Atomic database the syntax of ATTACH MATERIALIZED VIEW differs and is unknown.

@SaltTan
Copy link
Contributor

SaltTan commented Aug 16, 2022

Always create materialized views using the TO syntax (requires an existing storage table).
It is much easier to manage, especially in Atomic databases.
You can convert an implicit table to an explicit one using these steps (tested on Ordinary databases):

detach table <materialized_view_name>;
rename table ".inner.<materialized_view_name>" to <storage_table>;
attach table <materialized_view_name>;
drop table <materialized_view_name>;
CREATE MATERIALIZED VIEW <materialized_view_name> to <storage_table>...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-matview Materialized views feature
Projects
None yet
Development

No branches or pull requests

7 participants