Fix timeseries WHERE filter routing via exhaustive collection_type dispatch#5
Merged
farhan-syah merged 4 commits intomainfrom Mar 30, 2026
Merged
Conversation
…tion_type() method Replace four separate is_timeseries / is_plain_columnar / is_spatial / is_kv predicate methods with a single collection_type() call that performs one catalog read. Each call site is updated to match exhaustively on CollectionType, so new collection variants produce a compile error instead of silently falling through to document routing. Filter(TableScan) and bare TableScan paths in the converter now share the same dispatch logic. DML routing in dml.rs and point-operation builders in the native dispatch layer follow the same pattern. Helper functions serialize_predicate_filters, serialize_scan_filters, and resolve_scan_projection are extracted to eliminate repeated inline serialization blocks.
…path In ilp_listener.rs, fix schema comparison to use content equality instead of length comparison, replace silent error swallowing on catalog writes with tracing::warn!, fix catalog() call to use .as_ref(), and collapse nested if chains into let-chain conditions per clippy. In timeseries.rs, replace .unwrap() on memtable lookups with proper let-else guards that return a structured Internal error response, and convert the third unwrap in the schema-columns branch to a let-chain condition so a missing memtable no longer panics.
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4 —
SELECT * FROM ts_collection WHERE field = 'value'returned empty results because theFilter(TableScan)path in the plan converter never checked for timeseries (or columnar/spatial) collections, silently misrouting them toDocumentOp::Scan.Root cause: Four independent
is_kv()/is_timeseries()/is_plain_columnar()/is_spatial()methods each performed separate catalog lookups, and callers had to remember to check all of them. Missing a check meant silent misrouting to the document engine fallback.Fix: Replace the
is_*()waterfall with a singlecollection_type()method that returnsOption<CollectionType>, then dispatch via exhaustivematch. Rust's pattern exhaustiveness checking now guarantees that adding a newCollectionTypevariant produces compile errors at every dispatch site.Changes
converter.rs— Replaced 4is_*()helpers withcollection_type(). RefactoredFilter(TableScan), bareTableScan, andLimithandlers to exhaustivematch. Timeseries WHERE filters now correctly extract time-range bounds and preserve column projections. Limit propagation covers all scan types (TimeseriesOp::Scan,ColumnarOp::Scan,SpatialOp::Scan,KvOp::Scan).converter_helpers.rs— Aggregate timeseries detection usescollection_type().dml.rs— DML routing uses exhaustivematch. Spatial collections now route to columnar insert.plan_builder/mod.rs— Replacedis_kv()+is_timeseries()with singlecollection_type().plan_builder/document.rs—PointGet/PointPut/PointDeleteuse exhaustivematch. Columnar collections now return explicit errors instead of silent misrouting toDocumentOp.collection_insert.rs— Replacedis_strict() || is_columnar()with!is_schemaless()to also skip KV and timeseries.ddl/collection.rs— Storage mode registration uses exhaustivematch. KV collections register with their schema.Test plan
cargo test --all-features— 3223 passed, 0 failurescargo clippy -p nodedb --all-targets -- -D warnings— cleanSELECT * FROM metrics WHERE qtype = 'AAAA' LIMIT 10on a timeseries collection returns rowsSELECT * FROM metrics WHERE elapsed_ms > 1000 LIMIT 5on a timeseries collection returns rowsSELECT * FROM columnar_table WHERE field = 'x' LIMIT 10on a plain columnar collection returns rows