Skip to content

Support DEFAULT expressions inside Tuple data types - #108090

Open
alexey-milovidov wants to merge 109 commits into
masterfrom
default-expression-in-tuple
Open

alexey-milovidov wants to merge 109 commits into
masterfrom
default-expression-in-tuple

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jun 22, 2026 •

Copy link
Copy Markdown
Member

Related: #2797

DEFAULT expressions are now supported for named elements of Tuple data types, e.g.:

CREATE TABLE t (id UInt8, c Tuple(a UInt8, s String DEFAULT 'Hello')) ENGINE = MergeTree ORDER BY id;

Such defaults exist only at the syntax level: they are pulled up to the column level (for CREATE TABLE as well as ALTER TABLE ... ADD COLUMN / MODIFY COLUMN), so the stored schema is normalized without any DEFAULT inside the data type. The column above is stored as type Tuple(a UInt8, s String) with a column-level DEFAULT tuple(defaultValueOfTypeName('UInt8'), 'Hello').

A default expression may reference other columns, but not other elements of the same tuple/nested; a reference that collides with an element name is rejected as ambiguous. Building an actual data type while a default is set throws.

DEFAULT inside Nested (which is Array(Tuple(...))) or Array is not supported yet and is rejected with a clear NOT_IMPLEMENTED error, because a scalar element default cannot be represented as a static array column default. Note this is why issue #2797 (which asks specifically for DEFAULT on Nested elements) is linked as Related rather than Closes.

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Support DEFAULT expressions inside Tuple data types, e.g. Tuple(a UInt8, s String DEFAULT 'Hello'). The default is normalized away from the type and pulled up to the column level. Works for CREATE TABLE and ALTER TABLE ... ADD/MODIFY COLUMN.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/108090]


Workflow [PR]
Sync PR [sync-upstream/pr/108090]

Allow `DEFAULT` expressions for named elements of `Tuple` data types,
e.g. `Tuple(a UInt8, s String DEFAULT 'Hello')`. Such defaults exist only
at the syntax level: they are pulled up to the column level in
`InterpreterCreateQuery`, so the stored type is normalized without any
`DEFAULT` inside it. The example above becomes type `Tuple(a UInt8, s String)`
with a column-level `DEFAULT tuple(defaultValueOfTypeName('UInt8'), 'Hello')`.

A default expression may reference other columns, but not other elements of
the same tuple/nested; a reference that collides with an element name is
rejected as ambiguous. Building an actual data type while a default is set
throws.

`DEFAULT` inside `Nested` (which is `Array(Tuple(...))`) or `Array` is not
supported yet and is rejected with a clear error, because a scalar element
default cannot be represented as a static array column default.

Closes: #2797

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e4ecff3]

Summary: ❌

job_name test_name status info comment
Fast test FAIL
05325_tuple_element_default_on_cluster_old_ddl_format FAIL cidb
05024_tuple_element_default_time_series_on_cluster FAIL cidb
Code Review DROPPED
Fast test (arm_darwin) DROPPED
Build (amd_debug) DROPPED
Build (amd_asan_ubsan) DROPPED
Build (amd_tsan) DROPPED
Build (amd_msan) DROPPED
Build (amd_binary) DROPPED
Build (arm_debug) DROPPED
Build (arm_asan_ubsan) DROPPED

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Jun 22, 2026
alexey-milovidov and others added 3 commits June 29, 2026 00:06
The PR adds a New Feature (DEFAULT expressions for named Tuple elements),
which the CI `feature_docs.py` hook requires to be documented. Add a
`DEFAULT expressions for Tuple elements` section to the Tuple data type
docs describing the normalization (defaults pulled up to the column level),
the restriction against referencing sibling elements, and the
`NOT_IMPLEMENTED` rejection for `Nested`/`Array`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Addresses review feedback on #108090.

`DEFAULT` expressions written inside `Tuple` data types were normalized only on
the `CREATE TABLE` path. `ALTER TABLE ... ADD COLUMN` and `MODIFY COLUMN` parse
the same `ASTColumnDeclaration` but build the data type directly via
`DataTypeFactory::get`, so `DataTypeTuple::create` saw the embedded
`ASTNameTypePair::default_expression` and threw before any normalization ran. As
a result `ALTER TABLE t ADD COLUMN c Tuple(a UInt8 DEFAULT 1)` was rejected
instead of being normalized to a column-level `DEFAULT tuple(1)`.

Extract the pull-up normalization out of `InterpreterCreateQuery` into a shared
free function `pullUpTupleElementDefaults` and call it from `AlterCommand::parse`
for `ADD COLUMN` and `MODIFY COLUMN` before the data type is built, so all paths
normalize identically. The clone owned by `command.ast` is normalized in place so
the extracted type, the extracted default, and the stored AST all agree.

Extend `04402_default_inside_tuple` with focused `ALTER ADD COLUMN` / `MODIFY
COLUMN` coverage, including `system.columns` checks that the type is stripped and
the column-level `DEFAULT` is stored, and that `DEFAULT` inside `Nested`/`Array`
is rejected with `NOT_IMPLEMENTED` on the ALTER path too.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
alexey-milovidov and others added 3 commits June 29, 2026 21:15
…mbiguity check lambda-scope-aware

Two follow-ups for the AI review of #108090:

* `Nullable(Tuple(...))` is a supported tuple wrapper (behind
  `enable_nullable_tuple_type`), and a `DEFAULT` inside it is representable as
  the same column-level `tuple(...)` default that is then cast to the nullable
  tuple type. `buildAndStripTupleDefaults` now recurses through `Nullable`
  instead of rejecting it as `NOT_IMPLEMENTED`. If the setting is off, the
  `Nullable(Tuple)` type itself is still rejected later during type validation.

* `collectReferencedIdentifiers` treated every `ASTIdentifier` under a default
  expression as an external reference, so a lambda whose parameter is named like
  a tuple element (e.g. `Tuple(x UInt8, y Array(UInt8) DEFAULT arrayMap(x -> x + 1, [1, 2, 3]))`)
  was wrongly rejected as ambiguous. The walk is now lambda-scope-aware: it skips
  the parameter tuple, ignores identifiers bound by the lambda while walking its
  body, and still collects free identifiers from the body.

Added stateless coverage for both: a `Nullable(Tuple(... DEFAULT ...))` column,
a lambda parameter shadowing an element name, and a free identifier in a lambda
body that collides with an element name and is still rejected. Documentation
updated accordingly. The test is renumbered to avoid collision with tests added
on master.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…mbiguity check lambda-scope-aware

Two follow-ups for the AI review of #108090:

* `Nullable(Tuple(...))` is a supported tuple wrapper (behind
  `enable_nullable_tuple_type`), and a `DEFAULT` inside it is representable as
  the same column-level `tuple(...)` default that is then cast to the nullable
  tuple type. `buildAndStripTupleDefaults` now recurses through `Nullable`
  instead of rejecting it as `NOT_IMPLEMENTED`. If the setting is off, the
  `Nullable(Tuple)` type itself is still rejected later during type validation.

* `collectReferencedIdentifiers` treated every `ASTIdentifier` under a default
  expression as an external reference, so a lambda whose parameter is named like
  a tuple element (e.g. `Tuple(x UInt8, y Array(UInt8) DEFAULT arrayMap(x -> x + 1, [1, 2, 3]))`)
  was wrongly rejected as ambiguous. The walk is now lambda-scope-aware: it skips
  the parameter tuple, ignores identifiers bound by the lambda while walking its
  body, and still collects free identifiers from the body.

Added stateless coverage for both: a `Nullable(Tuple(... DEFAULT ...))` column,
a lambda parameter shadowing an element name, and a free identifier in a lambda
body that collides with an element name and is still rejected. Documentation
updated accordingly. The test is renumbered to avoid collision with tests added
on master.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Addressed the two AI-review majors (pushed in 4c2d17d, on top of a fresh master merge):

  • Nullable(Tuple(... DEFAULT ...)) is now supported: buildAndStripTupleDefaults recurses through the transparent Nullable wrapper and pulls the default up as the same column-level tuple(...), which is cast to the nullable tuple type. When enable_nullable_tuple_type is off, the Nullable(Tuple) type itself is still rejected later during type validation, so no fallback was introduced.
  • The ambiguity check is now lambda-scope-aware: collectReferencedIdentifiers skips the lambda parameter tuple(...), binds the parameters while walking the body, and still collects free identifiers. So a default like Tuple(x UInt8, y Array(UInt8) DEFAULT arrayMap(x -> x + 1, [1, 2, 3])) is accepted, while a free identifier in the body that collides with an element name (e.g. arrayMap(z -> z + a, [1]) where a is an element) is still rejected.

Added focused stateless coverage in 04489_default_inside_tuple (Nullable(Tuple) default, lambda parameter shadowing an element name, and a colliding free identifier) and documented both in docs/en/sql-reference/data-types/tuple.md. The test was renumbered 04402 → 04489 to avoid collision with tests added on master.

Verification: the changed TU compiles cleanly under the project's -Werror build; the produced normalized forms (tuple(defaultValueOfTypeName('UInt8'), 'Hi') cast to Nullable(Tuple(...)), and arrayMap(x -> (x + 1), ...)) were confirmed to evaluate to (0,'Hi') and (0,[2,3,4]) on a stock 26.7 binary.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Status (continue-pr shepherding pass):

  • AI Review: ✅ Approve, no unresolved findings. All three inline review threads (ALTER ADD/MODIFY normalization, Nullable(Tuple(... DEFAULT ...)), lambda-scope-aware ambiguity check) are resolved. No new reviewer feedback since 4c2d17d3.
  • Diff is intact (13 files), changed-line coverage 92.23%, test 04489_default_inside_tuple filename is unique on master.

The sole CI red is not a regression:

  • Stateless tests (amd_tsan, s3 storage, parallel, 2/2) → 03095_group_by_server_constants_bug failed once with UNEXPECTED_PACKET_FROM_SERVER (expected TablesStatusResponse, got ProfileInfo) on SELECT serverUUID() AS s, count() FROM remote('127.0.0.{1,2}', system.one) GROUP BY s. All reruns passed — CI flagged it non-reproducible.
  • This is a transient distributed-connection race. CIDB shows the same test flaking on unrelated PRs (Fix undefined behaviour when reading query state from native protocol #101972, Native Common Virtuals for Buffer #101537) over the last 90 days, and this PR touches no connection/distributed/protocol code (only the parser, pullUpTupleElementDefaults, InterpreterCreateQuery, AlterCommands, DataTypeTuple, docs, and the test).

No master re-merge: merge-base is ~1 day old and there are no conflicts, so a merge would not change the flake. PR is MERGEABLE; blocked only on a human approving review.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Status (continue-pr shepherding pass):

  • Re-ran the one failed CI job (Stateless tests (amd_tsan, s3 storage, parallel, 2/2), run 28403882859) to clear a misleading ❌ in the summary.
  • That job's sole failure is 03095_group_by_server_constants_bug, which the CI's own in-job reruns already marked not reproducible ("All reruns passed. The failure is not reproducible (likely a transient issue)"). The error is UNEXPECTED_PACKET_FROM_SERVER (expected TablesStatusResponse, got ProfileInfo) on SELECT serverUUID() AS s, count() FROM remote('127.0.0.{1,2}', system.one) GROUP BY s — the pooled-connection desync class addressed by Fix flaky distributed query "Unexpected packet from server (expected TablesStatusResponse, got ProfileInfo)" #108854, unrelated to this PR (which touches only the parser, pullUpTupleElementDefaults, InterpreterCreateQuery, AlterCommands, DataTypeTuple/Nested, docs, and the test).
  • AI Review: ✅ Approve, no unresolved findings. All three inline review threads are resolved.
  • PR is MERGEABLE; the only remaining gate is a human approving review.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Status (continue-pr shepherding pass): the only non-green check is CH Inc sync (description tests failed), whose private sync PR is clickhouse-private#61720. Its two reds are both flaky/infra and unrelated to this PR (which touches only the parser, pullUpTupleElementDefaults, InterpreterCreateQuery, AlterCommands, DataTypeTuple/DataTypeNested, docs, and the stateless test — nothing touching refreshable MVs, ZooKeeper, SharedCatalog, distributed/connection code, or hung-check logic):

  • Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/7) → test_refreshable_mv_no_multi_read::test_refreshable_mv_attach_without_multi_read: Failed connecting to Zookeeper within the connection retry policy / Connection refused, so the materialized view stayed Scheduled instead of becoming Disabled (assert 'Disabled' in 'Scheduled\t\n'). A ZooKeeper-connection infra flake.
  • Stress test (arm_asan_ubsan, SharedCatalog, meta in keeper) → Hung check failed, possible deadlock found, which the private CI itself auto-marked flaky: Marking 'Hung check failed, possible deadlock found' as flaky (matched ... issue: #107941). The exception stacks in the report (Unknown table expression identifier 'tab', Disk ... is not allowed for backups, Unknown table engine Shared) are AST-fuzzer noise.

Re-ran both failed sync jobs (private run 28408164251, --failed). Public CI is green, AI Review: ✅ Approve, no unresolved findings, and the PR is MERGEABLE; the remaining gate is a human approving review.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Status (continue-pr shepherding pass): the reruns of the two private CH Inc sync jobs triggered in the previous pass have completed, and CH Inc sync is now green. The PR is therefore fully green on head 4c2d17d3:

  • All required checks are SUCCESS (Style check, Mergeable Check, PR, CH Inc sync); every one of the 100 check-runs on this commit completed with no failures and nothing in progress.
  • AI Review: ✅ Approve, no unresolved findings. All three inline review threads (ALTER ADD/MODIFY normalization, Nullable(Tuple(... DEFAULT ...)), lambda-scope-aware ambiguity check) are resolved, and there is no new reviewer feedback since 4c2d17d3.
  • mergeable is MERGEABLE / CLEAN.

No master re-merge: the merge-base is ~1.5 days old (well under a week), CI is green, and there are no conflicts. Master's only touch to a file this PR changes is src/Storages/AlterCommands.cpp (the unrelated ALTER TABLE ... MODIFY CONSTRAINT path), and GitHub reports the merge as clean, so a re-merge would not change anything.

The only remaining gate is a human approving review.

@mintlify

mintlify Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Nov 24, 2026, 2:13 PM

Comment thread src/Parsers/ParserDataType.cpp Resolved
Comment thread src/Parsers/ParserDataType.cpp Resolved
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The Stress test (arm_release) failure on 13824dd ("Cannot start clickhouse-server": Part all_5_6_1_0 intersects previous part all_1_5_4_1 and the transaction metadata of at least one of them could not be read for test_3.t_plt_evict_reinsert) is unrelated to this PR — it is the known part_loading_tree_rollback test issue on object-storage disks, fixed by #110999 (in progress).

…g the column type

`fuzzQuery` calls `DataTypeFactory::get` on the raw column type AST in
`QueryFuzzer::fuzzColumnDeclaration`, before `pullUpTupleElementDefaults`
normalization ever runs, so a valid query like
`CREATE TABLE t (c Tuple(a UInt8 DEFAULT 1)) ENGINE = Memory` threw
`BAD_ARGUMENTS` from the `DataTypeTuple::create` fail-safe instead of
being fuzzed. Strip `ASTNameTypePair::default_expression` there the same
way as the main DDL paths, and add a `fuzzQuery` regression test.

Addresses the AI review finding on #108090

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The BuzzHouse (arm_asan_ubsan) failure on 313adf0 (Logical error: Not-ready Set is passed as the second argument for function 'in') is unrelated to this PR — it is the known fuzzer issue tracked in #107619 (same failure signature, STID group 0250-*). The error occurs during query execution (PullingAsyncPipelineExecutor), while this PR only touches parsing and CREATE/ALTER normalization of tuple element defaults. A fix is in progress: #109722 (re-land of #107924).

Related: #107619

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Two more CI failures on 313adf07, both unrelated to this PR:

The remaining BuzzHouse (arm_asan_ubsan) red is the known Not-ready Set issue #107619, already noted above.

…ma for tuple-element defaults

`AlterCommands::prepare` ignores `RENAME COLUMN IF EXISTS`, `DROP COLUMN IF EXISTS`
and `ADD COLUMN IF NOT EXISTS` by checking the columns of the table before the
query, and `AlterCommand::apply` then checks again against the columns so far
(for `DROP COLUMN IF EXISTS`, only an exact column name, not a flattened `Nested`
group). The simulated schema that tells an independent dotted column from a
subcolumn checked only the columns so far, so a rename of a column added by the
same query could invent an independent column, and a skipped drop could remove one.
Apply both checks, as execution does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: the CH Inc sync check is red because of Stress test (amd_msan, SharedCatalog, meta in keeper) in https://github.com/ClickHouse/clickhouse-private/pull/61720 (https://github.com/ClickHouse/clickhouse-private/actions/runs/42112109244/job/127557731818): Logical error: 'new_hint->structureEquals(*info)' in updateSerializationHintsForPart from MergeTreeData::Transaction::tryCommit / StorageSharedMergeTree::addCurrentPart. It looks like the ALTER / serialization-hints race addressed by #114019. Please provide a fix in a separate PR. If the fix is already in progress, link it here.

@groeneai

groeneai commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

The fix is in progress: #114019 (open, mergeable, no review yet).

It is the same race: ALTER publishes the new column types first and rebuilds the table's serialization hints only afterwards, so a part committed in between (addCurrentPart here) adds its serialization info to a hint still built for the old type. #114019 builds the new hints first and publishes them together with the new metadata under one parts_lock, which the part commit also takes. It changes the ALTER paths of StorageMergeTree and StorageReplicatedMergeTree.

StorageSharedMergeTree is not in this repository, so #114019 cannot change its ALTER apply: after the sync it needs the same switch to setPropertiesAndResetSerializationHints, otherwise this assertion will keep firing there.

It is not caused by this PR: the same assertion also fired in public CI on two unrelated PRs, e.g. Stress test (arm_asan_ubsan).

alexey-milovidov and others added 2 commits November 9, 2026 02:01
…mmands in tuple-element defaults

An `ALTER` query runs as segments of consecutive commands of the same kind, and
`runCommandSegments` calls `AlterCommands::prepare` for each segment of
`AlterCommands` with the metadata committed by the preceding segments. A mutation
between the commands therefore makes a column added before it count as existing for
a later `RENAME COLUMN IF EXISTS` or `DROP COLUMN IF EXISTS`. The simulated schema in
`pullUpTupleElementDefaultsInAlterQuery` used the columns from before the whole query
instead, so it could reject a valid reference to a dotted column as a self-reference,
or accept a reference to a column that the query drops.

Reset the starting columns at each segment boundary. `AlterCommand::isAlterCommand`
tells which commands go to `AlterCommands`; `AlterCommand::parse` asserts that it
agrees.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The Stress test (arm_debug) failure (Logical error: Inconsistent AST formatting on a CREATE TABLE ... ENGINE = TimeSeries produced by the AST fuzzer, report) is not related to this PR. The dumped original and re-parsed ASTs are identical, and only the order of the ViewTargets children differs. That order bug is being fixed in #128897. I merged master and addressed the open review thread.

…` as `no-replicated-database`

The test runs an `ALTER` query that has an `UPDATE` mutation between other
commands, because that is the case it checks. `Replicated` databases reject
`ALTER` queries that mix command types with `QUERY_IS_PROHIBITED`, so the test
always failed in the `DBReplicated` jobs.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=108090&sha=4d9a12e40e7c5a44438c99af1991d81d9381cc5f&name_0=PR
PR: #108090

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 2 commits November 11, 2026 12:28
… column type

A `DEFAULT` written inside a tuple element that references `c.<x>` from inside the
column `c` was rejected only if `<x>` was a subcolumn of the type as written. The type
is not final at that point: the `NULL` modifier or `data_type_default_nullable` may
wrap it in `Nullable` (adding the `null` subcolumn), and a later `MODIFY COLUMN` of the
same `ALTER` may change it while keeping the generated default. Such defaults were
accepted and failed on the first insert with `UNKNOWN_IDENTIFIER`.

Now `c.<x>` is a self-reference unless a table column has exactly this name (the exact
dotted-column precedence is preserved). A name that is neither a table column nor a
subcolumn cannot be resolved anyway, so no valid default is rejected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 2 commits November 13, 2026 15:19
…-name columns

A `DEFAULT` written inside a tuple element of the column `c` that referenced `c.n.x`
was rejected as a self-reference unless a table column was named exactly `c.n.x`,
although the name may be a subcolumn of another column with a dotted name, such as
`c.n Tuple(x UInt8)` or `c.a Array(UInt8)` (for `c.a.size0`).

Now such a name is resolved to its owning column: an exact column name still takes
precedence, then a table column named by a dot-delimited prefix longer than `c` owns it.
It is a self-reference if no other column owns it, or if `c` has a subcolumn with the
same name too (ambiguous ownership, resolved by column order in `ColumnsDescription`).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 2 commits November 15, 2026 11:07
… initiator lacks the table

An `ALTER TABLE ... ON CLUSTER` can be submitted from a host that does not have
the table. Then the initiator cannot tell whether `c.a` in a `DEFAULT` written
inside the tuple `c` is an independent column or a subcolumn of `c`, and it
rejected the query as a self-reference. Now such a declaration is left as
written, and each host normalizes it against its own table when it executes
the query. `data_type_default_nullable` wraps the type of such a declaration
in `Nullable` as written.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g dotted-name column

A default that references a subcolumn of another column with a dotted name
(`c.n.x` of the column `c.n`) failed with `UNKNOWN_IDENTIFIER` when `c.n` was
missing as well: `c.n` is computed by its own default under an alias, and an
identifier is bound to an alias by its first part only. Rewrite such a
reference as `getSubcolumn` of its column in `addDefaultRequiredExpressionsRecursively`.
This also makes the column a required column of the default when reading parts
that lack both columns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 3 commits November 18, 2026 21:30
…n rewriting subcolumn references in defaults

`replaceReferencesToSubcolumnsOfMissingColumns` treated every identifier of a
default expression as a column reference, so an identifier bound to a lambda
parameter (`arrayMap(x -> x.n.v, a)`) or to an expression alias
(`(1 AS `x.a`) + `x.a``) was rewritten into `getSubcolumn` of an unrelated
missing table column, silently changing the inserted values. A dotted lambda
parameter declaration was rewritten as well and failed with `TYPE_MISMATCH`.

Collect the aliases of the expression and the parameters of enclosing lambdas,
skip identifiers bound to them by their whole name or leading parts, and do not
rewrite lambda parameter declarations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After merging master, `DataTypeFactory::get` is `[[nodiscard]]`, and the build
failed with `-Wunused-result`. The call is made only to validate the type.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 3 commits November 21, 2026 16:14
…he insert column list

`replaceReferencesToSubcolumnsOfMissingColumns` looked up the owner of a
subcolumn reference with `ColumnsDescription::tryGetColumnOrSubcolumn`, which
returns whichever column registered the subcolumn name first. With
`` `x.n` Tuple(v UInt8) `` and `x Tuple(n Tuple(v UInt8))` in one table, the
reference `x.n.v` was rewritten to `getSubcolumn` of `x.n` when `x.n` was
omitted from the insert, while the analyzer bound it through `x` when `x.n`
was supplied. So the same default produced different values for different
insert column lists, also for column-level defaults that worked before.

The owner is now chosen the way the analyzer does it in
`TableExpressionData::tryGetSubcolumnInfo`: the shortest prefix naming a
physical column whose type has such a subcolumn. It depends neither on the
columns of the block nor on the order of the columns in the table.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The header uses `String` but relied on a transitive include through `Core/Names.h`, which no longer provides it on current master, so the Fast test build failed with "unknown type name 'String'".

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=108090&sha=3b195139ffcab3bf55296c454a96462766f655f5&name_0=PR&name_1=Fast%20test
#108090

Co-Authored-By: Claude Fable 5.2 <[email protected]>

This branch was successfully deployed

1 active deployment
staging - docs — e4ecff3a Deployed Nov 24, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-data-types Type system & core datatypes used across query planning/execution. pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard pr-feature Pull request with new product feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants