Repository navigation
Backport #101793 to 26.6: Fix ALTER TABLE MODIFY TTL with DateTime causing data loss on 32-bit overflow - #119003
Merged
Merged
Conversation
…using data loss on 32-bit overflow
Contributor
|
Workflow [BackportPR], commit [55f820c] Summary: ✅ |
The backport dropped the master-only `required_source_columns` out-parameter of `buildExpressionAndSets`, but this call site passed it positionally as `nullptr`, so it was left with one argument too many. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…xpression
`04077_datetime32_overflow` fails on this backport in case 12
(`MODIFY TTL ts + INTERVAL 1 DAY DELETE WHERE toTypeName(ts) =
'DateTime'`) with:
Code: 47. DB::Exception: Missing columns: 'ts' while processing:
'toTypeName(ts) = 'DateTime'', required columns: 'ts', no source columns.
(UNKNOWN_IDENTIFIER)
A stored TTL is an AST plus the list of columns it needs, and the pair
is rebuilt on every `INSERT`, every merge and every table load. On
this branch that list is taken from the *built* expression via
`ExpressionActions::getRequiredColumnsWithTypes`, so constant folding
drops columns the AST still refers to: `toTypeName(ts)` folds to a
literal, the stored column list comes out empty, and the next rebuild
of the same AST cannot resolve `ts` any more.
`master` and `26.8` do not have this problem because they take the
list from the syntax analysis, which sees the AST before folding. That
change landed on `master` in `f0bf4fce55ed` ("Keep a TTL expression
rebuildable and loadable"), which is not in this branch, so the
backported test exercises a code path the backport had no fix for.
This is the same adaptation already merged into `26.7` as
`96b9965489c4`, applied verbatim. Only the `required_source_columns`
part of the `master` commit is taken - the part this backport depends
on; its unrelated half (pinning `Variant` / `Dynamic` type-mismatch
strictness through `TypeMismatchStrictness`) is deliberately left out
of a bug-fix backport.
Because the timestamp expression is analyzed against widened
(`Date32` / `DateTime64`) columns, the reported list is mapped back to
the table's original narrow types, so it stays a subset of the columns
the caller passed and every later rebuild widens them again from the
real table types. Subcolumn names reported by the analysis (e.g.
`j.ts` of a `JSON` column) are kept as reported;
`04847_ttl_where_json_subcolumn` covers that path and is added along
with the mechanism it needs.
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.
Original pull-request #101793
Cherry-pick pull-request #117985
This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.
The PR source
The PR is created in the CI job
Version info
26.6.6.8