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

feat: Results table on Explore view #11854

Merged
merged 33 commits into from
Dec 5, 2020

Conversation

kgabryje
Copy link
Member

@kgabryje kgabryje commented Nov 30, 2020

SUMMARY

This PR implements feature described in apache-superset/superset-roadmap#61.
The goal was to move View results and View samples tables from DisplayQueryButton to main Explore view. Tables are placed in tabs, in a collapsible section.
The whole chart/table area is resizable, with tables section initially collapsed and with minimal height to show as much of the chart as possible. After "uncollapsing" it automatically resizes to 40% if container height, leaving 60% for the chart. The heights can be further adjusted with split handle. After collapsing, it shrinks back to its original height.
The implemented UI is a bit different compared to the one linked in the issue - changes were discussed with @junlincc and @rusackas.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

ezgif com-gif-maker (1)

TEST PLAN

  1. Manually test the feature on various charts.
  2. TODO: Write comprehensive E2E tests for the feature

ADDITIONAL INFORMATION

CC: @junlincc @rusackas @villebro
@adam-stasiak @agatapst Could you please help with manual testing?

@kgabryje kgabryje marked this pull request as draft November 30, 2020 17:30
@junlincc
Copy link
Member

junlincc commented Dec 1, 2020

ezgif-2-be0521eb2ebe

addressing below issues:

  • Run query button absolute position
  • collapsible DATA section that includes View Results and View Samples
  • minimum height for chart area 300px
  • include Search, Copy, and # of retrieved row in the data section
  • minor cosmetic issues

@villebro @rusackas @Mihir14

@pull-request-size pull-request-size bot added size/XL and removed size/L labels Dec 2, 2020
@kgabryje kgabryje marked this pull request as ready for review December 2, 2020 18:30
Copy link
Member

@junlincc junlincc left a comment

Choose a reason for hiding this comment

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

great work, Kamil!
comments -
1. the caret and DATA mis alignment
alignment
2. View Samples is not showing on Table Viz
Screen Shot 2020-12-02 at 12 51 12 PM
3. Data sorting order in the chart and table should be the same
Screen Shot 2020-12-02 at 12 53 36 PM
4. let's make Data bold
5. set horizontal scroll bar to view all columns in VIEW RESULTS and VIEW SAMPLES
Screen Shot 2020-12-02 at 12 56 09 PM

tested
Search bar ✅
#row retrieved ✅
tabs ✅
alignment ❌
Data showing on all charts ✅ except table viz, but it's an existing issue
showing the entire table/all columns ✅ except enormous amount of columns, existing issue
cosmetic ❌
resizing - legacy charts ✅
resizing - echarts ✅

@rusackas
Copy link
Member

rusackas commented Dec 2, 2020

Adding on to @junlincc 's numbering system:

  1. Agreed, let's fix that
  2. Let's fix that IF it works in the current implementation. If not, let's file an issue and tackle that separately, so we can merge this one.
  3. This is an enhancement, not addressed in the current solution. Let's file an issue and tackle that in a separate PR.
  4. Easy fix, let's fix.
  5. Just to clarify the scrolling business. I do not think we should un-truncate that cell. JSON can be huuuuuuuuge, so we should set a reasonable max-width on any given cell, and truncate with ellipsis. BUT, if a result set has many columns, we should scroll horizontally to make sure you can see every column (each with that max-width applied).

This is looking AWESOME, btw, super excited about this.

@junlincc
Copy link
Member

junlincc commented Dec 2, 2020

2. Let's fix that IF it works in the current implementation. If not, let's file an issue and tackle that separately, so we can merge this one.

it did not work before, i agree this should not be a blocker

@junlincc
Copy link
Member

junlincc commented Dec 2, 2020

5. BUT, if a result set has many columns, we should scroll horizontally to make sure you can see every column (each with that max-width applied).

currently, when there are tooooo many columns, clicking View Samples just crash the explore view. also happening in this PR.

so 2,3,5 really are not new problems. we can merge this PR without them being addressed, but we should create separate PRs to fix those soon. no necessary by @kgabryje though. :)

@junlincc
Copy link
Member

junlincc commented Dec 3, 2020

to confirm, this PR does offer horizontal scroll to show all columns(when it's not tooooo many like over 300 columns)
ezgif-4-bf3862e6e806
page does crashes when i tried to view a large sample
ezgif-4-fdc23e11bf62
these are all old behaviors, not introduced by this PR.
so scratch what i said in point 5. apologies for the confusion! @kgabryje

@etr2460
Copy link
Member

etr2460 commented Dec 3, 2020

page does crashes when i tried to view a large sample

@junlincc is that actually current behavior in master? Is there an issue tracking it? it looks pretty serious to me

@@ -0,0 +1,91 @@
/**
Copy link
Member

Choose a reason for hiding this comment

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

this is a new file, can you please use TypeScript?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@junlincc
Copy link
Member

junlincc commented Dec 3, 2020

page does crashes when i tried to view a large sample

@junlincc is that actually current behavior in master? Is there an issue tracking it? it looks pretty serious to me

100%positive this is currently happening~ i agree this is serious, after this change, View Samples will be more accessible to the users,, which means crashes will more likely to happen as users poke around this new feature. #11908

thanks for reviewing btw! @etr2460

@@ -49,22 +52,124 @@ const propTypes = {
triggerRender: PropTypes.bool,
};

export const EXPLORE_GUTTER_HEIGHT = 5;
Copy link
Member

Choose a reason for hiding this comment

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

I'd be tempted to see if we can live without these constants, and use gridUnit instead (which may require useTheme in some cases).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure about that. We use EXPLORE_GUTTER_MARGIN both in component logic and in a styled component. In case we wanted to change its value, we'd have to remember to modify 2 places instead of 1. Unless I passed that margin value as a prop to styled component? We'd benefit from using a theme variable, but I think we'd lose some readability. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe there's a compromise, setting the EXPLORE_GUTTER_HEIGHT and EXPLORE_GUTTER_MARGIN constants to the number of gridUnits, and then using that as the multiplier - in this case they'd both be set to 1, I suppose. Which then raises the question of whether we need two consts or just use one unified gutter size const.

If this is all too much trouble or ruins the readability, maybe we can just change them both to 4 so they at least match the current world layout grid?

Copy link
Member Author

@kgabryje kgabryje Dec 4, 2020

Choose a reason for hiding this comment

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

I like this idea... but in this case 1px really does make a difference.
Here's a gutter height 4px:
image
And here's 5px:
image

Maybe the screenshots don't really show it, but in my opinion 5px looks much much better. Which raises a question, do we want do play around with 1.25 multiplier for gridUnit?

Copy link
Member Author

Choose a reason for hiding this comment

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

I pushed a change with GUTTER_SIZE_FACTOR = 1.25. Let me know what you think 🙂

@kgabryje
Copy link
Member Author

kgabryje commented Dec 3, 2020

@junlincc Arrow centered and text bolded
image

@adam-stasiak
Copy link
Contributor

adam-stasiak commented Dec 3, 2020

@junlincc I have a question related to searching in results:
image
Should X rows retrieved be showing proper value when we apply the search filter? Or just show as it is total number of rows.

During my tests it stil crashes when I set big amount of data but as it was said - it is not introduced by this PR.

@kgabryje Visual issue - while expanding data space there is a glitch. Maybe while expanding we can move also the bottom side?
Hnet-image

@kgabryje kgabryje reopened this Dec 3, 2020
@mistercrunch
Copy link
Member

mistercrunch commented Dec 4, 2020

I haven't looked at the code but wanted to make sure that we don't fetch samples unless/until the tab is selected.

I think that the "View Samples" use case is fairly uncommon. Also note that it only needs to be reprocess when the filters are altered, changing metrics and other query parameters don't require re-fetching/re-rendering.

@kgabryje
Copy link
Member Author

kgabryje commented Dec 4, 2020

I haven't looked at the code but wanted to make sure that we don't fetch samples unless/until the tab is selected.

I think that the "View Samples" use case is fairly uncommon. Also note that it only needs to be reprocess when the filters are altered, changing metrics and other query parameters don't require re-fetching/re-rendering.

Currently both results and samples are fetched when user expands Data panel. They are refetched when query params change. I'll try to optimize that so that Samples are fetched only when needed

@kgabryje
Copy link
Member Author

kgabryje commented Dec 4, 2020

@mistercrunch I noticed that on current master, we send a request for samples not only when chart data changes, but every time we open a modal. Should we consider refetching samples only when filters change as a separate feature?

@junlincc
Copy link
Member

junlincc commented Dec 4, 2020

@junlincc @adam-stasiak I added a white background that makes the table area not transparent during resizing. Could you check it out?

white background is much better, thanks for adding it!

@junlincc
Copy link
Member

junlincc commented Dec 4, 2020

ezgif-7-5483dd6a7fb4

tested in Mozilla today.

  • previous cosmetic issues are addressed ✅
  • white background added to the table ✅
  • empty state ✅

remaining issues:

  1. typing text in search seems there's delay, see gif - should address separately, confirmed that it's happening currently in master, not related to this PR
  2. glitch when resizing - users will not likely resize too fast, not critical, should merge and address later
  3. big data sample crash - already assigned separate issue, and prioritized, it should be fixed soon.

@etr2460 @rusackas any objections?

@mistercrunch I noticed that on current master, we send a request for samples not only when chart data changes, but every time we open a modal. Should we consider refetching samples only when filters change as a separate feature?

if this behavior is not new, we should address it separately.

@mistercrunch
Copy link
Member

@kgabryje it's probably ok to only fetch samples when "View Samples" is first selected OR user hit run Run.

But logically I think it's only necessary to fetch the samples if the filtering has changed.

@kgabryje
Copy link
Member Author

kgabryje commented Dec 4, 2020

@mistercrunch Shall we create a separate task for that?
@junlincc I fixed the delay in filter input. Now it waits for 500ms after user stops typing to rerender the table.
ezgif com-gif-maker (2)

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

I think this looks mostly good now! I'm going to approve, but please address the remaining comments before merging

}
`;

export const CopyToClipboardButton = ({ data }: { data: object }) => (
Copy link
Member

Choose a reason for hiding this comment

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

I think we prefer Record<string, any> to object for typescript


export const CopyToClipboardButton = ({ data }: { data: object }) => (
<CopyToClipboard
text={data ? prepareCopyToClipboardTabularData(data) : ''}
Copy link
Member

Choose a reason for hiding this comment

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

if data is always an object, then this check shouldn't be needed

Copy link
Member Author

Choose a reason for hiding this comment

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

It actually can be undefined, I changed data: object to data?: Record<string, any>

);
};

export const RowCount = ({ data }: { data: object[] }) => (
Copy link
Member

Choose a reason for hiding this comment

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

same comment here about the typing of object

<RowCountLabel rowcount={data?.length ?? 0} suffix={t('rows retrieved')} />
);

export const useFilteredTableData = (filterText: string, data?: object[]) =>
Copy link
Member

Choose a reason for hiding this comment

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

same comment here about the typing of object

);
}, [data, filterText]);

export const useTableColumns = (data?: object[]) =>
Copy link
Member

Choose a reason for hiding this comment

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

same comment here about the typing of object (i'm going to stop making these, but please clean up the rest, thanks!)

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it! Thanks for pointing that out. Fixed here and in other types

return [];
}
const formattedData = applyFormattingToTabularData(data);
return formattedData.filter((row: object) =>
Copy link
Member

Choose a reason for hiding this comment

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

same comment here about the typing of object

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for all the feedback everyone, and thanks for all the due diligence Kamil!

@rusackas rusackas merged commit 41738df into apache:master Dec 5, 2020
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 17, 2021
merge to test feat: Results table on Explore view apache#11854
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 24, 2021
merge to test feat: Results table on Explore view apache#11854
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 25, 2021
merge to test feat: Results table on Explore view apache#11854
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 26, 2021
merge to test feat: Results table on Explore view apache#11854
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.0.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XL 🚢 1.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants