Skip to content

GA Nullable(Tuple(...)) - #119222

Merged
nihalzp merged 48 commits into
ClickHouse:masterfrom
nihalzp:nullable-tuple-ga
Sep 15, 2026
Merged

nihalzp merged 48 commits into
ClickHouse:masterfrom
nihalzp:nullable-tuple-ga

Conversation

@nihalzp

@nihalzp nihalzp commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Related: #89643
Related: #107754
Related: #52562

Nullable(Tuple(...)) has been available since 26.1 and Beta since 26.6. This makes it generally available: allow_experimental_nullable_tuple_type (alias enable_nullable_tuple_type) and allow_nullable_tuple_in_extracted_subcolumns are enabled by default and move to the production tier.

Changelog category (leave one):

  • Backward Incompatible Change

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

Nullable(Tuple(...)) is now generally available and enabled by default. Nullable(Tuple(...)) columns can be created without any setting, schema inference of nullable structs in the Parquet, Arrow, ORC, Avro and JSON formats returns Nullable(Tuple(...)), and a Tuple subcolumn extracted from a Variant, Dynamic, JSON or Nullable(Tuple) column is Nullable(Tuple(...)) and NULL where the value is missing, instead of a tuple of default values. The previous behavior is available with enable_nullable_tuple_type = 0 and allow_nullable_tuple_in_extracted_subcolumns = 0; the subcolumn setting is read at server startup, so it has to be set in the default profile. Upgrading existing tables whose partition keys, sorting keys, TTL expressions, or skip indexes depend on a tuple subcolumn extracted from a Dynamic, Variant or Nullable(Tuple) column or from a JSON path not declared as Tuple(...) is unsafe with the new default: tables may fail to attach, queries may fail, or data parts may be detached during startup. Before the first startup after upgrading, set allow_nullable_tuple_in_extracted_subcolumns = 0 in the default profile, or preserve the previous behavior through compatibility in that profile. Changing the setting after parts have been detached does not restore them automatically; those parts must also be reattached.


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

@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [32a2ea7]

Summary: ✅


AI Review

Summary

This PR makes Nullable(Tuple(...)) generally available and default-on, flips extracted tuple subcolumns to the default nullable/NULL semantics, and then fixes the resulting fallout in schema inference (ArrowFlight, BigQuery) and ORC subcolumn/filter pushdown. The code paths I checked now line up with that contract and the new tests cover the main behavior changes, but the branch still leaves the published generated English reference pages on the pre-GA contract.

Findings

⚠️ Majors

  • [src/Core/Settings.cpp:8839] [dismissed by author -- https://github.com/GA Nullable(Tuple(...)) #119222#discussion_r4004796216] The source-of-truth registrations now say enable_nullable_tuple_type is GA/default 1 and allow_nullable_tuple_in_extracted_subcolumns is default 1, but the checked-in generated pages under docs/reference/ still document the opposite: docs/reference/settings/session-settings/allow-experimental.mdx:240 keeps allow_experimental_nullable_tuple_type as Beta/default 0, docs/reference/settings/beta-and-experimental-features.mdx:55 still lists it as a Beta feature, docs/reference/settings/session-settings/allow.mdx:273 keeps the extracted-subcolumn setting at default 0, docs/reference/data-types/tuple.mdx:182 and docs/reference/data-types/nullable.mdx:12 still require SET enable_nullable_tuple_type = 1, and the generated BigQuery pages at docs/reference/functions/table-functions/bigquery.mdx:82 and docs/reference/engines/table-engines/integrations/bigquery.mdx:28 still say persistent tables need that setting. Until those generated reference pages are regenerated from the updated source registrations, the 26.9 docs shipped from this tree describe the wrong defaults and GA state. Suggested fix: regenerate/update the affected docs/reference pages from the modified source registrations, or land the dedicated docs-autogen follow-up before merge.
Final Verdict

Status: ⚠️ Request changes

  • Regenerate/update the affected published English docs/reference pages so they stop advertising the pre-GA/default-off Nullable(Tuple(...)) and BigQuery behavior.

LLVM Coverage Report

Measured on commit 32a2ea7.

Metric Baseline Current Δ
Lines 89.10% 89.10% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 81.50% 81.50% +0.00%

Changed lines: Changed C/C++ lines covered: 214/225 (95.11%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Sep 10, 2026
@nihalzp
nihalzp requested a review from Avogar September 10, 2026 13:11
@clickhouse-gh clickhouse-gh Bot added the comp-datatype-wrapper Type modifiers/wrappers (Nullable, LowCardinality, etc.). label Sep 10, 2026
@alexey-milovidov alexey-milovidov self-assigned this Sep 12, 2026
alexey-milovidov and others added 3 commits September 12, 2026 13:40
Resolved conflicts:
- `src/Core/SettingsChangesHistory.cpp`: kept both the GA default flips for
  `allow_experimental_nullable_tuple_type`, `enable_nullable_tuple_type` and
  `allow_nullable_tuple_in_extracted_subcolumns` and master's new 26.9 entries.
- `src/DataTypes/DataTypeNullable.cpp`, `src/DataTypes/DataTypeTuple.cpp`: master
  rewrote the beta notes from `:::note` to `<Note>`; this branch removes those notes
  entirely, so the removal wins.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…r versions

The Kafka Connect page said the multi-message union schema is supported from
`26.9`, while the section heading and the inline comments in the snippet still
described it as unsupported. Scope both to the versions where the restriction
actually applies.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`allow_nullable_tuple_in_extracted_subcolumns` is read from the global context,
which a gtest does not have by default, so the two tests updated for the GA
defaults read the setting as off and failed. Establish the shared test context so
the shipped default applies, which is what these tests are meant to pin.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Comment thread src/Core/Settings.cpp Resolved
nihalzp and others added 5 commits September 14, 2026 07:52
`05216_orc_nested_null_as_default_pushdown` issues about 1900 queries and
`05214_orc_nullable_set_filter_pushdown` started 112 client processes, one
per query. In the normal phase they take 80-90 s on sanitizer builds, and
the flaky check, which reruns a new test five times on a debug or sanitizer
server, killed `05216` at the 600 s hard timeout and reported `05215` as
running too long (> 180 s) in every flaky-check job.

The cases of `05215` and `05216` are independent, so each `run_case` now
runs in the background writing to its own file under `CLICKHOUSE_TMP`, and
the outputs are printed in the original order after `wait`. `05214` batches
all predicates of a column into one client run and prints the label from
the query itself (`TSVRaw` keeps the quotes in `tupleElement(t, 'x')`
unescaped). References are unchanged.

Local timing with a release build: `05216` 8.8 s -> 1.4 s,
`05214` 7.7 s -> 1.1 s, `05215` 2.3 s -> 0.8 s.

CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119222&sha=78bbd4423ee14a6d65dd88932933007a9e9e9ca6&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29
PR: ClickHouse#119222

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

Copy link
Copy Markdown
Member

🕵 Status after b16d2cf (merged master, 120 commits, clean; one commit on top) - the author has since merged master again in a3023d9, which resolves the Settings.cpp conflict with #119056 (primary name enable_nullable_tuple_type, alias allow_experimental_nullable_tuple_type) identically to my local resolution, so I pushed nothing further.

  • The only reds were the five Stateless tests (*, flaky check) jobs: 05216_orc_nested_null_as_default_pushdown was killed at the 600 s hard timeout and 05215_orc_relaxed_filter_pushdown exceeded the 180 s flaky-check limit. 05216 issues about 1900 queries and 05214_orc_nullable_set_filter_pushdown started 112 client processes, which takes 80-90 s in the normal phase on sanitizer builds; the flaky check reruns each new test five times on a debug or sanitizer server. The cases of 05215/05216 are independent, so each run_case now runs in the background into its own file under CLICKHOUSE_TMP and the outputs are printed in the original order after wait; 05214 batches all predicates of a column into one client run (TSVRaw keeps the label quotes unescaped). References are unchanged. Local timing with a release build: 05216 8.8 s -> 1.4 s, 05214 7.7 s -> 1.1 s, 05215 2.3 s -> 0.8 s.
  • Verified with a build of the merged branch: 05212-05216, 05210, 05166, 04707, 04652/04653 nullable tuple tests, 04356/03918 setting tests, 02149_schema_inference_formats_with_schema_{1,2,3}, 02242, 02293, and the Arrow/Avro nullable tuple schema inference tests all pass.

Comment thread src/Core/Settings.cpp
Always ignore ON CLUSTER clause for DDL queries with replicated databases.
)", 0) \
DECLARE_WITH_ALIAS(Bool, enable_nullable_tuple_type, false, R"(
DECLARE_WITH_ALIAS(Bool, enable_nullable_tuple_type, true, R"(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source-of-truth docs change here, but the generated English reference pages are still on the pre-GA contract. In the current tree, docs/reference/settings/session-settings/allow-experimental.mdx still shows allow_experimental_nullable_tuple_type as Beta with default 0, docs/reference/settings/beta-and-experimental-features.mdx still lists it, docs/reference/settings/session-settings/allow.mdx still shows allow_nullable_tuple_in_extracted_subcolumns default 0, docs/reference/data-types/tuple.mdx and docs/reference/data-types/nullable.mdx still require SET enable_nullable_tuple_type = 1, and the generated BigQuery engine/table-function pages still say persistent tables require that setting. Since /docs/reference is the published English docs, the PR currently ships GA/default-on behavior while documenting the opposite. Please regenerate/update the affected reference pages from the updated source registrations before merge.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regeneration happens through the dedicated docs autogeneration workflow, not in feature PRs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵 Confirming the author's answer with the tree at 32a2ea7: every location this finding cites lies between the {/*AUTOGENERATED_START*/} and {/*AUTOGENERATED_END*/} markers of its page (allow-experimental.mdx 9-373, beta-and-experimental-features.mdx 54-223, allow.mdx 9-395, data-types/tuple.mdx 9-216, data-types/nullable.mdx 9-78, both bigquery.mdx pages 9-152 / 9-58). Those regions are regenerated by the dedicated docs autogeneration workflow; feature PRs must not edit them (the docs check fails without the pr-autogenerated-docs label). The sources of truth are all updated in this PR: the DECLARE doc strings in src/Core/Settings.cpp (default true, tier 0), the Nullable/Tuple type docs in src/DataTypes/DataTypeNullable.cpp / DataTypeTuple.cpp (Beta notes and SET enable_nullable_tuple_type = 1 removed), and the BigQuery engine and table function docs in src/Storages/BigQuery/StorageBigQuery.cpp / src/TableFunctions/TableFunctionBigQuery.cpp (the "requires the setting" sentences removed). Nothing else to change here.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Status on 32a2ea7 (the author's head; nothing to push from my side, the branch is 230 commits behind master but merges cleanly and is MERGEABLE):

@nihalzp
nihalzp added this pull request to the merge queue Sep 15, 2026
Merged via the queue into ClickHouse:master with commit 38170d8 Sep 15, 2026
348 of 349 checks passed
@nihalzp
nihalzp deleted the nullable-tuple-ga branch September 15, 2026 03:57
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 15, 2026
huldarchen pushed a commit to huldarchen/ClickHouse that referenced this pull request Sep 19, 2026
…criminators

For a Variant/Dynamic/JSON element that is a tuple, the null map of a Nullable
field of that element returned 0 on every row holding a different alternative,
although the field itself reads NULL there. Since optimize_functions_to_subcolumns
is enabled by default and rewrites isNull(x) to x.null, a plain

    SELECT count() FROM t WHERE value.`Tuple(a Nullable(UInt32), b String)`.a IS NULL

silently dropped the matching rows: 1 instead of 2 on a three-row merged part.

SerializationVariantElement fills rows whose discriminator is not the element's
with the result column's default. For the value read that default IS NULL, so it
is correct; a null map is a bare UInt8 whose default 0 means "not null", which
makes it the one subcolumn whose value for an absent element is not its default.
Nothing on the path could distinguish the two: SerializationVariant::enumerate
Streams attaches one subcolumn creator per alternative, while the selection
happens per subcolumn beneath it, and ISerialization::createFromPath hands a
creator only the selected subcolumn's (serialization, type, column) - where a
null map's type is plain UInt8, indistinguishable from a genuine UInt8 element.
prev_type, which ClickHouse#112338 used to derive nullable_added_by_extraction, therefore
carries one bit too few for this case.

So ISubcolumnCreator gains one virtual with a default no-op,
specializeForSelectedSubcolumn, which names the selected substream to the
enclosing creators. VariantSubcolumnCreator uses it to learn that the selection
is a null map and then writes 1 for absent rows at all four read sites and in
both in-memory creator paths. SerializationVariantElementNullMap already does
exactly this for the top-level x.<Elem>.null, and cannot serve the nested case
because all three of its create() overloads discard prev and would throw away
the field's own on-disk null map. Nine of the ten creators inherit the no-op.
createFromPath and makeSubcolumnInfo also pass the true selected terminal, since
on the dynamically-resolved-descendant arm the leaf lives in the nested path and
path[prefix_len - 1] is only the prefix the dynamic type matched.

Two guards keep the change to the case where the null map is the only place the
information can live: the extraction must not have wrapped the element in
Nullable, where absence is already NULL, and the selection must still be a bare
UInt8, since an Array or Map below has already made it Array(UInt8), whose value
for an absent element is the correct default []. That leaves the fix orthogonal
to ClickHouse#119222, which flips allow_nullable_tuple_in_extracted_subcolumns to true.

No on-disk or format change: the same streams are requested and only the value
written into rows where the element is absent changes. This is not a regression -
released 26.8.3.105 already returns 0 there; our ClickHouse#112338 removed a SIGSEGV on the
sibling value read, which is what makes the contradiction observable and puts the
IS NULL rewrite on a completing path.

Closes: ClickHouse#119935

Co-Authored-By: Claude Opus 5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 25, 2026
ClickHouse#119222 made schema inference wrap a `Tuple` read from an Arrow struct in
`Nullable`, and dropped the multi-line spelling for it, so the `nested` row of
`DESC file(..., Arrow)` now reads `Nullable(Tuple(v Variant(Bool, Int8)))`.

Measured, not assumed: the master snapshot binary (which does not carry this
branch) prints the new line for the same fixture, and the full DESC output of
that binary and of this branch is byte-identical, so nothing here touches
schema inference. The `struct_utf8` row is unaffected because ClickHouse#119222 keeps a
`Tuple` alternative of a `Variant` non-`Nullable`.
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Oct 4, 2026
Since ClickHouse#119222 `enable_nullable_tuple_type` defaults to 1, so schema
inference takes the relaxed Nullable(Tuple) path of this branch for every
OPTIONAL struct in the parquet corpus.

00900_long_parquet_load_2: struct-level NULLs in nullable.impala.parquet
(nested_struct for id 6, C for id 5, map values g3 and H) were read as
tuples of element defaults and are now NULL, which is what pyarrow reads
from the same file. The other two moved lines are the WITH TOTALS rows,
whose default for a Nullable(Tuple) column is NULL. The master debug
binary reproduces the old reference byte for byte, so nothing else in the
corpus moves.

04065_parquet_optional_list_map_wrapper_nullable_tuple: the "inference
off" case relied on the old default; it now disables the setting itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-datatype-wrapper Type modifiers/wrappers (Nullable, LowCardinality, etc.). pr-backward-incompatible Pull request with backwards incompatible changes pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants