Skip to content

Fix const string comparison not respecting some of the the cast settings - #95040

Merged
nihalzp merged 8 commits into
ClickHouse:masterfrom
nihalzp:fix-const-string-comparison
Jan 26, 2026
Merged

nihalzp merged 8 commits into
ClickHouse:masterfrom
nihalzp:fix-const-string-comparison

Conversation

@nihalzp

@nihalzp nihalzp commented Jan 24, 2026 •

Copy link
Copy Markdown
Member
-- Throws but should be 1
SELECT CAST('2025-12-07T05:17:47.563383Z', 'DateTime64') = '2025-12-07T05:17:47.563383Z'
SETTINGS cast_string_to_date_time_mode = 'best_effort';
-- Throws but should not
SELECT CAST(1 AS Bool) = 'yess' SETTINGS bool_true_representation='yess', bool_false_representation='noo'; 
-- Does not throw but should
SELECT tuple(1, 0) = '(1, NULL)' SETTINGS input_format_null_as_default=0;

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 constant string comparisons not respecting the settings cast_string_to_date_time_mode, bool_true_representation, bool_false_representation, and input_format_null_as_default. Closes #91681.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.1.1.894

@clickhouse-gh

clickhouse-gh Bot commented Jan 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4505a9d]

Summary: ❌

job_name test_name status info comment
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting: the query: (STID: 1941-1bfa) FAIL cidb, issue

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jan 24, 2026
@tuanpach tuanpach self-assigned this Jan 26, 2026
@nihalzp
nihalzp added this pull request to the merge queue Jan 26, 2026
Merged via the queue into ClickHouse:master with commit 88589db Jan 26, 2026
129 of 130 checks passed
@nihalzp
nihalzp deleted the fix-const-string-comparison branch January 26, 2026 18:33
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jan 26, 2026
PedroTadim added a commit that referenced this pull request Nov 19, 2026
…f an enum

`SerializationEnum::deserializeWholeText` read the TSV setting, so every reader of a whole string as an enum
that gets the session format settings read the name as a number: comparisons with a string constant (since
#95040), the `Form` format, and `CAST` of a string to a `Variant` with an `Enum`. The setting is needed only by
`TSVRaw` and the `Raw` escaping rule, which reach the enum through `deserializeTextRaw`, so it moves there.
The name lookup already falls back to the value, so the whole text still accepts a number.

This replaces the reset of the setting in `ComparisonParams`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PedroTadim added a commit to buggins/ClickHouse that referenced this pull request Nov 20, 2026
…t_tsv_enum_as_number`

Since ClickHouse#95040 the comparison functions parse a
string constant with all format settings of the session, so `input_format_tsv_enum_as_number = 1`
made `enum_column = 'name'` read `'name'` as a number and throw `UNKNOWN_ELEMENT_OF_ENUM`.
`IN`, `has` and `CAST` were not affected.

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

pr-bugfix Pull request with bugfix, not backported by default 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.

Comparison with constant String doesn't respect settings related to CAST

3 participants