Skip to content

Fix FunctionVariantAdaptor exception when nested function returns Nothing type#97213

Merged
alexey-milovidov merged 3 commits intomasterfrom
fix-variant-adaptor-nothing-type
Feb 18, 2026
Merged

Fix FunctionVariantAdaptor exception when nested function returns Nothing type#97213
alexey-milovidov merged 3 commits intomasterfrom
fix-variant-adaptor-nothing-type

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

Summary

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=42be5daa2cfd617b45ee36eeec6d72fd405fba41&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_debug%29

Test plan

  • Added regression test 03918_variant_adaptor_nothing_type
  • Verified fix with clickhouse-local using both simplified and original fuzzer queries
  • Built and tested in RelWithDebInfo

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC) or LOGICAL_ERROR

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

Fix LOGICAL_ERROR exception in FunctionVariantAdaptor when a function operating on Variant columns returns Nothing type, which can happen with empty arrays in UNION ALL queries.

🤖 Generated with Claude Code

…hing type

When `FunctionVariantAdaptor` executes a function on a Variant column
that contains a single variant (e.g., `Array(Nothing)` from an empty
array literal `[]`), the nested function can return a result of type
`Nothing`. The code only checked for `Nullable(Nothing)` via `onlyNull`
but missed plain `Nothing`, causing a failed cast to the expected
`Variant(...)` result type and a `LOGICAL_ERROR` exception.

Add `isNothing` checks alongside existing `onlyNull` checks in all
three execution paths (single variant no NULLs, single variant with
NULLs, multiple variants) to treat `Nothing` results as defaults/NULLs.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=42be5daa2cfd617b45ee36eeec6d72fd405fba41&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_debug%29

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Feb 17, 2026

Workflow [PR], commit [e9c9ad9]

Summary:

@clickhouse-gh clickhouse-gh bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Feb 17, 2026
@alexey-milovidov
Copy link
Copy Markdown
Member Author

Looks reasonable.

alexey-milovidov and others added 2 commits February 18, 2026 05:25
…ot support Variant type inference in UNION ALL

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@alexey-milovidov alexey-milovidov merged commit cf4ab28 into master Feb 18, 2026
146 of 147 checks passed
@alexey-milovidov alexey-milovidov deleted the fix-variant-adaptor-nothing-type branch February 18, 2026 07:32
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 18, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Feb 18, 2026
robot-clickhouse added a commit that referenced this pull request Feb 18, 2026
Cherry pick #97213 to 26.1: Fix FunctionVariantAdaptor exception when nested function returns Nothing type
robot-clickhouse added a commit that referenced this pull request Feb 18, 2026
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Feb 18, 2026
clickhouse-gh bot added a commit that referenced this pull request Feb 18, 2026
Backport #97213 to 26.1: Fix FunctionVariantAdaptor exception when nested function returns Nothing type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

Logical error: Cannot convert nested result of function A with type B to the expected result type C: D (STID: 4827-671c)

5 participants