Repository navigation
Support clusterize() on queries with temporal aggregators (min, max, …)
#897
Replies: 3 comments 2 replies
|
I'd go for a separate API instead of extending An aggregator reduces the whole series of a field to a single value, and that value has no timestamp. BTW the server doesn't know the timestamp either: aggregators are computed from the per-chunk stats saved at ingestion, without reading the samples. To make It would also only work for some aggregators. Once My proposal is an API that returns the aggregated value per topic. You then use that value in a normal query, like this: max_x = topic.aggregate(IMU.Q.acceleration.x.max()) # name TBD
response = client.query(
QueryOntologyCatalog(IMU.Q.acceleration.x.eq(max_x))
)
# then clusterize() as usualthis is just a draft and we need to design it properly. This also covers the open questions with the current behavior. If several samples share the max, |
|
There's a couple of things that it is not clear to me. One among the others: it's not clear to me what the instruction |
|
For a concrete The second query must retain that association. For example, if topic A contains I'd therefore make a batch result carry The time-window choice also needs to be explicit. Computing the maximum within |
Uh oh!
There was an error while loading. Please reload this page.
Context
Right now, calling
TopicResponse.clusterize()(mosaico-sdk-py/src/mosaicolabs/query/response.py) on a query that contains an aggregator (e.g.min(),max()) makes the server return an error. As a result, there's no way to find out when the event happened in the topics that pass the filter.Use case
I want to find the IMU topics where the maximum acceleration goes above a given threshold:
The query correctly returns the topics that pass the filter. I also need the timestamp at which that maximum occurred, and that is exactly what
clusterize()is meant to give.Proposal
Allow
clusterize()on queries whose aggregators resolve to an actual time sample, such asminandmax. The aggregated value is a real sample in the series, so it has a well-defined timestamp. The resulting cluster may collapse to a single instant.For aggregators that do not produce a temporal value (e.g.
count()and others of the same type not yet implemented), the server can keep returning an error as it does today.Why
clusterize()and not a new APII'd rather not add a separate API. Users should be able to use the same tool to get the temporal information for any query, whether it's aggregated or not.
The current behavior is already inconsistent. Take this query:
If only one sample in a topic matches the condition,
clusterize()works fine and returns a single-instant cluster. This queryalso picks out a single sample per topic: the one holding the maximum value. To the user the result has the same shape, so there's no reason for
clusterize()to behave differently.Open questions
clustering_dt_ns) or only the first one?clusterize()interact withtimestamp_range: does the range limit how the aggregate is computed, or only which clusters are returned?@DevMattG @cabba @LuigiTer
All reactions