Repository navigation
Conversation
setVirtualRow built a default-valued constant for every header column absent from the PK block. For columns that hold no data this throws: the ColumnSet placeholder of an IN predicate, kept alive in the in-order read header by INTERPOLATE, is an IColumnDummy, and IColumnDummy::insert fails with "Cannot insert element into Set" (NOT_IMPLEMENTED) from MergingSortedTransform. The virtual row's non-sort-key columns are never read, so reuse the header's own placeholder resized to one row instead. Closes: ClickHouse#111831 Co-Authored-By: Claude Fable 5 <[email protected]>
|
ClickGap AI Bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
Workflow [PR], commit [0820919] Summary: ❌
AI ReviewSummaryThis PR fixes the reported Findings
Tests
Final VerdictChanges needed: the current patch fixes the reported |
| if (const auto * col_const = typeid_cast<const ColumnConst *>(nested)) | ||
| nested = &col_const->getDataColumn(); | ||
|
|
||
| if (nested && nested->isDummy()) |
There was a problem hiding this comment.
This guard is still too specific to IColumnDummy carriers. Lambda helpers are represented as DataTypeFunction / ColumnFunction, and those can also survive in these headers via the same constant-input machinery that kept the Set placeholder alive. They are non-creatable too: createColumnConstWithDefaultValue(1) reaches ColumnFunction::insert, which throws.
That means a multi-part read_in_order_use_virtual_row query that keeps a lambda helper in the header will still hit the same user-visible exception here. Please broaden this to the general non-creatable case, for example by checking isNotCreatable(col.type) or by reusing col.column->cloneResized(1) for missing virtual-row columns instead of only the isDummy() subset.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 8/8 (100.00%) · Uncovered code |
|
@groeneai check this PR and see if it is still required. If yes, open a new PR with the fix |
|
Still required. It reproduces on today's master (tested I will open a new PR with a fix, closing #111831 and crediting this one. One measurement on the AI review's request to generalize the guard to the whole |
|
Fix opened as #113264, closing #111831 and crediting this PR. Reporting back on the |
Closes: ClickHouse#111831 Related: ClickHouse#112344 A MergeTree read-in-order query combining WITH FILL INTERPOLATE with an IN or has filter failed with "Cannot insert element into Set" (NOT_IMPLEMENTED) when read_in_order_use_virtual_row was enabled, while the same query succeeded with the setting off. A plan optimization was breaking a correct query. setVirtualRow fills every header column absent from the part's primary-key block with createColumnConstWithDefaultValue(1), whose precondition is a creatable type. The second argument of an IN predicate is a Set placeholder column, and INTERPOLATE keeps it in the read header because the interpolate step declares every current header column as an input, so the placeholder survives column pruning all the way down into ReadFromMergeTree. DataTypeSet overrides both createColumn and getDefault successfully, so the failure landed one level deeper in IColumnDummy::insert. Reuse the header's own placeholder column resized to one row for types that cannot produce a default value, using the existing isNotCreatable predicate. This is sound because the virtual row is never emitted (skip_last_row, then removeTop without insert) and only its sort columns are ever compared. Reusing col.column rather than building a fresh one keeps the real FutureSetPtr alive inside the ColumnSet. isNotCreatable is used because it is the codebase's existing name for "types that cannot produce a default-valued column", not because Function is a carrier of this bug. It is not: the lambda shape fails with the setting off as well, at VirtualRowTransform rather than MergingSortedTransform, which is a pre-existing WITH FILL defect and needs its own issue. Validated on a debug build: the failure reproduces deterministically pre-fix, and post-fix every shape returns results identical to the read_in_order_use_virtual_row = 0 ground truth, including LowCardinality, Nullable, Array, Map, an empty set and a 10000-element set. The new test fails on the pre-fix binary and passes after, 100/100 green over 50 randomized plus 50 forced-setting runs. The original analysis is @ zlareb1's, from the closed PR ClickHouse#112344.
Closes: #111831
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
Cannot insert element into Set(NOT_IMPLEMENTED) exception when a query combinesread_in_order_use_virtual_rowwithORDER BY ... WITH FILL INTERPOLATEand anINfilter whoseColumnSetplaceholder is kept alive in the in-order read header.Documentation entry for user-facing changes
setVirtualRowbuilt a default-valued constant for every header column absent from the primary-key block. For columns that hold no data this throws: theColumnSetplaceholder of anINpredicate, kept alive in the in-order read header byINTERPOLATE, is anIColumnDummy, andIColumnDummy::insertfails withCannot insert element into SetfromMergingSortedTransform. The virtual row's non-sort-key columns are never read, so for dummy columns the fix reuses the header placeholder viacloneResized(1)instead of materializing a default value.Found by the optimizer test framework (
tests/optimizer_tester).🤖 Generated with Claude Code