Repository navigation
Backport #101793 to 26.7: Fix ALTER TABLE MODIFY TTL with DateTime causing data loss on 32-bit overflow - #119004
Conversation
…using data loss on 32-bit overflow
07d4e8f to
9a7020f
Compare
|
Workflow [BackportPR], commit [96b9965] 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` failed 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 `26.7` that list was taken
from the *built* expression via `ExpressionActions::getRequiredColumnsWithTypes`,
so constant folding dropped 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 `f0bf4fce55edf6060e1c31509c75fb97ce0713c5` ("Keep a TTL expression rebuildable
and loadable"), which is not in `26.7`, so the backported test exercised a code path
the backport had no fix for.
Only the `required_source_columns` part of that commit is taken here - 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`
from the original pull request covers that path and is added along with the mechanism
it needs.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 The Root cause: on Pushed The same prerequisite is missing in #119003 ( |
Original pull-request #101793
Cherry-pick pull-request #117987
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.7.7.79