-
Notifications
You must be signed in to change notification settings - Fork 13.4k
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: Expose different hooks dynamically to inject different database #29281
base: master
Are you sure you want to change the base?
Conversation
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.
Hello, I found that all the checks related to docker pull failed. Is there anything I need to do? |
Are you able to start by fixing the failed tests in the details of the pre-commit check? |
Yeah,I fix the pre-commit hook errros and pushed the submission again! thanks you for help! :) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #29281 +/- ##
===========================================
+ Coverage 60.48% 83.70% +23.21%
===========================================
Files 1931 527 -1404
Lines 76236 37937 -38299
Branches 8568 0 -8568
===========================================
- Hits 46114 31754 -14360
+ Misses 28017 6183 -21834
+ Partials 2105 0 -2105
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
add license info Co-authored-by: Evan Rusackas <[email protected]>
@betodealmeida this seems kind of in your wheelhouse -- are you able to review, or can you think of another committer who would be well-suited? |
This environment configuration setting hook allows administrators to alter different database connection parameters on the fly based on user information and hook strategy. This can be use for a variety of purposes:
SUMMARY
Although there is already a DB_CONNECTION_MUTATOR hook available to inject database connection logic on the fly, if we do not modify the code in superset/models/core.py within the Database.get_sqla_engine method, this injection will affect all data source connections. Specifically, if different data sources require different injection logic, then we need to make different modifications to the code within superset/models/core.py to handle the different database types. Therefore, I have added a DB_CONNECTION_MODIFIER hook (clearly, DB_CONNECTION_MUTATOR would be a better name, but it is already in use, so I used a synonym instead), which allows for different data sources to implement different injection logic on the fly, as long as these database injection logic classes implement the run method of the ImpalaURLModifier class. This increases the flexibility of injecting database connection logic on the fly.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
For example, when each user connects to the postgres data source, their use the current username to connect to the database, and the password is new_password_ str plus the username.
Add a new class PostgresDBConnectModifier in file superset/utils/database_connect_modifier.py
superset/config.py中
The user logs in to the superset page and queries the postgres database table in sqllab; or the underlying data table triggered by the chart page is the postgres data source.
ADDITIONAL INFORMATION