ALTER TABLE ... MODIFY REFRESH replaces the whole REFRESH clause of a refreshable materialized view, and the refresh mode is part of that clause. If the view was created with APPEND and the new clause does not repeat it, ClickHouse treats the statement as an attempt to remove APPEND, which is not supported:
APPEND at the end of the new REFRESH clause. To change the mode itself, recreate the view with CREATE OR REPLACE MATERIALIZED VIEW.
Reproduce the error
APPEND to a view that was created without it. The reference describes this limitation as “adding or removing APPEND is not supported”.
Repeat the mode in the new clause
- A view created with
APPEND INCREMENTALneeds both keywords.APPENDalone is rejected with the same message. - The mode comes last, after
RANDOMIZE FOR,DEPENDS ONandSETTINGS, as inMODIFY REFRESH EVERY 3 HOUR RANDOMIZE FOR 10 MINUTE SETTINGS refresh_retries = 5 APPEND. If you writeSETTINGSafterAPPEND, the refresh settings are read as query settings and the statement fails withUnknown setting 'refresh_retries'. (UNKNOWN_SETTING). - A view created with
SETTINGS all_replicas = 1has to repeat that setting. Otherwise the statement fails withAltering setting 'all_replicas' is not supported. (NOT_IMPLEMENTED). RANDOMIZE FOR,DEPENDS ONand the other refresh settings that you leave out are removed or reset to their defaults without an error.
system.view_refreshes has no column for the refresh mode. Use SHOW CREATE TABLE to see the current REFRESH clause of a view before you modify it.
Switch between the modes
A view cannot change its mode in place. Replace its definition withCREATE OR REPLACE MATERIALIZED VIEW. When the view writes to a table named in the TO clause, the statement replaces the view only, and the target table keeps its rows.
What happens to these rows afterwards depends on the new mode. A view without APPEND replaces the whole content of its target table on every refresh, including rows that the view did not write:
APPEND adds the full result of its SELECT on every refresh, so rows are duplicated unless the SELECT only returns new rows. Add EMPTY to the CREATE OR REPLACE statement to skip the immediate first refresh.
A view without a TO clause stores its rows in an inner table, and CREATE OR REPLACE drops that table together with the old view.