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

fix(sqllab): Handle long table names in SQL Lab #10518

Merged
merged 7 commits into from
Aug 11, 2020
Merged

Conversation

suddjian
Copy link
Member

@suddjian suddjian commented Aug 4, 2020

SUMMARY

In cases where there are lots of tables and/or tables with long names, SQL Lab can become difficult to use. This adds a couple of affordances for that use case:

  • Adds tooltips to items in the table select menu, displaying the full table name
  • Widen the autocomplete window. Unfortunately I couldn't find a way to make the width dynamic or add a tooltip. But it's now twice as wide as before which should be pretty accommodating.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen Shot 2020-08-03 at 11 30 40 PM

Screen Shot 2020-08-04 at 12 22 46 PM

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@suddjian suddjian requested review from rusackas and etr2460 August 4, 2020 21:11
@suddjian suddjian changed the title Handle long table names in SQL Lab fix(sqllab): Handle long table names in SQL Lab Aug 4, 2020
@etr2460
Copy link
Member

etr2460 commented Aug 4, 2020

How does the width look when the tables don't have long names? is it too ridiculous?

@mistercrunch
Copy link
Member

Mmmmh, it feels like the tooltip should only be where needed. Really unusual to see a tooltip in a dropdown list... I searched a bit to see if react-select could expand the width of the dropdown as needed but didn't find anything obvious. Seems like the dropdown box could be wider than the non-expanded control.

@rusackas
Copy link
Member

rusackas commented Aug 5, 2020

🏷 sqllab

@rusackas
Copy link
Member

rusackas commented Aug 5, 2020

🗑🏷 sqllab

@mistercrunch
Copy link
Member

🏷️ .ui

*/

.ace_editor.ace_autocomplete {
width: 520px;
Copy link
Member

Choose a reason for hiding this comment

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

Not sure we need a new file here... this could be shoehorned under the .ace_editor selector in main.less

Optionally, all o' that could be moved into Emotion (though that comes with the side mission of migrating the ligature settings into the SupersetTheme.

Also, is 520px based on... something? Maybe it could be a percentage?

Copy link
Member Author

@suddjian suddjian Aug 5, 2020

Choose a reason for hiding this comment

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

Adding it to main.less makes sense to me. That would change autocomplete widths for every instance of ace editor that we have.

I chose 520 based on what looked good to me on-screen. Can't be a percentage because the element is absolute positioned. We could use vw, but I don't really like how that can't be bounded.

@suddjian
Copy link
Member Author

suddjian commented Aug 5, 2020

I don't think it looks too ridiculous
Screen Shot 2020-08-05 at 9 47 04 AM

….tsx

Co-authored-by: Evan Rusackas <evan@preset.io>
@rusackas
Copy link
Member

rusackas commented Aug 5, 2020

In your second screenshot it looks like you might be able to use some CSS to truncate the list item with an ellipsis, e.g.

white-space: nowrap; // probably already happening
overflow: hidden; // _maybe_ already happening
text-overflow: ellipsis; // …

@suddjian
Copy link
Member Author

suddjian commented Aug 5, 2020

Mmmmh, it feels like the tooltip should only be where needed. Really unusual to see a tooltip in a dropdown list... I searched a bit to see if react-select could expand the width of the dropdown as needed but didn't find anything obvious. Seems like the dropdown box could be wider than the non-expanded control.

I agree that having a dynamic dropdown width would be best. I couldn't find a way to make that work either, at least not without going and changing the react-select library. There are actually cases where the dropdown is rendered wide enough to accommodate the longer table names. It only happens when the long name appears in the first few results, because the options are virtualized. It might be possible to figure out up front what the widest option will be and set that as the width, but you'd have to do some pretty weird stuff to get that to work.

Screen Shot 2020-08-03 at 11 34 41 PM

I think the best way to improve this would be to give SQL Lab a thorough design pass. A dropdown might not actually be the best way to solve this user need.

@suddjian
Copy link
Member Author

suddjian commented Aug 5, 2020

In your second screenshot it looks like you might be able to use some CSS to truncate the list item with an ellipsis, e.g.

white-space: nowrap; // probably already happening
overflow: hidden; // _maybe_ already happening
text-overflow: ellipsis; // …

Interestingly, the dropdown is actually horizontally scrollable so this wouldn't work. In theory, the horizontal scrolling should solve the issue of long table names, but it's not a very discoverable pattern. Maybe a better solution would be to make the scrollbar clearly visible and get rid of the tooltips.

@ktmud
Copy link
Member

ktmud commented Aug 5, 2020

I implemented the feature where long table names auto-expand the dropdown select. This is done only for non-virtualized list because it was easier. Didn't follow up to fix it for the virtualized list because once users start typing and narrow the list down to < 100 items, it becomes a non-virtualized list and will auto-expand anyway.

We can potentially slightly increase the windowThreshold (currently defaults to 100) on Select to make table name truncating less frequent for users.

@etr2460
Copy link
Member

etr2460 commented Aug 5, 2020

increasing the windowThreshold seems reasonable, since each dom element within the select isn't too complex. Maybe with some performance testing we can find an optimal value here?

@ktmud
Copy link
Member

ktmud commented Aug 5, 2020

Another easy "fix" is instead of tooltips, we can add the less aggressive html title attribute to the table items.

@suddjian
Copy link
Member Author

suddjian commented Aug 5, 2020

Oh it hadn't even occurred to me to use title, that's a good idea. I'll do a bit of testing with windowThreshold. Out of curiosity, how many tables do you guys have at Airbnb?

@ktmud
Copy link
Member

ktmud commented Aug 5, 2020

It depends on the schema. Normally it'd be less than 100, but we also have schemas with 1000+ tables.

@etr2460
Copy link
Member

etr2460 commented Aug 5, 2020

We've got a >10k table schema, but that's the largest we have so far i think

@suddjian
Copy link
Member Author

suddjian commented Aug 8, 2020

I tried passing a custom windowThreshold to the <Select> but it didn't seem to have any effect. I profiled scrolling around the select menu with and without windowThreshold set to 10000 and with 10000+ tables in the schema. I don't think setting the threshold worked correctly. It was around 200ms to render the menu each time regardless, and it didn't seem like there was actually a larger window of menu items.

@ktmud
Copy link
Member

ktmud commented Aug 8, 2020

I tried passing a custom windowThreshold to the <Select> but it didn't seem to have any effect. I profiled scrolling around the select menu with and without windowThreshold set to 10000 and with 10000+ tables in the schema. I don't think setting the threshold worked correctly. It was around 200ms to render the menu each time regardless, and it didn't seem like there was actually a larger window of menu items.

Did your IDE give you type hint?

because it worked for me. There is also a menuIsOpen option you can set to always open the menu on load, so you can more easily see what is rendered by inspecting elements.

Base on my experience, the scrolling starts to become janky even with just 200+ items, which is why I picked 100 as default in the first place.

@pull-request-size pull-request-size bot added size/S and removed size/M labels Aug 10, 2020
@codecov-commenter
Copy link

codecov-commenter commented Aug 10, 2020

Codecov Report

Merging #10518 into master will decrease coverage by 4.64%.
The diff coverage is 70.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10518      +/-   ##
==========================================
- Coverage   70.74%   66.10%   -4.65%     
==========================================
  Files         604      605       +1     
  Lines       32391    32430      +39     
  Branches     3282     3426     +144     
==========================================
- Hits        22916    21438    -1478     
- Misses       9363    10802    +1439     
- Partials      112      190      +78     
Flag Coverage Δ
#cypress ?
#javascript 59.94% <93.33%> (+0.22%) ⬆️
#python 70.41% <66.97%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset-frontend/src/components/TableSelector.jsx 79.08% <ø> (-5.89%) ⬇️
...rontend/src/explore/components/PropertiesModal.tsx 14.92% <0.00%> (-2.99%) ⬇️
...et-frontend/src/views/CRUD/dataset/DatasetList.tsx 73.18% <ø> (ø)
superset/cli.py 39.73% <0.00%> (+0.13%) ⬆️
superset/connectors/druid/views.py 69.86% <0.00%> (+0.47%) ⬆️
superset/dashboards/schemas.py 98.50% <ø> (ø)
superset/queries/schemas.py 100.00% <ø> (ø)
superset/sql_lab.py 78.69% <0.00%> (+0.77%) ⬆️
superset/views/datasource.py 93.44% <ø> (ø)
superset/utils/core.py 88.99% <25.00%> (-0.40%) ⬇️
... and 193 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5bb8b97...29f1a2d. Read the comment docs.

@suddjian suddjian force-pushed the fix/long-table-names branch from 6b698a0 to 29f1a2d Compare August 10, 2020 05:42
@suddjian
Copy link
Member Author

suddjian commented Aug 10, 2020

@ktmud I believe that's exactly what I tried. Got the intellisense completion and everything. Maybe I did something subtly wrong somewhere.

I changed to title attribute as suggested. I think optimization around the select component could be implemented in another PR.

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.

lgtm, one comment to address in the future

@@ -22,14 +22,14 @@ import 'brace/mode/sql';
import 'brace/theme/github';
import 'brace/ext/language_tools';
import ace from 'brace';
import { areArraysShallowEqual } from '../../reduxUtils';
import sqlKeywords from '../utils/sqlKeywords';
import { areArraysShallowEqual } from 'src/reduxUtils';
Copy link
Member

Choose a reason for hiding this comment

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

is this from a lint rule? auto modifications from your IDE? Could we do a programmatic migration here to absolute paths everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

We probably could do that, but I'm not sure it's worth it. I think I made a decision to change it here because it made more sense than a local path. But sometimes local paths are nice.

@suddjian suddjian merged commit 83af9d1 into master Aug 11, 2020
@suddjian suddjian deleted the fix/long-table-names branch September 1, 2020 22:53
@villebro villebro added the v0.38 label Sep 9, 2020
@dpgaspar dpgaspar removed the v0.38 label Sep 10, 2020
Ofeknielsen pushed a commit to ofekisr/incubator-superset that referenced this pull request Oct 5, 2020
* widen the autocomplete menu for table names

* display the full table name in a tooltip

* license

* Update superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx

Co-authored-by: Evan Rusackas <evan@preset.io>

* src importing

* move autocomplete width css to main.less

* use html title attribute instead of tooltip

Co-authored-by: Evan Rusackas <evan@preset.io>
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* widen the autocomplete menu for table names

* display the full table name in a tooltip

* license

* Update superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx

Co-authored-by: Evan Rusackas <evan@preset.io>

* src importing

* move autocomplete width css to main.less

* use html title attribute instead of tooltip

Co-authored-by: Evan Rusackas <evan@preset.io>
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.38.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/S 🚢 0.38.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants