-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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: Surface parameters fields for database model #14646
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ | |
from sqlalchemy.sql import expression, Select | ||
|
||
from superset import app, db_engine_specs, is_feature_enabled | ||
from superset.db_engine_specs.base import TimeGrain | ||
from superset.db_engine_specs.base import BasicParametersMixin, TimeGrain | ||
from superset.extensions import cache_manager, encrypted_field_factory, security_manager | ||
from superset.models.helpers import AuditMixinNullable, ImportExportMixin | ||
from superset.models.tags import FavStarUpdater | ||
|
@@ -212,6 +212,7 @@ def data(self) -> Dict[str, Any]: | |
"allows_cost_estimate": self.allows_cost_estimate, | ||
"allows_virtual_table_explore": self.allows_virtual_table_explore, | ||
"explore_database_id": self.explore_database_id, | ||
"parameters": self.parameters, | ||
} | ||
|
||
@property | ||
|
@@ -222,6 +223,17 @@ def unique_name(self) -> str: | |
def url_object(self) -> URL: | ||
return make_url(self.sqlalchemy_uri_decrypted) | ||
|
||
@property | ||
def parameters(self) -> Optional[Dict[str, Any]]: | ||
# Build parameters if db_engine_spec is a subclass of BasicParametersMixin | ||
parameters = {"engine": self.backend} | ||
|
||
if issubclass(self.db_engine_spec, BasicParametersMixin): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After we add BQ we need to change this, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea that PR will have the updated logic here to allow us to pass Big Query credentials |
||
uri = make_url(self.sqlalchemy_uri_decrypted) | ||
return {**parameters, **self.db_engine_spec.get_parameters_from_uri(uri)} | ||
|
||
return parameters | ||
|
||
@property | ||
def backend(self) -> str: | ||
sqlalchemy_url = make_url(self.sqlalchemy_uri_decrypted) | ||
|
@@ -568,10 +580,10 @@ def get_all_schema_names( | |
|
||
@property | ||
def db_engine_spec(self) -> Type[db_engine_specs.BaseEngineSpec]: | ||
return self.get_db_engine_spec_for_backend(self.backend) | ||
engines = db_engine_specs.get_engine_specs() | ||
return engines.get(self.backend, db_engine_specs.BaseEngineSpec) | ||
|
||
@classmethod | ||
@utils.memoized | ||
def get_db_engine_spec_for_backend( | ||
cls, backend: str | ||
) -> Type[db_engine_specs.BaseEngineSpec]: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so for sqlalchemy forms, we're only going to return engine? Maybe that should be the only required type then, it looks like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea good catch i'll make sure to update the type on the types file