-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ES|QL] Supports custom formatters in charts #201540
Conversation
Pinging @elastic/kibana-visualizations (Team:Visualizations) |
Pinging @elastic/kibana-esql (Team:ESQL) |
@@ -315,7 +315,14 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => { | |||
(body.all_columns ?? body.columns)?.map(({ name, type }) => ({ | |||
id: name, | |||
name, | |||
meta: { type: esFieldTypeToKibanaFieldType(type), esType: type }, | |||
meta: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being not familiar with this are of the code, and Lukas being on PTO, I wonder, how can this be tested in the DataDiscovery world? thx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go to discover, switch to esql mode and enter a query which contains | WHERE @timestamp >= ?_tstart AND @timestamp <= ?_tend | STATS ....
, save this to a new dashboard
now change a query to add a new field, remove the auto added dimension, manually add a new dimension, or change an existing one ... the field list is empty on main, but contains correct fields on this branch
x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/datasources/text_based/components/dimension_editor.tsx
Outdated
Show resolved
Hide resolved
46eb97e
to
bc3ec1f
Compare
0b10597
to
f531765
Compare
{!isFullscreen && ( | ||
<div className="lnsIndexPatternDimensionEditor--padded lnsIndexPatternDimensionEditor--collapseNext"> | ||
{selectedField && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can bring selectedField
up to the initial condition and remove it from the rest of this code.
{!isFullscreen && ( | |
<div className="lnsIndexPatternDimensionEditor--padded lnsIndexPatternDimensionEditor--collapseNext"> | |
{selectedField && ( | |
{!isFullscreen && selectedField && ( | |
<div className="lnsIndexPatternDimensionEditor--padded lnsIndexPatternDimensionEditor--collapseNext"> | |
x-pack/plugins/lens/public/datasources/text_based/to_expression.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/datasources/text_based/to_expression.ts
Outdated
Show resolved
Hide resolved
.filter((col) => col.params?.format) | ||
.map((col) => { | ||
// TODO: improve the type handling here | ||
const format = col.params!.format!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.filter((col) => col.params?.format) | |
.map((col) => { | |
// TODO: improve the type handling here | |
const format = col.params!.format!; | |
.filter((col): col is TextBasedLayerColumn & {params: {format: ValueFormatConfig}} => col.params?.format) | |
.map((col) => { | |
const format = col.params.format; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesnt seem to work
Type 'ValueFormatConfig | undefined' is not assignable to type 'boolean'.
Type 'undefined' is not assignable to type 'boolean'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.filter((col): col is TextBasedLayerColumn & { params: { format: ValueFormatConfig } } =>
Boolean(col.params?.format)
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this really better from what we currently have ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates a type guard that is the way to fix col.params!.format!;
in this place.
You can move the filter/typeguard function outside this code to make it a bit less verbose.
x-pack/plugins/lens/public/datasources/text_based/components/dimension_editor.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ResponseOps LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I havent tested yet but the change in fetchFieldsFromESQL
seems to affect the editor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works great and is a nice addition, kudos Peter
I updated the labels as I think it should go to 8.18 and also be added on our release notes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a last minor change as comment, it will be nice if that can be fixed, otherwise we can revisit it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataDiscovery Code LGTM, tested locally and works as expected. It's a nice enhancement 👍
💚 Build Succeeded
Metrics [docs]Async chunks
Page load bundle
History
|
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/12269844696 |
(cherry picked from commit 168e67d)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
# Backport This will backport the following commits from `main` to `8.x`: - [[ES|QL] Supports custom formatters in charts (#201540)](#201540) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Peter Pisljar","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-11T04:45:05Z","message":"[ES|QL] Supports custom formatters in charts (#201540)","sha":"168e67d50d2d36110ba26f130f381da96ddf163e","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Team:Visualizations","v9.0.0","Feature:ES|QL","Team:ESQL","backport:version","v8.18.0"],"title":"[ES|QL] Supports custom formatters in charts","number":201540,"url":"https://github.com/elastic/kibana/pull/201540","mergeCommit":{"message":"[ES|QL] Supports custom formatters in charts (#201540)","sha":"168e67d50d2d36110ba26f130f381da96ddf163e"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201540","number":201540,"mergeCommit":{"message":"[ES|QL] Supports custom formatters in charts (#201540)","sha":"168e67d50d2d36110ba26f130f381da96ddf163e"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Peter Pisljar <[email protected]>
Summary
adds labeling and formatting supports to esql charts