Repository navigation
feat: Phase 7.7b — User-Defined Functions (v0.17.0) - #70
Merged
Merged
Conversation
- Add UnaryOp::Udf variant to test_unary_op_variants_exist - Add WindowFunc::Udf test case to test_window_spec_func_name - Update UnaryOp::Udf doc-comment to align with WindowFunc::Udf wording - Update executor.rs comment to clarify that UDF aggregates route through the accumulator-based handler and will be dispatched via FunctionRegistry in Task 4 All 707 tests passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…egistry for 7.7b
- Replace AggregateDesc.{window_compatible,window_ops,is_builtin} fields with AggImpl enum (Builtin(WindowOps) | Udf(UdfOps))
- Add UdfOps: type-erased Arc<dyn Fn> closures for init/step/finalise
- Add PredicateDesc: Arc<dyn Fn(&Value) -> bool> with is_builtin sentinel
- Add predicates: HashMap to FunctionRegistry; populate built-in name sentinels
- Add register_aggregate_desc / register_predicate_desc (Err on duplicate)
- Add get_predicate (filters out built-in sentinels)
- Update is_window_compatible to use name-based logic instead of field
- Update executor.rs: match on AggImpl instead of old field access; UDF window stub returns Err for Task 4
- 6 new unit tests; all 713 tests pass
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…g predicates - Modify parse_window_expr to emit WindowFunc::Udf for unknown window function names - Modify parse_expr to emit UnaryOp::Udf for unknown 1-arg predicates - Unknown 2-arg forms still rejected with error - lag/lead still explicitly rejected (deferred post-1.0) - Add 5 new tests: parse_udf_window_function, parse_udf_predicate_clause, parse_unknown_two_arg_predicate_rejected, parse_lag_still_rejected, parse_lead_still_rejected - Update parse_unknown_window_func_rejected to parse_unknown_window_func_as_udf (reflects new behavior) - All 718 tests passing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…and predicate clauses - eval_expr: add registry: Option<&FunctionRegistry> parameter; handle UnaryOp::Udf by dispatching to registered predicate fn - apply_expr_clauses: add registry: &FunctionRegistry parameter, return anyhow::Result<Vec<Binding>>, pre-validate unknown UDF predicate names - compute_aggregation: replace AggImpl::Udf stub with real step/finalise loop - apply_window_functions: replace AggImpl::Builtin-only path with a match on AggImpl::Builtin vs AggImpl::Udf, each using their respective ops - Thread FunctionRegistry through not_body_matches, evaluate_branch, and apply_or_clauses so UDF predicates work inside not/or bodies - Update evaluator.rs apply_expr_clauses_in_evaluator and apply_or_clauses call sites to match new signatures - Update all test call sites (eval_expr +None, evaluate_branch +FunctionRegistry::with_builtins(), apply_expr_clauses +registry +unwrap) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Also fix parse_aggregate_expr to allow unknown aggregate names through as UDF candidates (resolved at runtime) instead of rejecting at parse time. Update parser.rs and aggregation_test.rs tests accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mplete) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…_COVERAGE Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Also fixes BTreeSet deduplication key ordering bug in apply_or_clauses (HashMap::iter() order is non-deterministic; sort key entries before inserting into BTreeSet to ensure identical bindings deduplicate correctly). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #70 +/- ##
==========================================
+ Coverage 84.50% 84.70% +0.19%
==========================================
Files 25 25
Lines 4402 4484 +82
==========================================
+ Hits 3720 3798 +78
- Misses 682 686 +4
🚀 New features to boost your workflow:
|
10 tasks done
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
61F4
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
Minigraf::register_aggregate(name, init, step, finalise)— custom aggregate functions usable in both:findgrouping and:over(window) clausesMinigraf::register_predicate(name, f)— custom single-argument filter predicates usable in[(name? ?var)]:whereclausesAggImplenum discriminates built-in vs UDF pathsTest Plan
tests/udf_test.rs— custom aggregate, empty result, predicate filter, window UDF, name collision guards, runtime error paths, thread safetycargo clippy -- -D warningsclean🤖 Generated with Claude Code