v.21.9Improvement

Flush Distributed Table on REPLACE TABLE Query and Handle Insertion Failures

Flush Distributed table on REPLACE TABLE query. Resolves #24566 - Do not replace (or create) table on [CREATE OR] REPLACE TABLE ... AS SELECT query if insertion into new table fails. Resolves #23175. #25895 (tavplubix).
Flushes Distributed tables during REPLACE TABLE queries to ensure consistency and prevent partial replacements if data insertion fails.

Why it matters

This feature addresses issues where a table could be replaced or created during a [CREATE OR] REPLACE TABLE ... AS SELECT query even if the data insertion into the new table fails. It prevents incomplete or inconsistent table states by flushing data on Distributed tables before replacement, thereby improving reliability and data integrity.

How to use it

Use the REPLACE TABLE or CREATE OR REPLACE TABLE syntax as usual with AS SELECT statements. The flushing of Distributed tables is handled automatically during these queries to ensure that the replacement occurs only if the insertion into the new table succeeds.