Skip to content

ESQL: merge STATS | INLINE STATS #139768

@alex-spies

Description

@alex-spies

I think there are interesting queries where we're interested both in per-group stats and global stats, like so:

...
| INLINE STATS total_median = MEDIAN(field)
| STATS per_group_median = MEDIAN(field), total_median = VALUES(total_median) BY group

or so:

...
| STATS per_group_min = MIN(field) BY group
| INLINE STATS total_min = min(per_group_min)

or:

...
| STATS ... BY b = BUCKET(field, 1 year), group
| INLINE STATS min_b = MIN(b)

Normally, INLINE STATS needs to run the first part of the query twice. That's wasteful. We're already aggregating. It'd be much nicer if we could compute the INLINE STATS alongside the STATS.

That's currently not possible because the INLINE STATS do not have a BY in these examples - so we'd need a way to compute an agg function over all values alongside agg functions that are per grouping.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions