Skip to content

Conversation

kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 9.1:

Questions ?

Please refer to the Backport tool documentation

## Summary

When a table from a dashboard using the **Download CSV** action, the
column sort order visible in the table on the dashboard are preserved in
the csv output.

https://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a

Fixes elastic#236550

## Details

The `datatable_fn` is used to set the table of data to the `adapters`,
which is the data used in the csv export action. This data comes in out
of order with additional `Part of X` columns for formula columns.
However, we do not sort these in before passing to the adapters.
Normally, with formulas, this is not a problem as the columns are in the
correct order but the
[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)
logic mixes up the column order for formulas.

The fix is to simply sort the columns in the table before passing it to
the `adapters.`

### 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
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

## Release Note

Fixes a bug in the Lens table in which exporting the table from a
dashboard, which containg formula columns, can result in a different
column order than shown on the dashboard.

Co-authored-by: Marco Liberati <[email protected]>
(cherry picked from commit ef105c5)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Sep 30, 2025
@kibanamachine kibanamachine enabled auto-merge (squash) September 30, 2025 16:53
@kibanamachine kibanamachine merged commit 2f93cc8 into elastic:9.1 Sep 30, 2025
12 checks passed
@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
lens 1.5MB 1.5MB +188.0B

History

cc @nickofthyme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport This PR is a backport of another PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants