Skip to content
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

[Lens][Datatable] Fix share export and inspect data #193780

Merged
merged 25 commits into from
Oct 24, 2024

Conversation

nickofthyme
Copy link
Contributor

@nickofthyme nickofthyme commented Sep 23, 2024

Summary

This PR fixes #187551 where the table provided in the inspector and the share export, did not match what was visible in the table.

Changes

Viewing the datatable from Inspect action

Zight.Recording.2024-09-23.at.02.06.10.PM.mp4

Exporting table to csv via the Share action

  • Now exports only the transposed data table.
  • Fixes column ordering of transposed data. Transposed metrics are zipped together by like terms (i.e. ['css › X', 'css › Y', 'deb › X', 'deb › Y']).
  • Now sorts rows based on active column sorting parameters (only for export not inspect). Always places null values at the bottom to match eui behavior.
image

The Lens table above would output a csv that shows as shown below (in Numbers).

image

Or in raw form as.

"Top 3 values of agent.keyword","(empty) › Count of records","gz › Count of records","css › Count of records","zip › Count of records","deb › Count of records"
"Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1",268,131,122,81,70
"Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24",235,109,98,81,68
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)",210,93,82,64,52

Checklist

- Add transposed table to list of tables
- Fix table select dropdown styles
- export transpose datatable from share
- support sorting transposed columns
- sort transposed columns by args column order (zippered)
- removed hidden columns from share output
- sort rows when column sorting is present
- push empty value to bottom
- Set transposed table as default selection in inspector
- Export only transposed table on share
- Remove unused prop-types
@nickofthyme nickofthyme added Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens labels Sep 23, 2024
Copy link
Contributor Author

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

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

Comments to reviewers

Copy link
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

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

Initial code review

src/plugins/data/common/exports/export_csv.tsx Outdated Show resolved Hide resolved
src/plugins/data/common/exports/export_csv.tsx Outdated Show resolved Hide resolved
src/plugins/data/common/exports/export_csv.tsx Outdated Show resolved Hide resolved
- used sorted column order from state
- use column order from transposed table via activeData
- remove transpose logic from csv export logic
- use prepareLogTable to strip out ghost columns ids from formulas
…rted to the csv export utility

- move column & row sorting into vis definition
- use `@kbn/sort-predicates` to sort rows
- remove sorted columns logic
- remove column sorting logic
- remove circular dep issue with transpose-helpers pkg
- split transpose logic to share only id util functions
- move transpose table logic back to plugin
- rename pkg to utils instead of helpers
- fixup failing tests from transpose sorting changes
@nickofthyme nickofthyme marked this pull request as ready for review October 22, 2024 03:48
@nickofthyme nickofthyme requested review from a team as code owners October 22, 2024 03:48
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

@nickofthyme nickofthyme added release_note:fix backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Oct 22, 2024
Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

kibana-presentation changes LGTM
code review only

@botelastic botelastic bot added the Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) label Oct 22, 2024
Copy link
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

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

Tested, approving for not blocking this.

Few observations who could be addressed in a follow up:

  • While now there's the option to select between tables in the Inspector > Data page, there's no clear distinctions nor explanation on why there are multiple tables. Better namings here would help (out of scope of this PR)
  • The download now leads to multiple downloads with generic names Inspector 1 and Inspector 2 which has the same issue as before: why 2 files? Which one is the transposed one? (Out of scope of this PR)
  • I've noticed some performance hit when switching between Request and Data page in the inspector when there's a Split by metric. (Out of scope of this PR)

@nickofthyme
Copy link
Contributor Author

Thanks @dej611 as for...

While now there's the option to select between tables in the Inspector > Data page, there's no clear distinctions nor explanation on why there are multiple tables. Better namings here would help.

Yeah I agree, I thought about changing this to allow tables to have titles and descriptions but it's been unchanged for 4 years, so I just left as is.

The download now leads to multiple downloads with generic names Inspector 1 and Inspector 2 which has the same issue as before: why 2 files? Which one is the transposed one?

Yeah this is the default behavior. The names could be better as mentioned above. I changed this on the share to export just the final table but not in the inspector downloads. I think adding options to the TablesAdapter to configure this would be great. Opened #197555 for both issues.

I've noticed some performance hit when switching between Request and Data page in the inspector when there's a Split by metric. (Out of scope of this PR)

I can take a look at this to see if there's duplicate code execution somewhere.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
expressionHeatmap 178 179 +1
lens 1466 1463 -3
total -2

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/transpose-utils - 7 +7
expressions 1765 1769 +4
lens 589 590 +1
total +12

Async chunks

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

id before after diff
data 48.0KB 48.1KB +98.0B
expressionHeatmap 26.7KB 26.8KB +62.0B
lens 1.5MB 1.5MB +3.2KB
total +3.4KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
lens 62 63 +1

Page load bundle

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

id before after diff
data 419.9KB 419.9KB -68.0B
expressions 99.8KB 100.3KB +434.0B
lens 51.4KB 50.6KB -859.0B
total -493.0B
Unknown metric groups

API count

id before after diff
@kbn/transpose-utils - 9 +9
expressions 2235 2241 +6
lens 691 692 +1
total +16

History

@nickofthyme nickofthyme merged commit a854ff8 into elastic:main Oct 24, 2024
38 checks passed
@nickofthyme nickofthyme deleted the fix-table-exports branch October 24, 2024 16:51
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11503862348

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 24, 2024
The exported table data table provided in the inspector and the share export now match what was visible in the UI.

(cherry picked from commit a854ff8)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 24, 2024
…197696)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Lens][Datatable] Fix share export and inspect data
(#193780)](#193780)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nick
Partridge","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-24T16:51:38Z","message":"[Lens][Datatable]
Fix share export and inspect data (#193780)\n\nThe exported table data
table provided in the inspector and the share export now match what was
visible in the
UI.","sha":"a854ff8a4e4f81397cebde70adc31e4ee893ce34","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:ExpressionLanguage","Team:Visualizations","Feature:Lens","v9.0.0","backport:prev-minor"],"title":"[Lens][Datatable]
Fix share export and inspect
data","number":193780,"url":"https://github.com/elastic/kibana/pull/193780","mergeCommit":{"message":"[Lens][Datatable]
Fix share export and inspect data (#193780)\n\nThe exported table data
table provided in the inspector and the share export now match what was
visible in the
UI.","sha":"a854ff8a4e4f81397cebde70adc31e4ee893ce34"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193780","number":193780,"mergeCommit":{"message":"[Lens][Datatable]
Fix share export and inspect data (#193780)\n\nThe exported table data
table provided in the inspector and the share export now match what was
visible in the
UI.","sha":"a854ff8a4e4f81397cebde70adc31e4ee893ce34"}}]}] BACKPORT-->

Co-authored-by: Nick Partridge <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) Feature:Lens release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Fix issue downloading tables to CSV that contain "Split metrics by"
6 participants