Repository navigation
Native Common Virtuals for Buffer - #101537
Conversation
|
Workflow [PR], commit [5e5e543] Summary: ❌
AI ReviewSummaryThis PR extends support for virtual column Missing context
Findings❌ Blockers
Tests
ClickHouse Rules
Performance & Safety
Final Verdict
|
| VirtualColumnsDescription StorageBuffer::createVirtuals() | ||
| { | ||
| VirtualColumnsDescription desc; | ||
| desc.addEphemeral("_table", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), ""); |
There was a problem hiding this comment.
This PR also adds a new user-visible virtual column (_table) for Buffer, but there is no corresponding stateless test coverage.
Please add a tests/queries/0_stateless test that selects _table from a Buffer table (ideally with rows both in the in-memory buffer and in the destination table) and verifies the expected table name is returned.
| /// Reads from one buffer (from one block) under its mutex. | ||
| class BufferSource : public ISource | ||
| { | ||
| ColumnPtr fillVirtualColumn(const String & name, const DataTypePtr & type, size_t num_rows) const |
There was a problem hiding this comment.
I feel like we can have this code shared for many sources by default. Maybe make some base class, like SourceWithVirtuals?
There was a problem hiding this comment.
Actually, I thought about it, and IMO it will require more effort in the future if we unite implementations of different storages. I like the idea that storage must always provide a way to customize its virtual columns, and this should not be tied to other storage engines.
wdyt?
| { | ||
| if (!dest_columns.hasPhysical(column_name)) | ||
| auto dest_column = destination_columns.tryGetByName(column_name); | ||
| if (!dest_column) |
There was a problem hiding this comment.
❌ SELECT _table FROM <buffer_table> can silently drop flushed rows when the destination engine has no _table virtual column.
In the mismatch branch, _table is removed from columns_intersection; if it is the only requested column, columns_intersection becomes empty and destination rows are skipped entirely ("Block of data is skipped."). That makes results depend on destination engine support instead of Buffer semantics.
Please keep destination rows in this case and synthesize _table for them from the queried Buffer table name (or otherwise ensure destination rows are still returned when _table is requested).
| d5 7 70 | ||
| d5 8 80 |
There was a problem hiding this comment.
this is a behavior change
LLVM Coverage Report
Changed lines: 100.00% (91/91) | lost baseline coverage: 7 line(s) · Uncovered code |
|
Hi @Michicosun @CheSema @KochetovNicolai — this PR appears to contain a backward incompatible change but is categorized as Why: The _table virtual column for Buffer previously returned the buffer table name for ALL rows. After this PR, it returns the destination table name for flushed data. This changes observable SQL semantics (test 03094 reference shows buffer1->d5 for flushed rows). Users filtering WHERE _table='buffer_name' will silently get fewer rows. Additionally, the PR introduces a crash for non-MergeTree destinations. Suggested category: Could you check if the changelog category should be updated? This helps users know what to expect when upgrading. Ignore this if the change is intentionally non-breaking. |
|
Hi @Michicosun @CheSema @KochetovNicolai — while reviewing this PR I found the following:
Happy to discuss — close anything that's wrong or already addressed. |
…rtuals/Buffer Native Common Virtuals for Buffer
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Part of #100766
Version info
26.4.1.565