feat: enable SearchV PREFILTER support in HQL#899
Conversation
| pre_filter | ||
| .iter() | ||
| .map(|f| format!("|v: &HVector, txn: &RoTxn| {f}")) | ||
| .map(|f| format!("|val: &HVector, txn: &RoTxn| {f}")) |
There was a problem hiding this comment.
txn will always be unused in valid prefilter closures
The closure parameter txn: &RoTxn is declared but is never referenced in the generated body for valid prefilter expressions. The validator in is_supported_search_vector_prefilter_traversal restricts accepted traversals to exactly two steps (PropertyFetch + BoolOp), and bool_ops.rs renders those as val.get_property(...).map_or(false, |v| ...) — a path that only touches val. Any traversal needing txn (i.e., the multi-step G::from_iter(&db, &txn, ...) path) is already rejected by the validator. This will emit an unused-variable warning on every compiled prefilter closure; use _txn to suppress it.
| .map(|f| format!("|val: &HVector, txn: &RoTxn| {f}")) | |
| .map(|f| format!("|val: &HVector, _txn: &RoTxn| {f}")) |
|
Addressed the unused xn warning in generated prefilter closures by renaming it to _txn in codegen.\n\nFix commit: 6d56b81 |
|
Opened a separate CI-fix PR for the cli_tests.yml parser failure noise: #900 |
Summary
SearchV<...>(..., k)::PREFILTER(...)SearchVanalysis path (start-node and expression forms)valso generated predicates compile against&HVector::SearchVfrom silently dropping prefilters by surfacing an analyzer errorNotes
_::{category}::EQ("tech")) for prefilter closuresValidation
cargo testin this environment becausecargois not installedCloses #834
Greptile Summary
This PR enables
SearchV<T>(..., k)::PREFILTER(...)in HQL by uncommenting the grammar rule, wiringbuild_search_vector_pre_filterinto the rootSearchVanalysis path, aligning the generated closure binding toval, and blocking PREFILTER on graph-stepSearchVwith an E601 diagnostic. Support is intentionally scoped to simple property predicates (_::{field}::BoolOp(value)).Important Files Changed
("::" ~ pre_filter)?suffix onsearch_vector, enabling PREFILTER syntax in HQL.build_search_vector_pre_filterand validator helpers; test fixtures use[F64]with an[F32]schema and compound And/Or prefilter paths are untested.build_search_vector_pre_filterinto the rootSearchVanalysis path, replacing the previously deadlet pre_filter = None.SearchVfrom silently dropping prefilters by emitting E601 whensv.pre_filteris set.vtovalso generated predicates compile against thevalidentifier emitted by the traversal renderer; doc comment is now stale.SearchV<T>(..., k)::PREFILTER(...)round-trips throughHelixParser::parse_sourcewithout error.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["HQL: SearchV<T>(vec, k)::PREFILTER(expr)"] --> B{Root or graph-step?} B -->|Root StartNode| C["traversal_validation.rs\nbuild_search_vector_pre_filter()"] B -->|Graph step| D["graph_step_validation.rs\nEmit E601 error"] C --> E["infer_expr_type()\nparent_ty = Type::Vector(T)"] E --> F{stmt result} F -->|Traversal| G["BoExp::Expr(tr)"] F -->|BoExp| H["BoExp directly"] F -->|Other / None| I["Emit E306 / E601\nreturn None"] G --> J["is_supported_search_vector_prefilter_expr()"] H --> J J -->|Valid: PropertyFetch + BoolOp| K["Some(vec![pre_filter])"] J -->|Invalid: Exists / Empty / wrong steps| L["Emit E601\nreturn None"] K --> M["SearchVector { pre_filter: Some(...) }\nsource_steps.rs Display:\n|val: &HVector, txn: &RoTxn| ..."] L --> N["SearchVector { pre_filter: None }"]Reviews (1): Last reviewed commit: "fix(hql): silence unused txn in generate..." | Re-trigger Greptile