Skip to content

Fix variant_throw_on_type_mismatch/dynamic_throw_on_type_mismatch=false not catching exceptions during function execution#105543

Open
Avogar wants to merge 1 commit into
masterfrom
fix-variant-throw-on-type-mismatch-execute-v2
Open

Fix variant_throw_on_type_mismatch/dynamic_throw_on_type_mismatch=false not catching exceptions during function execution#105543
Avogar wants to merge 1 commit into
masterfrom
fix-variant-throw-on-type-mismatch-execute-v2

Conversation

@Avogar
Copy link
Copy Markdown
Member

@Avogar Avogar commented May 21, 2026

Closes #103484

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fix variant_throw_on_type_mismatch/dynamic_throw_on_type_mismatch=false not catching exceptions during function execution. Closes #103484

…ring `execute`

The `try_build` lambda in `FunctionVariantAdaptor` and `FunctionDynamicAdaptor`
only wrapped `build()` in a try-catch for type-related errors. Some functions
(e.g. comparison functions like `equals`) pass `build()` successfully but throw
`NO_COMMON_TYPE` during `execute()` because `executeGeneric` calls
`getLeastSupertype` which rejects incompatible types like `String` and `UInt8`.

Add a `try_execute` helper that wraps `execute()` calls with the same
try-catch pattern, returning NULL for incompatible-type rows when
`throw_on_type_mismatch` is disabled. Apply the fix to all three execution
paths in both adaptors (single variant no NULLs, single variant with NULLs,
and the general multi-variant case).

Closes #103484

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

clickhouse-gh Bot commented May 21, 2026

Workflow [PR], commit [ea4ea81]

Summary:

job_name test_name status info comment
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/check_report_messages.py FAIL

AI Review

Summary

This PR fixes FunctionVariantAdaptor and FunctionDynamicAdaptor so variant_throw_on_type_mismatch = false / dynamic_throw_on_type_mismatch = false also handle type-related exceptions raised during execute (not only during build), and adds regression coverage for the affected execution paths. The implementation is consistent with the setting contract (incompatible rows become NULL, non-type exceptions still propagate), and the new tests cover the reproduced behavior for both Variant and Dynamic.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label May 21, 2026
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh Bot commented May 21, 2026

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 91.40% 91.40% +0.00%
Branches 76.50% 76.60% +0.10%

Changed lines: 88.00% (66/75) · Uncovered code

Full report · Diff report

@alexbakharew alexbakharew self-assigned this May 27, 2026
Copy link
Copy Markdown
Contributor

@alexbakharew alexbakharew left a comment

Choose a reason for hiding this comment

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

The initial PR #95811 was backported to 26.1.

@Avogar Do you know why only to 26.1 and not to other supported versions?

This fix should be backported as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

variant_throw_on_type_mismatch=false fails for comparison functions: try_build only wraps build, not execute

2 participants