Repository navigation
restore: keep existing UDF, no DROP FUNCTION, restore functions before tables - #1657
Merged
Merged
Conversation
restore / restore_remote ran DROP FUNCTION IF EXISTS + CREATE OR REPLACE FUNCTION for every function from backup, even with --tables for one table, function was unavailable between DROP and CREATE and definitions changed after backup were silently rolled back. Now existing functions are read from system.functions first: missing ones are created with CREATE FUNCTION IF NOT EXISTS, identical ones are skipped without any query (no CREATE/DROP FUNCTION grants needed), changed ones are kept with warning and replaced by atomic CREATE OR REPLACE only with --rm, same as tables and RBAC. Functions are restored before tables, so materialized views and tables which use UDF can be created on a clean server. --dry-run shows the plan per function. Fix #1636 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Download closes clickhouse connection on return, so functions plan in restore_remote --dry-run failed with "connection is closed"; fix integration test check of materialized view rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage Report for CI Build 41036149125Coverage increased (+0.05%) to 70.533%Details
Uncovered Changes
Coverage Regressions50 previously-covered lines in 10 files lost coverage.
Coverage Stats
💛 - Coveralls |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #1636
DROP FUNCTION IF EXISTSbefore create, no more window when function doesn't existsystem.functionsbefore restore, for each function from backup:CREATE FUNCTION IF NOT EXISTS [ON CLUSTER]CREATE->CREATE OR REPLACEnormalization) -> skip without any query, soCREATE FUNCTION/DROP FUNCTIONgrants not required--rmoverwrites it with atomicCREATE OR REPLACE FUNCTION, same as tables and RBACrestoreProloguebeforeRestoreSchema, materialized views and tables which use UDF can be created on clean server (applies torestore,restore_remoteandrestore_remote --streaming)restore --dry-run/restore_remote --dry-runshowfunctionsmap withcreate,replace,keep_existing,skip_identicalTests
TestPlanFunctionsRestoreTestRestoreFunctionsKeepExisting: MV uses UDF, function changed and another dropped after backup, checkrestore_remote --dry-run, restore without--rmkeeps changed function and creates missing one before MV,--rmreplaces, restore by user withoutCREATE FUNCTION, DROP FUNCTIONgrants works when functions are identicalKnown limitation: comparison uses
system.functionsof local node only, withrestore_schema_on_clusterand withoutuser_defined_zookeeper_pathfunction identical locally but missing on other node is not created there🤖 Generated with Claude Code