[Discover] Fix formatting and sorting for custom ES|QL vars#209360
[Discover] Fix formatting and sorting for custom ES|QL vars#209360jughosta merged 18 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
stratoula
left a comment
There was a problem hiding this comment.
yes this works great now 🙌 Thanx a ton Julia fir working on it (I didnt check the code, just tested the feature!)
davismcphee
left a comment
There was a problem hiding this comment.
Code changes look good, and it seems like it will also solve some other subtle issues, thanks! We might want to consider if this could be centralized at some point so ES|QL based data views include custom fields directly in their field lists, but not something for now at least.
| public readonly create = (field: FieldSpec): DataViewField => { | ||
| return new DataViewField({ ...field, shortDotsEnable }); | ||
| }; |
There was a problem hiding this comment.
I partly wonder if this would be more intuitive on the data views service instead since it doesn't actually modify the data view, but I don't feel strongly about it
There was a problem hiding this comment.
@davismcphee Yes, it might be a good location for it too. I wanted to keep it rather as a sync function but getting shortDotsEnable would require to make it async if defined for data views service.
Also should have mentioned it earlier, having this new create method allows to create data view field instances also from packages. DataViewField class is defined in the plugin and can be instantiated directly only in a plugin - we should probably move the whole class to a its own package at some point 🙃
There was a problem hiding this comment.
I wanted to keep it rather as a sync function but getting
shortDotsEnablewould require to make it async if defined for data views service.
Good point, I also ran into a similar issue when working on the "All logs" data view since I originally tried to add the cloning logic directly in the data views service as a sync method. There seemed to be a way to work around this by modifying the UI settings abstraction used by the data views service, but I decided against it to avoid expanding the scope of that work.
DataViewFieldclass is defined in the plugin and cannot be instantiated directly only in a plugin - we should probably move the whole class to a its own package at some point 🙃
++ This would probably be the best approach. I didn't clue in that this was a workaround for that limitation, but it would certainly be easier to manage if we could import and instantiate directly from packages.
|
@davismcphee Agree, centralizing it would be better. I considered doing it now too but there are some nuances:
As a side note here, there is definitely a room for optimizing ES|QL mode by skipping fields fetching when ES|QL data view is created. It would work faster. But we would still need to fetch the time field separately I guess. |
|
@jughosta Thanks for the additional context, it's insightful. I'm actually encountering similar obstacles with the state management work related to data view async methods too. I created a separate issue from those observations so we don't lose track of them: #210464. Please feel free to reformat or add any additional context to the issue since you've been working on it lately. |
|
Starting backport for target branches: 8.18, 8.x, 9.0 https://github.com/elastic/kibana/actions/runs/13260252055 |
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
History
cc @jughosta |
…209360) - Closes elastic#208020 ## Summary By default the data view (which is used in ES|QL mode) has only mapped fields as per field caps for the current index pattern. This PR dynamically extends with additional fields based on ES|QL meta information. This change helps to fix the formatting for ES|QL var values and fixes sorting on them. <img width="1673" alt="Screenshot 2025-02-03 at 18 42 14" src="https://github.com/user-attachments/assets/3647a375-f0f5-43e6-815d-d5a4292c637a" /> <img width="643" alt="Screenshot 2025-02-03 at 18 42 50" src="https://github.com/user-attachments/assets/9d84bc23-7665-43c1-8ac2-d67174b68c31" /> ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co> (cherry picked from commit 9635cfa)
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
…09360) (#210519) # Backport This will backport the following commits from `main` to `9.0`: - [[Discover] Fix formatting and sorting for custom ES|QL vars (#209360)](#209360) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"julia.rechkunova@elastic.co"},"sourceCommit":{"committedDate":"2025-02-11T09:58:51Z","message":"[Discover] Fix formatting and sorting for custom ES|QL vars (#209360)\n\n- Closes https://github.com/elastic/kibana/issues/208020\r\n\r\n## Summary\r\n\r\nBy default the data view (which is used in ES|QL mode) has only mapped\r\nfields as per field caps for the current index pattern. This PR\r\ndynamically extends with additional fields based on ES|QL meta\r\ninformation.\r\n\r\nThis change helps to fix the formatting for ES|QL var values and fixes\r\nsorting on them.\r\n\r\n<img width=\"1673\" alt=\"Screenshot 2025-02-03 at 18 42 14\"\r\nsrc=\"https://github.com/user-attachments/assets/3647a375-f0f5-43e6-815d-d5a4292c637a\"\r\n/>\r\n<img width=\"643\" alt=\"Screenshot 2025-02-03 at 18 42 50\"\r\nsrc=\"https://github.com/user-attachments/assets/9d84bc23-7665-43c1-8ac2-d67174b68c31\"\r\n/>\r\n\r\n\r\n### Checklist\r\n\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>","sha":"9635cfa5268c6250111f8eb5edcd693311a47193","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","Team:DataDiscovery","Feature:ES|QL","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[Discover] Fix formatting and sorting for custom ES|QL vars","number":209360,"url":"https://github.com/elastic/kibana/pull/209360","mergeCommit":{"message":"[Discover] Fix formatting and sorting for custom ES|QL vars (#209360)\n\n- Closes https://github.com/elastic/kibana/issues/208020\r\n\r\n## Summary\r\n\r\nBy default the data view (which is used in ES|QL mode) has only mapped\r\nfields as per field caps for the current index pattern. This PR\r\ndynamically extends with additional fields based on ES|QL meta\r\ninformation.\r\n\r\nThis change helps to fix the formatting for ES|QL var values and fixes\r\nsorting on them.\r\n\r\n<img width=\"1673\" alt=\"Screenshot 2025-02-03 at 18 42 14\"\r\nsrc=\"https://github.com/user-attachments/assets/3647a375-f0f5-43e6-815d-d5a4292c637a\"\r\n/>\r\n<img width=\"643\" alt=\"Screenshot 2025-02-03 at 18 42 50\"\r\nsrc=\"https://github.com/user-attachments/assets/9d84bc23-7665-43c1-8ac2-d67174b68c31\"\r\n/>\r\n\r\n\r\n### Checklist\r\n\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>","sha":"9635cfa5268c6250111f8eb5edcd693311a47193"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/209360","number":209360,"mergeCommit":{"message":"[Discover] Fix formatting and sorting for custom ES|QL vars (#209360)\n\n- Closes https://github.com/elastic/kibana/issues/208020\r\n\r\n## Summary\r\n\r\nBy default the data view (which is used in ES|QL mode) has only mapped\r\nfields as per field caps for the current index pattern. This PR\r\ndynamically extends with additional fields based on ES|QL meta\r\ninformation.\r\n\r\nThis change helps to fix the formatting for ES|QL var values and fixes\r\nsorting on them.\r\n\r\n<img width=\"1673\" alt=\"Screenshot 2025-02-03 at 18 42 14\"\r\nsrc=\"https://github.com/user-attachments/assets/3647a375-f0f5-43e6-815d-d5a4292c637a\"\r\n/>\r\n<img width=\"643\" alt=\"Screenshot 2025-02-03 at 18 42 50\"\r\nsrc=\"https://github.com/user-attachments/assets/9d84bc23-7665-43c1-8ac2-d67174b68c31\"\r\n/>\r\n\r\n\r\n### Checklist\r\n\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>","sha":"9635cfa5268c6250111f8eb5edcd693311a47193"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…209360) - Closes elastic#208020 ## Summary By default the data view (which is used in ES|QL mode) has only mapped fields as per field caps for the current index pattern. This PR dynamically extends with additional fields based on ES|QL meta information. This change helps to fix the formatting for ES|QL var values and fixes sorting on them. <img width="1673" alt="Screenshot 2025-02-03 at 18 42 14" src="https://github.com/user-attachments/assets/3647a375-f0f5-43e6-815d-d5a4292c637a" /> <img width="643" alt="Screenshot 2025-02-03 at 18 42 50" src="https://github.com/user-attachments/assets/9d84bc23-7665-43c1-8ac2-d67174b68c31" /> ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co> (cherry picked from commit 9635cfa) # Conflicts: # src/platform/packages/shared/kbn-discover-utils/src/__mocks__/data_view.ts # src/platform/packages/shared/kbn-unified-data-table/tsconfig.json # src/platform/plugins/shared/unified_doc_viewer/tsconfig.json
…209360) (#220069) # Backport This will backport the following commits from `main` to `8.19`: - [[Discover] Fix formatting and sorting for custom ES|QL vars (#209360)](#209360) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"julia.rechkunova@elastic.co"},"sourceCommit":{"committedDate":"2025-02-11T09:58:51Z","message":"[Discover] Fix formatting and sorting for custom ES|QL vars (#209360)\n\n- Closes https://github.com/elastic/kibana/issues/208020\r\n\r\n## Summary\r\n\r\nBy default the data view (which is used in ES|QL mode) has only mapped\r\nfields as per field caps for the current index pattern. This PR\r\ndynamically extends with additional fields based on ES|QL meta\r\ninformation.\r\n\r\nThis change helps to fix the formatting for ES|QL var values and fixes\r\nsorting on them.\r\n\r\n<img width=\"1673\" alt=\"Screenshot 2025-02-03 at 18 42 14\"\r\nsrc=\"https://github.com/user-attachments/assets/3647a375-f0f5-43e6-815d-d5a4292c637a\"\r\n/>\r\n<img width=\"643\" alt=\"Screenshot 2025-02-03 at 18 42 50\"\r\nsrc=\"https://github.com/user-attachments/assets/9d84bc23-7665-43c1-8ac2-d67174b68c31\"\r\n/>\r\n\r\n\r\n### Checklist\r\n\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>","sha":"9635cfa5268c6250111f8eb5edcd693311a47193","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","Team:DataDiscovery","Feature:ES|QL","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[Discover] Fix formatting and sorting for custom ES|QL vars","number":209360,"url":"https://github.com/elastic/kibana/pull/209360","mergeCommit":{"message":"[Discover] Fix formatting and sorting for custom ES|QL vars (#209360)\n\n- Closes https://github.com/elastic/kibana/issues/208020\r\n\r\n## Summary\r\n\r\nBy default the data view (which is used in ES|QL mode) has only mapped\r\nfields as per field caps for the current index pattern. This PR\r\ndynamically extends with additional fields based on ES|QL meta\r\ninformation.\r\n\r\nThis change helps to fix the formatting for ES|QL var values and fixes\r\nsorting on them.\r\n\r\n<img width=\"1673\" alt=\"Screenshot 2025-02-03 at 18 42 14\"\r\nsrc=\"https://github.com/user-attachments/assets/3647a375-f0f5-43e6-815d-d5a4292c637a\"\r\n/>\r\n<img width=\"643\" alt=\"Screenshot 2025-02-03 at 18 42 50\"\r\nsrc=\"https://github.com/user-attachments/assets/9d84bc23-7665-43c1-8ac2-d67174b68c31\"\r\n/>\r\n\r\n\r\n### Checklist\r\n\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>","sha":"9635cfa5268c6250111f8eb5edcd693311a47193"}},"sourceBranch":"main","suggestedTargetBranches":["8.18","8.19"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/210519","number":210519,"state":"MERGED","mergeCommit":{"sha":"3f49fd963f5d9386dcf47381d053d0e00cc8c37e","message":"[9.0] [Discover] Fix formatting and sorting for custom ES|QL vars (#209360) (#210519)\n\n# Backport\n\nThis will backport the following commits from `main` to `9.0`:\n- [[Discover] Fix formatting and sorting for custom ES|QL vars\n(#209360)](https://github.com/elastic/kibana/pull/209360)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n\n\nCo-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>"}},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/209360","number":209360,"mergeCommit":{"message":"[Discover] Fix formatting and sorting for custom ES|QL vars (#209360)\n\n- Closes https://github.com/elastic/kibana/issues/208020\r\n\r\n## Summary\r\n\r\nBy default the data view (which is used in ES|QL mode) has only mapped\r\nfields as per field caps for the current index pattern. This PR\r\ndynamically extends with additional fields based on ES|QL meta\r\ninformation.\r\n\r\nThis change helps to fix the formatting for ES|QL var values and fixes\r\nsorting on them.\r\n\r\n<img width=\"1673\" alt=\"Screenshot 2025-02-03 at 18 42 14\"\r\nsrc=\"https://github.com/user-attachments/assets/3647a375-f0f5-43e6-815d-d5a4292c637a\"\r\n/>\r\n<img width=\"643\" alt=\"Screenshot 2025-02-03 at 18 42 50\"\r\nsrc=\"https://github.com/user-attachments/assets/9d84bc23-7665-43c1-8ac2-d67174b68c31\"\r\n/>\r\n\r\n\r\n### Checklist\r\n\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>","sha":"9635cfa5268c6250111f8eb5edcd693311a47193"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
Summary
By default the data view (which is used in ES|QL mode) has only mapped fields as per field caps for the current index pattern. This PR dynamically extends with additional fields based on ES|QL meta information.
This change helps to fix the formatting for ES|QL var values and fixes sorting on them.
Checklist