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

fix: remove unneeded complexity in migration #19022

Merged

Conversation

betodealmeida
Copy link
Member

SUMMARY

The migration from SIP-68 was calling create_engine just to get the dialect associated with a given database. This required reimplementing many methods in the custom Database class defined in the migration, since it requires doing user impersonation, mutating the connection string, and much more. This was failing for BigQuery because it was not finding the credentials:

google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started

Turns out there's a simpler way of getting the dialect associated with a database that doesn't require create_engine. I implemented it in this PR.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

Migration should run fine. I ran a downgrade and upgrade and it works fine, but I only testes with Postgres.

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

@betodealmeida betodealmeida requested a review from a team as a code owner March 3, 2022 23:43
@codecov
Copy link

codecov bot commented Mar 4, 2022

Codecov Report

Merging #19022 (9bb1470) into master (77063cc) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #19022   +/-   ##
=======================================
  Coverage   66.56%   66.56%           
=======================================
  Files        1641     1641           
  Lines       63495    63495           
  Branches     6425     6425           
=======================================
  Hits        42265    42265           
  Misses      19550    19550           
  Partials     1680     1680           
Flag Coverage Δ
hive 52.59% <ø> (ø)
mysql 81.81% <ø> (ø)
postgres 81.86% <ø> (ø)
presto 52.44% <ø> (ø)
python 82.29% <ø> (ø)
sqlite 81.55% <ø> (ø)

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


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77063cc...9bb1470. Read the comment docs.

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

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

wow.. that's a lot less code. :)

@betodealmeida
Copy link
Member Author

wow.. that's a lot less code. :)

Yeah! The original implementation was copied from the current Database model, but of course there we use get_sqla_engine for other things than just accessing the dialect. I should've realized it could've been done in a simpler way.

@betodealmeida betodealmeida merged commit 50bb86d into apache:master Mar 4, 2022
@sadpandajoe
Copy link
Member

🏷️ preset:2022.9

sadpandajoe pushed a commit to preset-io/superset that referenced this pull request Mar 4, 2022
villebro pushed a commit that referenced this pull request Apr 3, 2022
@mistercrunch mistercrunch added 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 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 lts-v1 preset:2022.9 size/M 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants