Skip to content

[ES|QL] Support new exponential_histogram ES Field type#242748

Merged
bartoval merged 7 commits intoelastic:mainfrom
bartoval:support_esql_extended_histogram
Nov 18, 2025
Merged

[ES|QL] Support new exponential_histogram ES Field type#242748
bartoval merged 7 commits intoelastic:mainfrom
bartoval:support_esql_extended_histogram

Conversation

@bartoval
Copy link
Contributor

@bartoval bartoval commented Nov 12, 2025

Summary

https://github.com/elastic/elasticsearch/blob/main/x-pack/plugin/esql/qa/testFixtures/src/main/resources/data/exp_histo_sample.csv

#242699

From the dev tool

PUT test-histogram
{
  "mappings": {
    "properties": {
       "@timestamp": {"type": "date"}, 
        "response_time": {"type": "exponential_histogram"}
      }
   }
}
POST /test-histogram/_doc
{
  "@timestamp": "2025-11-12T17:00:00Z",
   "response_time": {
      "scale": 0,
      "positive": {
      "indices": [0, 1, 2],
      "counts": [5, 10, 3]
    }
  }
}
screen
@bartoval bartoval requested a review from a team November 12, 2025 17:20
@bartoval bartoval requested a review from a team as a code owner November 12, 2025 17:20
@bartoval bartoval self-assigned this Nov 12, 2025
@bartoval bartoval added release_note:fix backport:skip This PR does not require backporting Feature:ES|QL ES|QL related features in Kibana Team:ESQL ES|QL related features in Kibana t// v9.3.0 labels Nov 12, 2025
@elasticmachine
Copy link
Contributor

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

@davismcphee
Copy link
Contributor

@jughosta Tagging you for the review on this as the most familiar on our end with the field types code.

Also a heads up @drewdaemon about bundle size increases, which seem fairly significant for such a small change. Maybe this is a case where we'd benefit from adding the fields packages to our shared deps bundle so we only take the hit once? Didn't look into it though, just for awareness.

@davismcphee davismcphee requested a review from jughosta November 13, 2025 02:20
@bartoval bartoval force-pushed the support_esql_extended_histogram branch from f5149a5 to 5b4d82d Compare November 13, 2025 06:41
Copy link
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.

Shouldn't we added this also here? src/platform/packages/shared/kbn-esql-ast/src/definitions/types.ts

In order when the definitions get updated and the function support this field type to have it ready (check the type in the signatures, here for example src/platform/packages/shared/kbn-esql-ast/src/definitions/generated/aggregation_functions.ts)

@bartoval bartoval force-pushed the support_esql_extended_histogram branch from 5b4d82d to 5b6ac96 Compare November 13, 2025 10:32
rank_features: { iconType: 'tokenRankFeatures' },
histogram: { iconType: 'tokenHistogram' },
exponential_histogram: { iconType: 'tokenHistogram' },
tdigest: { iconType: 'tokenHistogram' },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

???

I don't see any other options

Copy link
Contributor

Choose a reason for hiding this comment

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

What is tdigest?

Copy link
Contributor Author

@bartoval bartoval Nov 13, 2025

Choose a reason for hiding this comment

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

ah sorry, the Issue was updated #242699

elastic/elasticsearch#137649

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is ok to use the same. These 2 field types are connected with histograms. ES is going to add support for the existing histogram type in ESQL by casting to one of these

@bartoval
Copy link
Contributor Author

it’s quicker to ask here....

The tdigest follows all the same steps as exponential_histogram.
I created the index and also inserted the values into Elasticsearch, and got a 200 response. (following instinct and reading elastic/elasticsearch#137546)

But here I don’t see any icons for response_time , and what I see in discover is null.
Why?

PUT /test-tdigest
{
   "mappings": {
   "properties": {
       "@timestamp": {
       "type": "date"
    },
    "response_time": {
     "type": "tdigest"
    }
  }
 }
}
POST /test-tdigest/_doc
{
   "@timestamp": "2025-11-13T10:00:00Z",
   "response_time": {
      "centroids": [2.0, 3.4],
      "counts": [1, 4]
  }
}

also
src/platform/packages/shared/kbn-field-utils/src/utils/field_type.ts
src/platform/packages/shared/kbn-field-utils/src/utils/get_field_type_name.ts

should the info be added here too?

@stratoula
Copy link
Contributor

stratoula commented Nov 13, 2025

Do you mean that when you run this index in discovr, you dont see this column??

If yes, then this is possibly happening because they don't support this part yet. It is ok though I think, we can add support at kibana

@bartoval
Copy link
Contributor Author

bartoval commented Nov 13, 2025

Do you mean that when you run this index in discovr, you dont see this column??

If yes, then this is possibly happening because they don't support this part yet. It is ok though I think, we can add support at kibana

yes I think so. Elastic side data exist

aa but these values exists kkk
Copy link
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 didnt test again, code review only, LGTM!

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

LGTM 👍

exponential_histogram still shows up in the breakdown dropdown though. Maybe it's a bug in the utils we have for filtering it.

@jughosta
Copy link
Contributor

How about we modify the following utils to exclude these new types?

@bartoval
Copy link
Contributor Author

bartoval commented Nov 14, 2025

How about we modify the following utils to exclude these new types?

Is that a bad idea ? (in esql_fields_utils.ts)
``

in the function isGroupable add

import { getKbnFieldType } from '@kbn/field-types';
....
if (type) {
    const kbnFieldType = getKbnFieldType(type);
       if (!kbnFieldType.filterable) {
        return false;
}
@jughosta
Copy link
Contributor

Hm, not sure about it. If we had !kbnFieldType.aggregatable then I think it would fit better. Otherwise, we can check for these new types directly.

Also, I can't remember why isESQLFieldGroupable is used in the sidebar for checking for the breakdown button. Why not the same fieldSupportsBreakdown. @stratoula, do you know? Anyway, it might be something for a follow up work.

@bartoval
Copy link
Contributor Author

bartoval commented Nov 14, 2025

Hm, not sure about it. If we had !kbnFieldType.aggregatable then I think it would fit better. Otherwise, we can check for these new types directly.

Also, I can't remember why isESQLFieldGroupable is used in the sidebar for checking for the breakdown button. Why not the same fieldSupportsBreakdown. @stratoula, do you know? Anyway, it might be something for a follow up work.

it can be a check also in is own parent field_list_item.tsx. There is a flag called isBreackdownSupported and it call this function.

These are just ideas to avoid putting TODO and then manually removing them in the future (if I understand correctly this breackdown button should be disabled for the condition filterable false as a role)

@bartoval
Copy link
Contributor Author

ok @jughosta I applied your suggestions, Thanks!

@bartoval bartoval force-pushed the support_esql_extended_histogram branch from 98d296a to 86381e6 Compare November 14, 2025 16:11
@stratoula
Copy link
Contributor

stratoula commented Nov 17, 2025

@jughosta @bartoval

fieldSupportsBreakdown

The BY operator in ES|QL is not an aggregation. In DSL you are applying the terms aggregation to create the breakdown, this is why you are checking if the field is aggregateble or not.

In ES|QL you cant have the same checks. The BY operator allows more capabilities and fields to create the breakdown and this is why we have different flags

@stratoula
Copy link
Contributor

These are just ideas to avoid putting TODO and then manually removing them in the future (if I understand correctly this breackdown button should be disabled for the condition filterable false as a role)

This is not great I agree, but you can't use the isFilterable either. Neither the iisAggregatabler though (this is a DSL thingy). One field type can be used in where but is not supported in the BY. We could create an isGroupable flag but again you would need to change it to true when ES adds support.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
aiops 526.1KB 527.7KB +1.6KB
apm 2.8MB 2.8MB +738.0B
cases 1.4MB 1.4MB +306.0B
cloudSecurityPosture 641.3KB 642.1KB +824.0B
console 197.2KB 197.5KB +302.0B
controls 486.5KB 486.8KB +306.0B
dashboard 663.3KB 663.6KB +302.0B
datasetQuality 427.0KB 427.8KB +863.0B
dataViewManagement 141.1KB 141.8KB +738.0B
dataVisualizer 602.1KB 603.3KB +1.2KB
discover 1.2MB 1.2MB +2.2KB
embeddableAlertsTable 1000.4KB 1000.7KB +306.0B
enterpriseSearch 947.6KB 948.0KB +392.0B
esql 574.4KB 575.5KB +1.1KB
esqlDataGrid 148.8KB 149.6KB +824.0B
eventAnnotationListing 205.9KB 206.6KB +738.0B
graph 372.5KB 372.6KB +86.0B
indexManagement 705.5KB 705.6KB +86.0B
lens 1.6MB 1.6MB +1.2KB
lists 128.8KB 129.1KB +306.0B
maps 3.1MB 3.1MB +86.0B
ml 5.4MB 5.4MB +378.0B
observability 1.7MB 1.7MB +584.0B
onechat 420.4KB 420.7KB +302.0B
presentationUtil 67.2KB 67.9KB +732.0B
securitySolution 11.1MB 11.1MB +1.2KB
slo 983.8KB 985.4KB +1.6KB
stackAlerts 68.0KB 68.3KB +388.0B
streamsApp 941.6KB 941.9KB +390.0B
transform 624.6KB 624.9KB +388.0B
triggersActionsUi 1.5MB 1.5MB +306.0B
unifiedDocViewer 276.3KB 277.4KB +1.1KB
unifiedSearch 389.7KB 390.1KB +388.0B
workflowsManagement 2.1MB 2.1MB +388.0B
total +22.3KB

Page load bundle

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

id before after diff
data 441.0KB 441.3KB +302.0B
dataViewFieldEditor 23.2KB 23.5KB +302.0B
dataViews 62.5KB 62.8KB +302.0B
dataVisualizer 27.3KB 27.6KB +302.0B
fieldFormats 58.0KB 58.2KB +302.0B
kbnUiSharedDeps-srcJs 4.0MB 4.0MB +92.0B
lens 63.7KB 64.0KB +302.0B
maps 40.9KB 41.2KB +302.0B
osquery 42.1KB 42.2KB +86.0B
total +2.2KB

History

cc @bartoval

@jughosta
Copy link
Contributor

Thanks for updating the utils!

@bartoval bartoval merged commit 8d17e44 into elastic:main Nov 18, 2025
12 checks passed
eokoneyo pushed a commit to eokoneyo/kibana that referenced this pull request Dec 2, 2025
## Summary

https://github.com/elastic/elasticsearch/blob/main/x-pack/plugin/esql/qa/testFixtures/src/main/resources/data/exp_histo_sample.csv

elastic#242699

From the dev tool

```bash
PUT test-histogram
{
  "mappings": {
    "properties": {
       "@timestamp": {"type": "date"}, 
        "response_time": {"type": "exponential_histogram"}
      }
   }
}
```

```bash
POST /test-histogram/_doc
{
  "@timestamp": "2025-11-12T17:00:00Z",
   "response_time": {
      "scale": 0,
      "positive": {
      "indices": [0, 1, 2],
      "counts": [5, 10, 3]
    }
  }
}
```

<img width="1060" height="484" alt="screen"
src="https://github.com/user-attachments/assets/a20992ee-c089-4ea2-b3c4-ea93f16adadd"
/>
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:enhancement Team:ESQL ES|QL related features in Kibana t// v9.3.0

6 participants