Skip to content

Conversation

@astefan
Copy link
Contributor

@astefan astefan commented Sep 8, 2025

No description provided.

@astefan astefan added >bug test-release Trigger CI checks against release build :Analytics/ES|QL AKA ESQL v9.2.0 labels Sep 8, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @astefan, I've created a changelog YAML for you.

@astefan astefan marked this pull request as ready for review September 8, 2025 17:20
@astefan astefan removed the test-release Trigger CI checks against release build label Sep 8, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Sep 8, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@astefan astefan added the test-release Trigger CI checks against release build label Sep 8, 2025
b.set(STATS.ordinal());
} else {
plan.forEachDownMayReturnEarly((p, breakEarly) -> {
if (p instanceof UnaryPlan up && up.child() instanceof Aggregate && p instanceof InlineStats == false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this track correctly an Aggregate child of a binary plan? ... | STATS ... | LOOKUP JOIN ...

(Slightly off topic: this is one more case where a back reference to the parent would help. Don't know if we ever considered it.)

An alternative might be to just count Aggregate and InlineStats and subtract agg's count by inlinestats' and only set the bit if the result is non-zero. Don't know if it'd be prettier, though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this track correctly an Aggregate child of a binary plan?

I think it will, forEachDownMayReturnEarly applies to all the children

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it doesn't correctly count the Aggregates in that specific case @luigidellaquila. @bpintea is correct, I rushed this PR. Thank you for spotting this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, my bad, now I see it. The case where the Aggregate is a direct child of an N-ary plan

Copy link
Contributor

@luigidellaquila luigidellaquila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @astefan, LGTM

I wonder if, in the long term, we could refactor this and unify it with APM telemetry, accounting for commands at parse time.
It would save us from dealing with special cases like this one, where we build complex plans from a single command.

@astefan
Copy link
Contributor Author

astefan commented Sep 9, 2025

Thanks @astefan, LGTM

I wonder if, in the long term, we could refactor this and unify it with APM telemetry, accounting for commands at parse time. It would save us from dealing with special cases like this one, where we build complex plans from a single command.

On the first look, it can help us, but it needs a deep dive to see if there are any things we are missing. Thank you for this suggestion, if you believe it's worth a github issue not to lose track of it, please go ahead and create one.

Catching issues like that one boils down to two main things: having a test for it (which is really hard given the wide range of queries telemetry is used for) which unfortunately it's also the case of counting metrics at parsing time, having a good imagination for things to try out and know the code that could lead to an issue.

@astefan astefan requested a review from bpintea September 9, 2025 13:29
Copy link
Contributor

@bpintea bpintea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +504 to +521
assertEquals(0, dissect(c));
assertEquals(0, eval(c));
assertEquals(0, grok(c));
assertEquals(0, limit(c));
assertEquals(0, sort(c));
assertEquals(0, stats(c));
assertEquals(1L, where(c));
assertEquals(0, enrich(c));
assertEquals(0, mvExpand(c));
assertEquals(0, show(c));
assertEquals(0, row(c));
assertEquals(1L, from(c));
assertEquals(0, drop(c));
assertEquals(0, keep(c));
assertEquals(0, rename(c));
assertEquals(1L, inlinestats(c));
assertEquals(0, lookupjoin(c));
assertEquals(1, function("max", c));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth at some point to refactor this list and somehow only provide the non-zero counters to a checking function that would also assert on all the rest being 0. Maybe when we'd consider tapping the parser for usage.

@astefan astefan added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Sep 9, 2025
@elasticsearchmachine elasticsearchmachine merged commit 1a9ff77 into elastic:main Sep 10, 2025
36 checks passed
@astefan astefan deleted the inlinestats_telemetry branch September 10, 2025 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) test-release Trigger CI checks against release build v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants