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: add denylist for db engines #21486

Merged
merged 4 commits into from
Oct 9, 2022

Conversation

eschutho
Copy link
Member

@eschutho eschutho commented Sep 15, 2022

SUMMARY

Some db_engine_specs can have multiple db_engine_specs, Databricks for example. Since we build the database connection form available dbs dropdown list based on db_engine_specs that match installed drivers, there are times when one may not want to show all options. This is a simple optional denylist config that removes extra db engines from that list.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

With this code and no extra config added (this is what it looks like without this code):
Additional drivers installed:
databricks-sql-connector 2.0.2
sqlalchemy-databricks 0.2.0

_DEV__Superset

With added local superset_config of:

DBS_AVAILABLE_DENYLIST: Dict[str, Tuple[str, ...]] = {
    "databricks": ("pyhive", "pyodbc")}

_DEV__Superset

TESTING INSTRUCTIONS

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

@codecov
Copy link

codecov bot commented Sep 15, 2022

Codecov Report

Merging #21486 (09afa27) into master (aef6217) will increase coverage by 9.81%.
The diff coverage is 83.33%.

❗ Current head 09afa27 differs from pull request most recent head 2b9c704. Consider uploading reports for the commit 2b9c704 to get more accurate results

@@            Coverage Diff             @@
##           master   #21486      +/-   ##
==========================================
+ Coverage   55.46%   65.28%   +9.81%     
==========================================
  Files        1800     1792       -8     
  Lines       68940    68671     -269     
  Branches     7334     7320      -14     
==========================================
+ Hits        38236    44830    +6594     
+ Misses      28812    21951    -6861     
+ Partials     1892     1890       -2     
Flag Coverage Δ
hive 52.91% <83.33%> (-0.01%) ⬇️
mysql 78.21% <83.33%> (?)
postgres 78.28% <83.33%> (?)
presto ?
python 78.62% <83.33%> (+20.70%) ⬆️
sqlite 76.78% <83.33%> (?)
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/db_engine_specs/__init__.py 84.52% <80.00%> (+0.97%) ⬆️
superset/config.py 91.61% <100.00%> (+0.64%) ⬆️
superset/tables/schemas.py 0.00% <0.00%> (-100.00%) ⬇️
superset/columns/schemas.py 0.00% <0.00%> (-100.00%) ⬇️
...-chart-table/src/DataTable/utils/useMountedMemo.ts 0.00% <0.00%> (-87.50%) ⬇️
...set/advanced_data_type/plugins/internet_address.py 16.32% <0.00%> (-79.60%) ⬇️
superset/utils/pandas_postprocessing/boxplot.py 20.51% <0.00%> (-79.49%) ⬇️
superset/charts/post_processing.py 11.76% <0.00%> (-77.95%) ⬇️
...perset/advanced_data_type/plugins/internet_port.py 18.75% <0.00%> (-77.09%) ⬇️
superset/utils/pandas_postprocessing/rolling.py 21.87% <0.00%> (-68.75%) ⬇️
... and 474 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

superset/config.py Outdated Show resolved Hide resolved
@eschutho eschutho changed the title feat: add blacklist for db engines feat: add denylist for db engines Sep 19, 2022
@eschutho eschutho force-pushed the elizabeth/db_engine_blacklist branch 2 times, most recently from ad1a4e9 to b29799f Compare September 19, 2022 23:50
superset/config.py Outdated Show resolved Hide resolved
if (
engine_spec.engine in dbs_denylist_engines
and hasattr(engine_spec, "default_driver")
and engine_spec.default_driver in dbs_denylist[engine_spec.engine]

Choose a reason for hiding this comment

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

Curious, why just checking if the default_driver is in the list and not any other that engine might have?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's just a way to identify the db_engine_spec so that the default driver option doesn't show up in the database connection list.

if request and hasattr(request, "param"):
for key, val in request.param.items():
app.config[key] = val

Copy link
Member Author

Choose a reason for hiding this comment

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

@betodealmeida I extended this method so that you can pass in extra configs from tests.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I like the idea!

Should we give this a more descriptive name, just in case? Eg, override_app_config instead of param?

Also, how is this used? Is request a Flask request object?

Copy link
Member Author

@eschutho eschutho Oct 9, 2022

Choose a reason for hiding this comment

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

I added typing here. Request is a pytest fixture sub request object. So I can’t change the name of param but agree it would read better.

Copy link
Member

@Antonio-RiveroMartnez Antonio-RiveroMartnez left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

Looks great, I just left a couple comments!

superset/config.py Outdated Show resolved Hide resolved
if request and hasattr(request, "param"):
for key, val in request.param.items():
app.config[key] = val

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I like the idea!

Should we give this a more descriptive name, just in case? Eg, override_app_config instead of param?

Also, how is this used? Is request a Flask request object?

@eschutho eschutho force-pushed the elizabeth/db_engine_blacklist branch from 40d08b6 to 2b9c704 Compare October 7, 2022 23:57
@eschutho eschutho merged commit f58227a into apache:master Oct 9, 2022
@eschutho eschutho deleted the elizabeth/db_engine_blacklist branch October 21, 2022 20:59
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants