-
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
[Datatable] missing percentage column and wrong headers on export formatted csv #66883
[Datatable] missing percentage column and wrong headers on export formatted csv #66883
Conversation
2105a0e
to
0272e36
Compare
210da56
to
6d397db
Compare
f4f6835
to
5b2bf7a
Compare
Pinging @elastic/kibana-app (Team:KibanaApp) |
@elasticmachine merge upstream |
1 similar comment
@elasticmachine merge upstream |
3312df7
to
ac9e6ef
Compare
ac9e6ef
to
ac428ef
Compare
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 will! Thanx @kertal I wasn't sure about it tbh ;) |
} | ||
return escape(v); | ||
|
||
if (!column) return; |
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.
Have a question to understand this part. The change in this implementation is, if there's no column available for a rows's property, don't add it to the column. This sounds valid, and an improvement. Just try to understand, how could that be the case? Are there row properties with no columns? Just checking to prevent some kind of regression here. Because then there is a nice potential to simplify the code here in a way like this
for (const col of columns) {
const value = row[col.id];
const formattedValue = formatted && col.formatter
? escape(col.formatter.convert(v))
: escape(v);
rowArray.push(formattedValue);
}
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.
Yes there is a case where the user has selected two buckets and has ticked the Show partial rows. On the table you can't see any change but when the CSV is downloaded an extra column is added but as there is no extra header, it is messed up. So the question here is which is the expected behavior? As far as I can't see any change on the table, I expect to see the same on the CSV, right? If not this is another bug that has to do with the partial rows
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.
synced with @stratoula, and she showed me another issue in the current implementation, fixed by this PR, so here the example described in the recent comment,
Exporting this table led to an formatted CSV export with an extra column"extension.keyword: Descending","geo.dest: Descending",Count
,624,122,CN
,624,96,IN
,624,51,US
,624,23,ID
,624,22,PK
gz,285,63,CN
gz,285,52,IN
gz,285,16,US
gz,285,9,NG
gz,285,7,ID
This is also fixed by this PR, and therefore it's safe to refactor the existing code in the suggested way
ba9c1a8
to
b9b0de8
Compare
@elasticmachine merge upstream |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
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.
Code LGTM. 2 + 1 issues solved by a single PR 👏 . Tested locally with Safari, Firefox, Chrome. Works!
…matted csv (elastic#66883) * Fixes the bug with percentage column missing in formatted csv * fix tests * Fix: Wrong formatted CSV when splitting tables * On split table the split row should be added as a column only on the exported csv * eslint * fix test * Improve the loop on the columns and rows Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
…matted csv (#66883) (#67448) * Fixes the bug with percentage column missing in formatted csv * fix tests * Fix: Wrong formatted CSV when splitting tables * On split table the split row should be added as a column only on the exported csv * eslint * fix test * Improve the loop on the columns and rows Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Summary
Fixes #49149. Percentage column is missing in formatted csv.
Fixes #57096. Wrong formatted CSV when splitting tables.
Have tested it on Chrome, Safari and FF. Both raw and formatted CSVs are exported as expected.
Moreover the order of the header columns was different from the rows so the data were not displayed correctly in some cases (under the corresponding header).
Preview of formatted csv with percentages:
Preview of formatted csv when splitting tables: