Skip to content

[Lens] Fix timefield hydration for API generated charts#263481

Closed
markov00 wants to merge 9 commits intoelastic:mainfrom
markov00:2026_04_15-fix_timefield_esql_api
Closed

[Lens] Fix timefield hydration for API generated charts#263481
markov00 wants to merge 9 commits intoelastic:mainfrom
markov00:2026_04_15-fix_timefield_esql_api

Conversation

@markov00
Copy link
Copy Markdown
Contributor

@markov00 markov00 commented Apr 15, 2026

Summary

API generated charts currently doesn't contain information if a XY chart is actually a time based chart or a categorical chart.
We have left this information to be computed/decided at runtime (as it's currently done when you create a chart from the Lens UI).
But information about the current timeField is required:

  • to filter the chart in the configured time range
  • to property assign the X axis scale type

This PR fixes this problem (better then the predecessor PR) by hydrating the state at the time of the deserialization.
This can't be done in a later stage (like after the data is received) because we need the timeField information to add the proper DSL filter on top of the ESQL query.

For ESQL folks, I've just extracted the getESQLTimeField into its own file, so it can be easily reused without the need to touch the DataViews as it was initially used.
In our hydration we also need to add the correct meta.type to the column specified at the API level. Because column name and timeField can differ, I've temporarly implemented a function that uses the getQuerySummary to get actual column names associated with possible bucketing aggregations (TBUCKET, BUCKET, DATE_TRUNC) and we use this to match the actual column name described by the API user and associate the proper meta.type.

The previous ensureESQLTimeFieldOnAdHocDataViews was replaced with the hydrateESQLTimeFields.

A set of scout tests are in place to evaluate eventual regressions.

fix #262425
fix #262181

@markov00 markov00 added bug Fixes for quality problems that affect the customer experience Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// release_note:skip Skip the PR/issue when compiling release notes Feature:Lens backport:version Backport to applied version labels v9.4.0 labels Apr 15, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Apr 15, 2026

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!
  • Click to trigger kibana-storybooks-from-pr for this PR!

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Apr 15, 2026

Catch flakiness early (recommended)

Recommended before merge: run the flaky test runner against this PR to catch flakiness early.

Trigger a run with the Flaky Test Runner UI or post this comment on the PR:

/flaky scoutConfig:x-pack/platform/plugins/shared/lens/test/scout/ui/parallel.playwright.config.ts:30

This check is experimental. Share your feedback in the #appex-qa channel.

Posted via Macroscope — Flaky Test Runner nudge

@elastic elastic deleted a comment from elasticmachine Apr 16, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Apr 16, 2026

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] affected Scout: [ platform / lens ] plugin / local-stateful-classic - Lens ES|QL timeseries via dashboard API - renders a time-scaled x-axis for TBUCKET
  • [job] [logs] affected Scout: [ platform / lens ] plugin / local-stateful-classic - Lens ES|QL timeseries via dashboard API - renders a time-scaled x-axis for TBUCKET

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
agentBuilder 1382 1383 +1
alertingVTwo 888 889 +1
apm 2125 2126 +1
cases 1992 1993 +1
cloudSecurityPosture 768 769 +1
console 384 385 +1
controls 427 428 +1
dashboard 1121 1122 +1
dashboardAgent 613 614 +1
data 628 629 +1
datasetQuality 1073 1074 +1
dataVisualizer 877 878 +1
discover 2003 2004 +1
esql 987 988 +1
esqlDataGrid 437 438 +1
eventAnnotationListing 703 704 +1
fleet 1688 1689 +1
infra 1862 1863 +1
lens 1736 1738 +2
lists 469 470 +1
logsShared 448 449 +1
maps 1375 1376 +1
ml 4268 4269 +1
observability 1740 1741 +1
observabilityAIAssistantApp 907 908 +1
observabilityLogsExplorer 254 255 +1
osquery 757 758 +1
queryActivity 256 257 +1
searchPlayground 591 592 +1
securitySolution 9252 9253 +1
slo 1332 1333 +1
stackAlerts 231 232 +1
streamsApp 1841 1842 +1
triggersActionsUi 1441 1442 +1
unifiedDocViewer 956 957 +1
visTypeVega 1831 1832 +1
workflowsManagement 1583 1584 +1
total +38

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-utils 141 144 +3

Async chunks

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

id before after diff
agentBuilder 1.1MB 1.1MB +61.0B
alertingVTwo 636.2KB 636.3KB +62.0B
dashboard 1.1MB 1.1MB +63.0B
data 27.3KB 27.3KB +69.0B
dataVisualizer 618.2KB 618.2KB +62.0B
discover 1.9MB 1.9MB +62.0B
esql 831.4KB 831.4KB +62.0B
lens 2.0MB 2.0MB -1.0KB
maps 3.2MB 3.2MB +62.0B
observabilityAIAssistantApp 670.0KB 670.1KB +61.0B
stackAlerts 88.5KB 88.5KB +58.0B
total -403.0B

Page load bundle

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

id before after diff
dashboard 19.2KB 19.2KB +1.0B
data 442.6KB 442.6KB +3.0B
lens 83.8KB 86.3KB +2.5KB
total +2.5KB
Unknown metric groups

API count

id before after diff
@kbn/esql-utils 211 215 +4

ESLint disabled line counts

id before after diff
@kbn/esql-utils 3 4 +1

Total ESLint disabled count

id before after diff
@kbn/esql-utils 3 4 +1

History

@markov00 markov00 closed this Apr 20, 2026
@markov00
Copy link
Copy Markdown
Contributor Author

replaced by #264134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels bug Fixes for quality problems that affect the customer experience Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Lens as code] Bug when creating a ES|QL panel with TBUCKET [Lens API] panels created via API don't respond to time picker

2 participants