Repository navigation
Fix #80429 Logical error: SQL user defined function ... must represent lambda expression - #80431
Merged
Merged
Conversation
Contributor
pufit
approved these changes
May 19, 2025
This was referenced Sep 29, 2026
clickgapai
pushed a commit
to clickgapai/ClickHouse
that referenced
this pull request
Oct 1, 2026
`RESTORE TABLE system.functions` registers every restored definition through `registerFunction`, whose `checkCanBeRegistered` runs `validateSQLFunction`, the check for a new `CREATE FUNCTION`. Each time that check was tightened, definitions stored under the older rules became unrestorable, and the first of them aborted the whole restore: - ClickHouse#80431 (25.6) requires the argument list to be a `tuple`, so a backup taken on 25.5 or earlier that holds `CREATE FUNCTION f AS lambda(identity(x), x)` fails on 25.6 and later with `Lambda must have valid arguments`. - ClickHouse#120483 (master) requires the core to be a `lambda` and the tuple to have no parameters, so a Cloud upgrade from 26.4 failed with `Expected lambda expression, got: JSONExtractString((x, y), x): While restoring data of table system.functions`: ClickHouse#120483 (comment) Loading the same definitions from disk or Keeper at startup never validates them, so an in-place upgrade keeps them and `BACKUP` writes them out unchanged. `restore` now passes `is_restore`, and `validateSQLFunction` then skips exactly those two rules. The structural rules stay (the core is a function with two arguments, the argument list holds unique identifiers, the body exists, no self-recursion): no version accepted a definition that fails them, and the DDL expansion in `UserDefinedSQLFunctionVisitor::tryToReplaceFunction` relies on them without checks. `CREATE FUNCTION` is unchanged. Tables are re-created by `RESTORE` under `LoadingStrictnessLevel::SECONDARY_CREATE`, which skips some sanity checks for the same reason. The new backward-compatibility test creates three such definitions and a control on 25.3, backs them up, upgrades, and restores; it fails on master and on 26.9.1.1629 at the first restore. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Changelog category (leave one):
This closes #80429.