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(sqllab): Adds refresh button to table metadata in SQL Lab #29974

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

Usiel
Copy link
Contributor

@Usiel Usiel commented Aug 20, 2024

SUMMARY

When table metadata changes (e.g. due to queries launched in Superset or other external changes) the user has no convenient way to force a refresh of the data for their TabState. The metadata is persisted even across sessions and will never update if the user stays on the current tab.

This feature is a first step to make this experience better by adding a refresh button for each table that allows a manual refresh.

Future improvements:

  • Automatically refresh when query is likely to change the metadata
  • Refresh metadata from time to time
  • Do not persist the metadata for a SQL Lab tab forever: Maybe remove TableSchema and instead use a shared cache with well defined expiry

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Refresh Button in Action

TESTING INSTRUCTIONS

  1. Load SQL Lab and expand a table
  2. Change the table (e.g. add column)
  3. Click refresh button
  4. Expected: New column appears
  5. Refresh the whole page
  6. Expected: Column is still there (asserts the server-side TableSchema was properly updated)

ADDITIONAL INFORMATION

  • Has associated issue
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@dosubot dosubot bot added change:frontend Requires changing the frontend sqllab Namespace | Anything related to the SQL Lab labels Aug 20, 2024
When table metadata changes (e.g. due to queries launched in Superset or other external changes) the user has no convenient way to force a
refresh of the data. The metadata is persisted even across sessions and will never update if the user stays on the current tab.

This feature is a first step to make this experience better by adding a refresh button for each table that allows a manual refresh.

Future improvements:
- Automatically refresh when query is likely to change the metadata
- Refresh metadata from time to time
@Usiel Usiel force-pushed the usiel/add-tablem-metadta-refresh branch from 4aecbb6 to 9c1b366 Compare August 20, 2024 08:37
@Usiel
Copy link
Contributor Author

Usiel commented Aug 20, 2024

Rebased on master (thought I branched off the latest but apparently that was not the case)

providesTags: result =>
result
? [
{ type: 'TableMetadatas', id: result.name },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having a guaranteed unique id would be better. From what I can tell we would need to return it from the API though, so I just went with the name for now.

Copy link
Member

Choose a reason for hiding this comment

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

what is result.name in this context? Is it a fully-qualified table name? Regardless I think at this time changing anything in the table selector flushes the metadata section, so even just a table name should be safe for now. If we were to support tables from multiple schemas to remain accessible in this metadata section, this could in theory create some collision.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just the table name, no extra qualifier like schema. And I see it the same way regarding collisions, so I'm good leaving it as is it.

@michael-s-molina michael-s-molina added the review:checkpoint Last PR reviewed during the daily review standup label Aug 20, 2024
@@ -107,7 +108,7 @@ const TableElement = ({ table, ...props }: TableElementProps) => {
const {
currentData: tableMetadata,
isSuccess: isMetadataSuccess,
isLoading: isMetadataLoading,
isFetching: isMetadataLoading,
Copy link
Member

@mistercrunch mistercrunch Aug 21, 2024

Choose a reason for hiding this comment

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

haven't dug deep, but I'd assume switching the name here we'd also change some other reference to it somewhere else in the method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are destructuring isFetching (which is already part of the return of useTableMetadataQuery) into isMetadataLoading.
(isLoading is only true on the first load while isFetching is also true on subsequent fetches.)

I renamed the local variable isMetadataLoading to isMetadataFetching to be in sync with the naming convention.

@michael-s-molina michael-s-molina removed the review:checkpoint Last PR reviewed during the daily review standup label Aug 21, 2024
@mistercrunch mistercrunch merged commit 9d5268a into apache:master Aug 23, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:frontend Requires changing the frontend size/M sqllab Namespace | Anything related to the SQL Lab
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants