Skip to content

Fix bad cast exception in kql_array_sort with constant array arguments - #98251

Merged
alexey-milovidov merged 4 commits into
masterfrom
fix-kql-array-sort-const-bad-cast
Feb 28, 2026
Merged

alexey-milovidov merged 4 commits into
masterfrom
fix-kql-array-sort-const-bad-cast

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Feb 27, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Fix logical error "Bad cast from type DB::ColumnConst to DB::ColumnArray" in kql_array_sort_asc/kql_array_sort_desc when a constant array argument (e.g. []) is passed
  • The tupleElement result was not unwrapped from ColumnConst before casting to ColumnArray
  • Added convertToFullColumnIfConst call before the cast

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=12fa973a02c8e877fdd81efd696be1108834388a&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20plan%2C%20s3%20storage%2C%20parallel%29

Changelog category (leave one):

  • Bug Fix

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

Fix logical error "Bad cast from type DB::ColumnConst to DB::ColumnArray" in kql_array_sort_asc/kql_array_sort_desc when called with constant array arguments.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

🤖 Generated with Claude Code

Version info

  • Merged into: 26.3.1.160

…with constant array arguments

The `tupleElement` result could be a `ColumnConst` wrapping a `ColumnArray`
when the first array argument is a constant (e.g. empty array literal `[]`).
The code tried to cast it directly to `ColumnArray` without unwrapping,
causing a logical error "Bad cast from type DB::ColumnConst to DB::ColumnArray".

https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=12fa973a02c8e877fdd81efd696be1108834388a&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20plan%2C%20s3%20storage%2C%20parallel%29

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Feb 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8b74075]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan, db disk, old analyzer, 3/6) failure
test_mysql_protocol/test.py::test_mysql_dotnet_client FAIL cidb

@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 27, 2026
@alexey-milovidov alexey-milovidov added pr-bugfix Pull request with bugfix, not backported by default and removed pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-critical-bugfix labels Feb 27, 2026
@nickitat nickitat assigned nickitat and unassigned nickitat Feb 27, 2026
@alexey-milovidov
alexey-milovidov merged commit 40310cf into master Feb 28, 2026
143 of 144 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-kql-array-sort-const-bad-cast branch February 28, 2026 20:40
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 28, 2026
alexey-milovidov added a commit that referenced this pull request Mar 1, 2026
…d-cast

Fix bad cast exception in kql_array_sort with constant array arguments
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @alexey-milovidov @nickitat — while reviewing this PR I found the following:

Happy to discuss — close anything that's wrong or already addressed.

@clickgapai

Copy link
Copy Markdown
Contributor

Apologies for the duplicate notification — we had a race condition in our notification system where multiple processes posted simultaneously. The duplicate has been removed and we've added a strict 3-layer dedup guard (DB lock + immediate key + GitHub comment check) to ensure this cannot happen again.

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.

4 participants