-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement table rename with atomic exchange (#2229)
Currently, peerdb creates a _resync table and then tries to run ```sql DROP TABLE IF EXISTS target_table; RENAME TABLE _resync_table TO target_table; ``` however, the problem is that this procedure breaks, once a depending dictionary is defined on these tables. In order to enable such behavior, this PR modifies the ClickhouseConnector of Flow to - check whether the database engine supports the `EXCHANGE TABLES` command (https://clickhouse.com/docs/en/sql-reference/statements/exchange) - If it does and the table already existed, runs `EXCHANGE TABLES` followed by a `DROP` which atomically swaps and therefore keeps the dictionary references - If it doesnt, there's a fallback to the old method. Currently, this will work with the Atomic() database engine. --------- Co-authored-by: Philip Dubé <[email protected]>
- Loading branch information
1 parent
ab638d5
commit b7ca715
Showing
1 changed file
with
39 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters