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(SIP-95): catalogs in SQL Lab and datasets #28376

Merged
merged 3 commits into from
May 8, 2024
Merged

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented May 7, 2024

SUMMARY

This PR finishes the initial work for #22862, introducing a new hierarchical data level: catalogs.

A few important concepts:

  • Not all databases support catalogs. Notable databases that do support catalogs are Presto, Trino, Snowflake, Databricks, BigQuery ("projects"), and Postgres ("databases").
  • SQLAlchemy has no concept of catalogs, only schemas. Because of this, DB engine specs need to implement methods that (1) return the default catalog, (2) return the list of catalog names available, and (3) modify the SQLAlchemy URI before a connection so it can point to a non-default catalog when necessary. So far only this has only been implemented in Postgres, and I'm planning to add support for Databricks next.
  • Support for changing the catalog needs to be enabled for each database, and defaults to false.

See the option at the bottom of "Advanced" -> "Other" -> "Allow changing catalogs":

Screenshot 2024-05-07 at 16-57-44 Superset

Once the feature is enabled, a dropdown will show up the in DatabaseSelector component, allowing users to select a catalog. This includes SQL Lab, the page for adding datasets, and the dataset editor.

Screenshot 2024-05-07 at 16-59-09 Superset

The dropdown is hidden when a database without the feature is selected:

Screen.Recording.2024-05-07.at.5.01.08.PM.mov

Nothing should change for databases that don't support catalogs, or that have it disabled. Relevant APIs have been updated to accept an optional catalog. Databases without support will simply ignore it, and databases that support it will use it to establish the connection, or fallback to the default catalog if a null is passed.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

See above.

TESTING INSTRUCTIONS

WIP, I'm currently updating existing tests and adding new tests.

ADDITIONAL INFORMATION

  • Has associated issue: [SIP-95] Proposal for Catalog Support in SQL Lab #22862
  • 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

Sorry, something went wrong.

@github-actions github-actions bot added api Related to the REST API preset-io labels May 7, 2024
@betodealmeida betodealmeida marked this pull request as ready for review May 8, 2024 16:55
@@ -410,6 +412,8 @@ export default function sqlLabReducer(state = {}, action) {
return state;
},
[actions.LOAD_QUERY_EDITOR]() {
console.log(state);
console.log(state.unsavedQueryEditor);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
console.log(state.unsavedQueryEditor);

}

if (isFetched) {
addSuccessToast('List refreshed');
Copy link
Member

Choose a reason for hiding this comment

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

translate?

name="select-catalog"
notFoundContent={t('No compatible catalog found')}
placeholder={t('Select catalog or type to search catalogs')}
onChange={item => changeCatalog(item as CatalogOption)}
Copy link
Member

@eschutho eschutho May 8, 2024

Choose a reason for hiding this comment

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

did passing just changeCatalog to the prop fail because of a ts error? (as opposed to the arrow function)

function renderSchemaSelect() {
const refreshIcon = !readOnly && (
<RefreshLabel
onClick={() => refetch()}
onClick={() => refetchSchemas()}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
onClick={() => refetchSchemas()}
onClick={refetchSchemas}

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

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

lgtm.. just some small nits.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 8, 2024
@betodealmeida betodealmeida merged commit ce668d4 into master May 8, 2024
29 checks passed
imancrsrk pushed a commit to imancrsrk/superset that referenced this pull request May 10, 2024
jzhao62 pushed a commit to jzhao62/superset that referenced this pull request May 16, 2024
EnxDev pushed a commit to EnxDev/superset that referenced this pull request May 31, 2024
@rusackas rusackas deleted the catalog-sqllab branch September 27, 2024 21:04
vinothkumar66 pushed a commit to vinothkumar66/superset that referenced this pull request Nov 11, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 4.1.0 labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to the REST API 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels lgtm This PR has been approved by a maintainer packages preset-io size/XL 🚢 4.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants