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(db_engine): Add custom_user_agent when connecting to MotherDuck #27665

Merged
merged 15 commits into from
Mar 29, 2024

Conversation

guenp
Copy link
Contributor

@guenp guenp commented Mar 26, 2024

SUMMARY

This PR adds a custom_user_agent key to the config that is passed to the SQLAlchemy engine for DuckDB. This is needed for MotherDuck so we can track usage of Superset.
The PR also updates the sqlalchemy_uri_placeholder for DuckDB and MotherDuck.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

User agent before:

duckdb/v0.9.2(osx_arm64) python duckdb_engine/0.11.2(sqlalchemy/1.4.36)

User agent after:

duckdb/v0.9.2(osx_arm64) python duckdb_engine/0.11.2(sqlalchemy/1.4.36) apache-superset/0.0.0-dev

sqlalchemy_uri_placeholder before:
Screenshot 2024-03-26 at 10 29 20 AM
Screenshot 2024-03-26 at 10 29 33 AM

sqlalchemy_uri_placeholder after:
Screenshot 2024-03-26 at 10 28 46 AM
Screenshot 2024-03-26 at 10 28 59 AM

TESTING INSTRUCTIONS

Run unit tests.

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

codecov bot commented Mar 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.89%. Comparing base (d69a187) to head (ec44431).
Report is 1305 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #27665      +/-   ##
==========================================
+ Coverage   67.47%   69.89%   +2.41%     
==========================================
  Files        1911     1911              
  Lines       75019    75033      +14     
  Branches     8352     8352              
==========================================
+ Hits        50620    52445    +1825     
+ Misses      22349    20538    -1811     
  Partials     2050     2050              
Flag Coverage Δ
hive 48.92% <37.50%> (?)
mysql 77.86% <37.50%> (-0.05%) ⬇️
postgres 78.00% <37.50%> (-0.02%) ⬇️
presto 53.63% <37.50%> (?)
python 83.16% <100.00%> (+4.99%) ⬆️
sqlite 77.44% <37.50%> (-0.02%) ⬇️
unit 56.77% <100.00%> (?)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@betodealmeida betodealmeida self-requested a review March 27, 2024 02:11
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.

Nice!

superset/db_engine_specs/duckdb.py Show resolved Hide resolved
@guenp
Copy link
Contributor Author

guenp commented Mar 27, 2024

I can repro the failing CI step locally, but it succeeds if I set flask back to 2.2.5 (this was changed in #27657).
These are the errors (also happening on master):

Run pylint -j 0 superset
************* Module superset.models.helpers
superset/models/helpers.py:39:0: E06[11](https://github.com/apache/superset/actions/runs/8452926923/job/23154446091?pr=27665#step:5:12): No name 'escape' in module 'flask' (no-name-in-module)
superset/models/helpers.py:39:0: E0611: No name 'Markup' in module 'flask' (no-name-in-module)
************* Module superset.models.sql_lab
superset/models/sql_lab.py:28:0: E0611: No name 'Markup' in module 'flask' (no-name-in-module)
************* Module superset.tags.models
superset/tags/models.py:22:0: E0611: No name 'escape' in module 'flask' (no-name-in-module)
************* Module superset.views.database.mixins
superset/views/database/mixins.py:19:0: E0611: No name 'Markup' in module 'flask' (no-name-in-module)
************* Module superset.views.chart.mixin
superset/views/chart/mixin.py:[17](https://github.com/apache/superset/actions/runs/8452926923/job/23154446091?pr=27665#step:5:18):0: E0611: No name 'Markup' in module 'flask' (no-name-in-module)
************* Module superset.connectors.sqla.views
superset/connectors/sqla/views.py:21:0: E0611: No name 'Markup' in module 'flask' (no-name-in-module)
************* Module superset.connectors.sqla.models
superset/connectors/sqla/models.py:36:0: E0611: No name 'escape' in module 'flask' (no-name-in-module)
superset/connectors/sqla/models.py:36:0: E0611: No name 'Markup' in module 'flask' (no-name-in-module)
************* Module superset.utils.core
superset/utils/core.py:63:0: E0611: No name 'Markup' in module 'flask' (no-name-in-module)

It looks like other PRs are failing with the same issue

Edit: this is now resolved but Python integration is failing.
Edit: this is now ready to merge! :)

@guenp
Copy link
Contributor Author

guenp commented Mar 29, 2024

@betodealmeida Thanks for the review! this PR is now ready to merge ✅

@villebro villebro merged commit fcf90df into apache:master Mar 29, 2024
37 checks passed
@guenp guenp deleted the guenp/add-custom-user-agent-for-duckdb branch March 29, 2024 14:12
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
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 4.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants