Skip to content

Commit 3ef543b

Browse files
authored
Merge pull request ClickHouse#106044 from ClickHouse/sema/docs-mv-ignore-errors
Clarify docs for materialized_views_ignore_errors
2 parents f5dd68d + 7d6e135 commit 3ef543b

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

docs/en/sql-reference/statements/create/view.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ Materialized views in ClickHouse are implemented more like insert triggers. If t
146146

147147
Materialized views in ClickHouse do not have deterministic behaviour in case of errors. This means that blocks that had been already written will be preserved in the destination table, but all blocks after error will not.
148148

149-
By default if pushing to one of views fails, then the INSERT query will fail too, and some blocks may not be written to the destination table. This can be changed using `materialized_views_ignore_errors` setting (you should set it for `INSERT` query), if you will set `materialized_views_ignore_errors=true`, then any errors while pushing to views will be ignored and all blocks will be written to the destination table.
149+
By default, if pushing to one of the views throws, the `INSERT` query fails. Whether the block has already reached the source table by that point is not guaranteed — it depends on insert pipeline timing, not on the view error. Retry the failed `INSERT` with insert deduplication (`insert_deduplicate`, `deduplicate_blocks_in_dependent_materialized_views`) to get exactly-once delivery to the source table and all dependent views.
150150

151-
Also note, that `materialized_views_ignore_errors` set to `true` by default for `system.*_log` tables.
151+
Setting `materialized_views_ignore_errors=true` on the `INSERT` query only changes error reporting: each view error is logged as a warning and the `INSERT` query succeeds. Delivery to the failing view's destination is partial — blocks processed before the exception are kept, and the failing block plus any subsequent blocks are dropped from that view. Views downstream of that destination see only the blocks that did arrive, so their delivery is partial too. Sibling views (and their downstream chains) that did not throw are written to in full, and the source table is written to as usual. Because the `INSERT` reports success, the client gets no failure signal and no automatic retry is triggered; use this setting only when source-table writes must not be blocked by view-side problems (for example, `system.*_log` tables).
152+
153+
`materialized_views_ignore_errors` is `true` by default for `system.*_log` tables.
152154
:::
153155

154156
If you specify `POPULATE`, the existing table data is inserted into the view when creating it, as if making a `CREATE TABLE ... AS SELECT ...` . Otherwise, the query contains only the data inserted in the table after creating the view. We **do not recommend** using `POPULATE`, since data inserted in the table during the view creation will not be inserted in it.

src/Core/Settings.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4726,7 +4726,9 @@ This setting is useful for ensuring that materialized views do not contain dupli
47264726
- [NULL Processing in IN Operators](/guides/developer/deduplicating-inserts-on-retries#insert-deduplication-with-materialized-views)
47274727
)", 0) \
47284728
DECLARE(Bool, materialized_views_ignore_errors, false, R"(
4729-
Allows to ignore errors for MATERIALIZED VIEW, and deliver original block to the table regardless of MVs
4729+
If enabled, exceptions thrown while pushing data to a dependent materialized view (in its `SELECT` or in the inner table sink) are logged as a warning and the `INSERT` statement succeeds. If disabled (default), such an exception propagates and the `INSERT` statement fails.
4730+
4731+
This setting controls only error reporting. It does not roll back a write to the source table, and it does not guarantee whether the original block has already been committed to the source table when an error occurs in a dependent view's pipeline. When disabled (default), the `INSERT` fails on a view error — retry it with insert deduplication (`insert_deduplicate`, `deduplicate_blocks_in_dependent_materialized_views`) for exactly-once delivery to the source table and all dependent views. When enabled, the `INSERT` reports success despite partial delivery to failing views and their downstream chains; use this only when source-table writes must not be blocked by view-side problems (for example, `system.*_log` tables). See the `CREATE VIEW` docs for full semantics.
47304732
)", 0) \
47314733
DECLARE(Bool, ignore_materialized_views_with_dropped_target_table, false, R"(
47324734
Ignore MVs with dropped target table during pushing to views

0 commit comments

Comments
 (0)