Skip to content

ESQL: Implement TO_STRING for exponential_histogram#138884

Merged
JonasKunz merged 8 commits intoelastic:mainfrom
JonasKunz:esql-exponential-histo-tostring
Dec 5, 2025
Merged

ESQL: Implement TO_STRING for exponential_histogram#138884
JonasKunz merged 8 commits intoelastic:mainfrom
JonasKunz:esql-exponential-histo-tostring

Conversation

@JonasKunz
Copy link
Copy Markdown
Contributor

@JonasKunz JonasKunz commented Dec 2, 2025

exponential_histogram would have been the only type without TO_STRING support.
While this function is not necessarily very useful on this type, it might be used in explorative use-cases.

As it is not much effort, I decided to just add it.
The implementation will output a string containing the exponential histogram serialized as JSON.

@elasticsearchmachine elasticsearchmachine added v9.3.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Dec 2, 2025
@JonasKunz JonasKunz marked this pull request as ready for review December 2, 2025 15:45
@JonasKunz JonasKunz requested a review from dnhatn December 2, 2025 15:45
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Dec 2, 2025
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

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

Thanks Jonas!

if (this.processFunction.args.getFirst() instanceof StandardArgument == false) {
throw new IllegalArgumentException("first argument must be the field to process");
}
argument = (StandardArgument) this.processFunction.args.getFirst();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!


@ConvertEvaluator(extraName = "FromExponentialHistogram")
static BytesRef fromExponentialHistogram(ExponentialHistogram histogram) {
return new BytesRef(exponentialHistogramToString(histogram));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We convert to a string in exponentialHistogramToString (from a byte array), then convert to BytesRef here. However, since performance is not a concern for this method, it is perfectly fine to keep it this way instead of adding an exponentialHistogramToBytesRef method.

@JonasKunz JonasKunz merged commit cf6ffeb into elastic:main Dec 5, 2025
34 checks passed
@JonasKunz JonasKunz deleted the esql-exponential-histo-tostring branch December 5, 2025 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL external-contributor Pull request authored by a developer outside the Elasticsearch team >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants