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(dbview): Add token request button to DuckDB and MotherDuck database modal #27908

Merged
merged 19 commits into from
Apr 15, 2024

Conversation

guenp
Copy link
Contributor

@guenp guenp commented Apr 5, 2024

SUMMARY

  • Add a DuckDBParametersSchema to break out the DuckDB connection URI into database, access token (for MotherDuck) and query
  • Add a button to go to MotherDuck and copy an access token to paste directly into Superset.

The latter is implemented by adding support for the metadata description and load_default values from the parameters schema fields.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
image

After:
ebebe569-b32b-4c8b-9b0e-98bf7c1d9b6b

TESTING INSTRUCTIONS

See animated GIF.

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

Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

This is really nice, I love how easy it makes to connect to MotherDuck!

I left a few comments... can we also add some unit tests for build_sqlalchemy_uri, get_parameters_from_uri, and for the serialization/deserialization of DuckDBURI?

superset/databases/utils.py Outdated Show resolved Hide resolved
superset/db_engine_specs/duckdb.py Outdated Show resolved Hide resolved
Comment on lines +228 to +243
@classmethod
def parameters_json_schema(cls) -> Any:
"""
Return configuration parameters as OpenAPI.
"""
if not cls.parameters_schema:
return None

spec = APISpec(
title="Database Parameters",
version="1.0.0",
openapi_version="3.0.2",
plugins=[MarshmallowPlugin()],
)
spec.components.schema(cls.__name__, schema=cls.parameters_schema)
return spec.to_dict()["components"]["schemas"][cls.__name__]
Copy link
Member

Choose a reason for hiding this comment

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

Note to self, we should not require this, it's the same for every database.

superset/db_engine_specs/duckdb.py Outdated Show resolved Hide resolved
@michael-s-molina
Copy link
Member

@guenp @betodealmeida What's our policy for this screen regarding specific database configs? I thought this was a generic database interface given that it would be really difficult to maintain this modal if we add UI-specific elements for each database type which seems the case here. Are we planning to support specific versions of this modal for each database type?

@betodealmeida
Copy link
Member

@guenp @betodealmeida What's our policy for this screen regarding specific database configs? I thought this was a generic database interface given that it would be really difficult to maintain this modal if we add UI-specific elements for each database type which seems the case here. Are we planning to support specific versions of this modal for each database type?

@michael-s-molina the frontend components are mostly generic, and the configuration lives in the DB engine spec (eg, https://github.com/apache/superset/pull/27908/files#diff-651962bab25f2e142c7d1701b15bed4e3c055374d855f1340b85724b573966b7R116-R129). In this PR they're adding some optional parameters to show the URL to get the token, which is useful in general, IMHO.

That being said, I actually think that the frontend components should be more specific. I think we should have a MotherDuckDatabaseConfig component, a BigQueryDatabaseConfig, and so on. The current approach of building a UI based on generic components that are shared between databases doesn't scale, and as you mentioned, and the databases will start stepping on each other toes very quickly.

@michael-s-molina
Copy link
Member

That being said, I actually think that the frontend components should be more specific. I think we should have a MotherDuckDatabaseConfig component, a BigQueryDatabaseConfig, and so on. The current approach of building a UI based on generic components that are shared between databases doesn't scale, and as you mentioned, and the databases will start stepping on each other toes very quickly.

That was exactly my thinking. It's not a blocker for this PR but something we should consider given the flexibility we'll gain. It's similar to database engine specs where you have common elements but can also extend them to include specific things that will improve overall UX for users.

@guenp guenp force-pushed the guenp/add-token-request-button branch from 24b4c93 to 9eebe83 Compare April 12, 2024 08:52
Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

Awesome!

@betodealmeida betodealmeida merged commit 08aaebb into apache:master Apr 15, 2024
29 checks passed
EnxDev pushed a commit to EnxDev/superset that referenced this pull request Apr 15, 2024
@guenp guenp deleted the guenp/add-token-request-button branch April 15, 2024 17:16
qleroy pushed a commit to qleroy/superset that referenced this pull request Apr 28, 2024
jzhao62 pushed a commit to jzhao62/superset that referenced this pull request May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants