Skip to content

[ES|QL] Clean STATS mutate summarise method#250688

Merged
sddonne merged 20 commits intoelastic:mainfrom
sddonne:clean-mutate
Jan 29, 2026
Merged

[ES|QL] Clean STATS mutate summarise method#250688
sddonne merged 20 commits intoelastic:mainfrom
sddonne:clean-mutate

Conversation

@sddonne
Copy link
Copy Markdown
Contributor

@sddonne sddonne commented Jan 28, 2026

Closes #250156

Summary

This PR gets rid of mutate.commands.stats.summarizeCommand in favour of adding grouping and aggregations to the sumarizeQuery method.

  • A bug that was producing wrong column names when using WHERE function within STATS has been solved.

Cleanup of the summary fields

  • usedFields has been removed from the summary.
  • column has been removed from the summary.
  • terminals has been removed from the summary and a helper has been added to extract it.
  • Relevant clients of the summary has been carefully refactored to adapt to the new signature.

* definition: <AST node representing 'field'>
* }
*/
definition: ESQLProperNode;
Copy link
Copy Markdown
Contributor Author

@sddonne sddonne Jan 28, 2026

Choose a reason for hiding this comment

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

I'm not totally kind in keeping this definition field here, IMO it's a derivative of arg, and we should provide a helper so the ones who need it can get it easily (similar to what I did with terminals).
For the moment added a better description to it as it was a bit difficult to differentiate between arg, definition, column and terminal.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I dont like it either tbh, I agree with this ++

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok will move it in a another PR then, as doing it here will bring more conflicts with #250560

@sddonne sddonne added Feature:ES|QL ES|QL related features in Kibana Team:ESQL ES|QL related features in Kibana t// v9.4.0 backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes labels Jan 28, 2026
@sddonne sddonne marked this pull request as ready for review January 28, 2026 14:01
@sddonne sddonne requested review from a team as code owners January 28, 2026 14:01
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-esql (Team:ESQL)

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/esql-language 664 666 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
datasetQuality 592.8KB 592.9KB +14.0B
discover 1.5MB 1.5MB +877.0B
lens 2.0MB 2.0MB +14.0B
securitySolution 10.8MB 10.8MB +15.0B
slo 1.1MB 1.1MB +14.0B
total +934.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/esql-language 49 50 +1
@kbn/esql-utils 4 5 +1
total +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
data 443.6KB 443.7KB +184.0B
kbnUiSharedDeps-srcJs 4.4MB 4.4MB +160.0B
slo 33.4KB 33.5KB +62.0B
total +406.0B
Unknown metric groups

API count

id before after diff
@kbn/esql-language 871 873 +2

Copy link
Copy Markdown
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

I like it! Some small comments that I do not need to check again so I am approving.

@eokoneyo take a look too please!

expectedGrouping: ['field1'],
},
{
description: 'STATS with assigned aggregation and assigned grouping columns',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seb add also a test for this

BY BUCKET(@timestamp,50,?_tstart,?_tend)

*/
renamedColumnsPairs?: Set<[string, string]>;

grouping?: Set<FieldSummary>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add some descriptions here as I have at the others

* definition: <AST node representing 'field'>
* }
*/
definition: ESQLProperNode;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I dont like it either tbh, I agree with this ++

Copy link
Copy Markdown
Contributor

@eokoneyo eokoneyo left a comment

Choose a reason for hiding this comment

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

Tested changes locally, LGTM... thanks for this

@sddonne sddonne merged commit 6eb6161 into elastic:main Jan 29, 2026
16 checks passed
@eokoneyo eokoneyo linked an issue Jan 29, 2026 that may be closed by this pull request
hannahbrooks pushed a commit to hannahbrooks/kibana that referenced this pull request Jan 30, 2026
Closes elastic#250156
## Summary
This PR gets rid of `mutate.commands.stats.summarizeCommand` in favour
of adding `grouping` and `aggregations` to the `sumarizeQuery` method.

* A bug that was producing wrong column names when using `WHERE`
function within `STATS` has been solved.

Cleanup of the summary fields
* `usedFields` has been removed from the summary.
* `column` has been removed from the summary.
* `terminals` has been removed from the summary and a helper has been
added to extract it.
* Relevant clients of the summary has been carefully refactored to adapt
to the new signature.

---------

Co-authored-by: Stratou <efstratia.kalafateli@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:ES|QL ES|QL related features in Kibana release_note:skip Skip the PR/issue when compiling release notes Team:ESQL ES|QL related features in Kibana t// v9.4.0

Projects

None yet

5 participants