Repository navigation
Fix Arrow Flight returning garbage for columns stored in sparse serialization - #125553
Conversation
`PullingPipelineExecutor` returns columns as the pipeline produced them, so a MergeTree column stored in sparse serialization reaches the Arrow Flight server as a `ColumnSparse`. Ordinary output formats never see one, because `QueryPipeline::complete` gives them a `MaterializingTransform`, but the server converts pulled blocks with `CHColumnToArrowColumn` directly, and the converter only undoes `ColumnConst` and `ColumnReplicated`. The first `assert_cast` to the concrete column class then fails: a `LOGICAL_ERROR` on debug and sanitizer builds, and garbage values on release builds, where `assert_cast` is a `static_cast`. Call `removeSpecialColumnRepresentations` after every `pull` at the three places where the server reads a query result (`DoGet` with a SQL ticket, `executeSQLtoTables_impl` behind `GetFlightInfo`, and `PollSession::getNextBlock` behind `PollFlightInfo`), before any `block_modifier` sees the block, as the dictionary sources and the query result cache already do. The converter is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 rounds; round 2 delta: 0 findings) plus my own review.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261013-030300 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261013-025200 |
|
Workflow [PR], commit [f2c6b40] Summary: ✅
AI ReviewSummaryThis PR fixes the Final Verdict✅ Approve — no blocking or major issues found. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 22 s compile time in total, 8 of them have a recent master baseline. |
Resolve the conflicts in ArrowFlightServer.cpp: 26.9 does not have #115250, #125534 and #125553, which changed the same lines (conversion settings, the `block.empty()` check in `DoGet`, `removeSpecialColumnRepresentations`), so their changes are left out and only #129193's lines are kept. Leave out 05497_arrowflight_exception_on_query_finish: 26.9 has no Arrow Flight port in the stateless test config (#125517 is master-only), so the test cannot connect there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflicts in ArrowFlightServer.cpp: 26.8 does not have #115250, #125534 and #125553, which changed the same lines (conversion settings, the `block.empty()` check in `DoGet`, `removeSpecialColumnRepresentations`), so their changes are left out and only #129193's lines are kept. Leave out 05497_arrowflight_exception_on_query_finish: 26.8 has no Arrow Flight port in the stateless test config (#125517 is master-only), so the test cannot connect there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #125517
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed the Arrow Flight interface returning garbage values for a
MergeTreecolumn stored in sparse serialization, which is the default for a column that holds mostly default values. AffectedDoGetwith a SQL ticket,GetFlightInfoandPollFlightInfo.Description
On 26.8.21.12 and 26.3.33.24, with default
MergeTreesettings,DoGetof the SQL ticketSELECT x FROM t, wherexis mostly zeros and its part therefore stores it sparse, returns garbage such as139362918555712instead of the column values. Debug and sanitizer builds abort withLogical error: 'Bad cast from type DB::IColumn const* to DB::ColumnNullable const*', which is how the stress test of #125517 found it (CI report).Root cause:
PullingPipelineExecutorreturns columns as the pipeline produced them. An ordinary output format gets aMaterializingTransformfromQueryPipeline::complete, but the Arrow Flight server converts the pulled blocks withCHColumnToArrowColumndirectly, and the converter only undoesColumnConstandColumnReplicated. AColumnSparsethen fails the firstassert_cast, which is astatic_castin release builds.Change: call
removeSpecialColumnRepresentationsafter eachpullat the three places where the server reads a query result (DoGetwith a SQL ticket,GetFlightInfo,PollFlightInfo), as the dictionary sources already do. Results without sparse columns are unchanged (identical Arrow IPC bytes).Validation: the new integration test reads a sparse table through all three paths; it fails on master with the server abort and passes with the fix. Locally, all three paths return the same values as the native protocol for compact and wide parts, a
DoGetof 13 sparse-capable types matches HTTPFORMAT Arrow, and alltest_arrowflight_*integration tests pass.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125553]
Version info
26.10.1.2317-master(included in26.10and later)