Skip to content

Fix fasttest exception in file inferred Nullable cols - #102509

Merged
alexey-milovidov merged 10 commits into
ClickHouse:masterfrom
rorylshanks:fix/fix-fastest-crash
Jul 25, 2026
Merged

alexey-milovidov merged 10 commits into
ClickHouse:masterfrom
rorylshanks:fix/fix-fastest-crash

Conversation

@rorylshanks

@rorylshanks rorylshanks commented Apr 12, 2026 •

Copy link
Copy Markdown
Contributor

Fix an exception in the COUNT(*) fast path for file(...) when the inferred schema wraps columns in Nullable: IDataType::getSubcolumn and IDataType::tryGetSubcolumn did not handle ColumnConst, so extracting a subcolumn from a constant column threw an exception. Now the constant is unwrapped, the subcolumn is extracted from the nested column, and the result is wrapped back into ColumnConst.

Note: the original end-to-end failure (#102044) is no longer reproducible on current master because the triggering code path changed, but IDataType::getSubcolumn/tryGetSubcolumn still lack the ColumnConst handling (while IDataType::getSerializationInfo already has it), so this remains a valid robustness fix, and the regression test pins the relevant settings to keep exercising this path. Since the misbehavior is not reproducible on master, the changelog category is set to Improvement rather than Bug Fix.

This fixes #102044

Changelog category (leave one):

  • Improvement

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

Handle ColumnConst in IDataType::getSubcolumn and IDataType::tryGetSubcolumn: the constant is unwrapped, the subcolumn is extracted from the nested column, and the result is wrapped back into ColumnConst. This prevents a potential exception in the COUNT(*) fast path for file(...) when the inferred schema wraps columns in Nullable. Closes #102044.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 20, 2026
@alexey-milovidov alexey-milovidov self-assigned this Jul 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a78907b]

Summary: ✅


AI Review

Summary

This PR fixes IDataType::getSubcolumn and IDataType::tryGetSubcolumn for ColumnConst inputs by unwrapping the nested column, extracting the requested subcolumn, and wrapping the result back into ColumnConst with the original row count. I reviewed the current diff, the prior discussion, and the added regression coverage; the previous review concerns are addressed, the focused gtest now exercises the exact new branches, and I did not find any remaining correctness, compatibility, or testing issues that warrant a new inline comment.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 20, 2026
alexey-milovidov and others added 2 commits July 20, 2026 23:46
… the regression test

Address review: without forcing these settings, the test could fall back to
a normal file read if the count fast path is disabled in a test profile,
and would no longer exercise the `ColumnConst` subcolumn path.

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default and removed pr-ci labels Jul 21, 2026
…egression test

The test relies on the inferred schema wrapping columns in `Nullable` to
exercise the `ColumnConst(Nullable(...))` subcolumn path. Pin
`schema_inference_make_columns_nullable = 1` so a future change of the
default cannot silently stop the test from covering the fixed code.

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

Copy link
Copy Markdown
Member

CI triage for the latest run (06ec723):

Also addressed the review feedback by pinning schema_inference_make_columns_nullable = 1 in the test (6eaa998).

The stateless test `04115_file_count_from_nullable_csv.sh` did not reliably
exercise the `ColumnConst` unwrap branches in `IDataType::getSubcolumn` and
`IDataType::tryGetSubcolumn` (the `COUNT(*) FROM file(...)` fast path can
succeed without hitting them, so LLVM coverage left them uncovered).

Add a focused gtest that builds a `ColumnConst(Nullable(String))` and calls
both methods directly, verifying they return a `ColumnConst` of the original
size for an existing subcolumn (`null`) and `nullptr` for a missing one. This
keeps the fix guarded regardless of the end-to-end query being reproducible.

Addresses review feedback on ClickHouse#102509
@alexey-milovidov

Copy link
Copy Markdown
Member

CI triage for run 71205354:

The branch has been updated with the latest master (clean merge, no conflicts; the PR's changed files were untouched on master) to get a fresh CI run. AI review verdict is ✅ Approve, all review threads are resolved, and changed-lines coverage is 100%.

@alexey-milovidov

Copy link
Copy Markdown
Member

CI triage for run 76bbeed6 — all four failures are pre-existing flakes, unrelated to this PR (which only touches IDataType::getSubcolumn/tryGetSubcolumn and its tests):

AI review is ✅ Approve, no unresolved review threads, and changed-lines coverage is 100%. Merged the latest master (clean, no conflicts; IDataType.cpp compiles) and pushed 84099b7 to restart CI.

@alexey-milovidov

Copy link
Copy Markdown
Member

CI triage for 84099b7: all three reds are unrelated to this PR.

Merged current master (clean, master did not touch this PR's files) to pull in the #111353 fix and re-run CI: b82ba54.

@clickhouse-gh

clickhouse-gh Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.20% 86.20% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 78.30% 78.30% +0.00%

Changed lines: Changed C/C++ lines covered: 33/33 (100.00%) · Uncovered code

Full report · Diff report

@alexey-milovidov alexey-milovidov left a comment

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.

Interesting, because we don't store ColumnConst anywhere, so this code path is irrelevant for now. But we plan to do it. There is "automatic Const and LowCardinality storage representations" in the roadmap. So the fix is marginally useful. I think it does not make it worse - let's merge.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 25, 2026
Merged via the queue into ClickHouse:master with commit 3e405fa Jul 25, 2026
179 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 25, 2026
pull Bot pushed a commit to admariner/ClickHouse that referenced this pull request Jul 30, 2026
…iners

The aggregate-state carve-out in `checkColumnStructure` (functions with the
same state representation compare equal, e.g. `quantileState` vs
`quantilesState(0.9)`) applied only to top-level `ColumnAggregateFunction`.
When an expression over a `UNION ALL` of such states wraps them into another
column (e.g. `tuple(s)`), the nested columns fell into the strict
`IColumn::getName` comparison, and debug and sanitizer builds failed the
query plan and pipeline header checks with a logical error
'Block structure mismatch in after optimization liftUpUnion stream'.

Make the comparison recursive: descend into plain container columns (Tuple,
Array, Map, Nullable, Const, Sparse, Replicated) and apply the aggregate-state
relaxation at any nesting depth; all other columns are still compared by full
name, exactly as before.

Found by AST fuzzer: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102509&sha=06ec723ed42b84c7c77f932d8afb808060adca5c&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%29
(the failure was unrelated to ClickHouse#102509)

Closes: ClickHouse#111185

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The stateless test `04115_file_count_from_nullable_csv.sh` did not reliably
exercise the `ColumnConst` unwrap branches in `IDataType::getSubcolumn` and
`IDataType::tryGetSubcolumn` (the `COUNT(*) FROM file(...)` fast path can
succeed without hitting them, so LLVM coverage left them uncovered).

Add a focused gtest that builds a `ColumnConst(Nullable(String))` and calls
both methods directly, verifying they return a `ColumnConst` of the original
size for an existing subcolumn (`null`) and `nullptr` for a missing one. This
keeps the fix guarded regardless of the end-to-end query being reproducible.

Addresses review feedback on ClickHouse#102509
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-crash

Fix fasttest exception in file inferred Nullable cols
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-improvement Pull request with some product improvements 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.

Server died

3 participants