Repository navigation
feat(seql): scalable time-based analytics — bin N%, query templates, new aggregates - #16
Merged
Merged
Conversation
…helper throughput() was a stub returning count(*). Compute count(*) / seconds, where seconds is the time-bin width when the query is bucketed by ts() (a per-bucket rate) and otherwise the whole scan window — so the rate scales with the selected time range. Adds effective_window_ns() and threads it through apply_aggregate, laying groundwork for range-relative bucketing (ts() bin N%). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Introduce BinSpec (Fixed | Percent | Auto), replacing GroupExpr.bin_ns. The compiler resolves Percent/Auto against the query's effective window at compile time: `bin 10%` yields ~10 buckets scaled to the selected range, and `bin auto` snaps to a nice duration ladder (~100 buckets). Fixed durations are unchanged. This lets a saved time-series re-bucket sensibly as the dashboard range widens or narrows instead of exploding a fixed `bin 1m` into thousands of buckets. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ime range
Make the scan time scope optional (Scan.time_range: Option<TimeRange>) so a
query can be a range-agnostic template (`spans | group by { ts() bin 10% } {
count() }`). Add compile_with_range / compile_ast_with_range that inject a
structured range which overrides any inline scope, so the dashboard's selected
range drives the whole query. A scope-less query on a time-scoped signal errors
if executed without a range instead of silently scanning everything. The
effective window (inline or injected) feeds bin N% / throughput, so time-relative
features scale to whatever range is applied.
Rust core only; FFI + Swift threading follows.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ates Add stddev(col), variance(col)/var(col), and percentile(col, q) — q a 0..1 quantile (a 0–100 form is normalized). p95/p99 now delegate to a shared approx_percentile_cont helper, generalizing the previously hardcoded quantiles. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…a }`
Add a `window { … }` stage applied after aggregation over the ordered result
(by the ts() bucket / first temporal column): moving_avg(col, n), cumulative(col)
/running_sum(col), and delta(col) (period-over-period). Compiles to DataFusion
window exprs over row frames using only avg/sum UDAFs — delta reads the previous
row via a [1 preceding, 1 preceding] frame, so no lag UDF dependency.
A spike confirmed window functions survive the full Substrait round-trip through
the backend's custom consumer, so no SeqlExtension fallback is needed; a test
compiles a windowed time-series query and consumes it back to prove the daemon
can execute it. Being layered on aggregation, windowed queries are live-safe via
the existing Replace re-execution path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… path Add query_with_range / query_live_with_range on the backend and client (compiling via compile_*_with_range so a supplied range overrides the query's inline scope), dispatch them through the FFI QueryExecutor, and extend the C ABI: sequins_seql_query / _query_live now take (range_kind, range_a_ns, range_b_ns) — kind 0=none, 1=relative sliding window (a=duration), 2=absolute (a=start,b=end). Regenerates sequins.h. Lets the app run a scope-less query template against a separately-chosen range instead of baking time into the query string. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…write executeSeQL/executeLiveSeQL take an optional TimeRange, forwarded to the FFI as the (range_kind, range_a_ns, range_b_ns) triple; dashboards now inject the picker's range structurally (overriding the query's inline scope) instead of rewriting the leading `<signal> <scope>` via TimeRange.applied(to:). This also covers cases the string rewrite missed (inner sub-scopes, the signal(id) shorthand) and lets a scope-less query template run against the selected range. The chat/one-off path passes nil, so an inline scope is still honored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Update default_grounding() to cover percentile/stddev/variance and the corrected
per-second throughput(), range-relative bucketing (ts() bin 10% / bin auto), and
the window { moving_avg, cumulative, delta } stage, plus a note that dashboards
apply the selected range/liveness automatically and light interactive
query-building guidance. Refresh the parse-checked example list accordingly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Superseded by query_with_range (the plain query() had no remaining callers). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Qard
force-pushed
the
feat/seql-analytics
branch
from
July 28, 2026 14:24
10f4939 to
c20190a
Compare
Rebasing onto main brought this branch's ABI change together with the test call sites added by the assistant line (squashed into main as #15) for the first time. Those tests call `sequins_seql_query` with the old 4-argument form, so the crate fails to compile under `cargo test` — neither branch is broken alone. Pass `0, 0, 0` (kind 0 = use the query's inline scope) at each of the 12 call sites, preserving existing behavior. Note this is invisible to CI's clippy step, which runs without --all-targets and so never compiles test code; only the test step catches it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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
Extends SeQL so time-based query features scale to the query's time range and the range is a separable input (query templates), adds richer aggregation and window functions, wires the structured range end-to-end through the FFI + app, and teaches it all to the assistant. Implements the full analytics plan.
Language (seql-ast / seql-parser / seql-substrait)
throughput()fixed (1c8251f) — realcount(*) / seconds, per-bucket when time-bucketed else over the window; sharedeffective_window_ns.cd08a18) —ts() bin 10%(~10 buckets of the window) andts() bin auto(nice-snapped). A saved time-series re-buckets as the range changes.46d4e6d) — optional scan scope;compile_with_range/compile_ast_with_rangeinject a range that overrides the inline scope; scope-less + no range errors clearly.d0edfe5) —stddev,variance/var, arbitrarypercentile(col, q); p95/p99 refactored onto a shared helper.c3c2930) —window { moving_avg(col, n), cumulative(col), delta(col) }after aggregation, over DataFusion window frames (no lag UDF; delta via a[1 preceding,1 preceding]frame). A spike confirmed full Substrait round-trip through the backend's custom consumer, so no fallback is needed; live-safe via the existing Replace path.Wiring (ffi + macOS)
7d2e2d7) —query_with_range/query_live_with_rangeon backend + client; C ABIsequins_seql_query[_live]gains(range_kind, range_a_ns, range_b_ns); header regenerated.68c9a06) —executeSeQL/executeLiveSeQLtake an optionalTimeRange; dashboards inject the picker's range (overriding the inline scope) instead ofTimeRange.applied(to:)string rewriting — fixing the inner-scope /signal(id)gaps. Chat/one-off passes nil, honoring the inline scope.Assistant (
da52e91)ts() bin 10%/auto, thewindow { … }stage, that dashboards apply the selected range automatically, and light interactive query-building guidance; parse-checked example list refreshed.Testing
cargo test -p seql-ast -p seql-parser -p seql-substrait(26 / 114 / 44) — throughput scaling,bin 10%/auto, templates + injected-range override + no-range error, statistical aggregates, and a window query that compiles and consumes back through the backend's Substrait consumer. Grounding parse-check green.cargo fmt/clippyclean; FFI Rust builds, xcframework rebuilt, macOS app BUILD SUCCEEDED.Note: for the new grounding to take effect in remote mode, the daemon container image needs rebuilding (grounding is compiled into the daemon).
🤖 Generated with Claude Code