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(snowflake): Allow encrypted_extra field to be imported #22357

Merged

Conversation

askldjd
Copy link
Contributor

@askldjd askldjd commented Dec 7, 2022

SUMMARY

The encrypted_extra field holds the keypair to authenticate to Snowflake. However, this field can't be imported currently.

See #22348.

TESTING INSTRUCTIONS

Here are my test steps:

  1. Add a new Snowflake connection called "Snowflake UI" using the UI. Choose SQLAchemy as the option and use provide the keypair in the SECURE EXTRA following the instruction.
  2. Construct a new snowflake-import.yaml in this format:
databases:
  - database_name: Snowflake from Import
    sqlalchemy_uri: $url
    cache_timeout: null
    expose_in_sqllab: true
    allow_run_async: false
    allow_ctas: false
    allow_cvas: false
    allow_csv_upload: false
    version: 1.0.0
    encrypted_extra: $encrypted_extra

where $url is the sqlachemy URL and encrypted_extra is the JSON encoded JSON block. So it looks something like this:

"{\n  \"auth_method\": \"keypair\",\n  \"auth_params\": {\n      \"privatekey_body\": \"-----BEGIN ENCRYPTED PRIVATE KEY-----\\nblablabla\\n-----END ENCRYPTED PRIVATE KEY-----\",\n      \"privatekey_pass\": \"mypassword\"\n  }\n}"
  1. Run superset import_datasources -p snowflake-import.yaml
  2. Inspect that dbs table and verify that both the UI entry and the imported entry are identical.
  • Of course, test the connection from the UI too. :)

Prior to the fix, step 4 would fail. The encrypted_extra column would be empty for the imported entry.

ADDITIONAL INFORMATION

Fixes #22348

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️
We hope to see you in our Slack community too!

@betodealmeida betodealmeida self-requested a review December 8, 2022 01:21
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.

This is great, @askldjd!

@codecov
Copy link

codecov bot commented Dec 8, 2022

Codecov Report

Merging #22357 (b6b3145) into master (ff1d29c) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #22357      +/-   ##
==========================================
- Coverage   66.85%   66.85%   -0.01%     
==========================================
  Files        1847     1847              
  Lines       70560    70560              
  Branches     7737     7737              
==========================================
- Hits        47173    47171       -2     
- Misses      21380    21382       +2     
  Partials     2007     2007              
Flag Coverage Δ
hive 52.53% <100.00%> (ø)
mysql 77.95% <100.00%> (ø)
postgres 78.02% <100.00%> (ø)
presto 52.42% <100.00%> (ø)
python 81.23% <100.00%> (-0.01%) ⬇️
sqlite 76.48% <100.00%> (ø)
unit 50.91% <100.00%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
superset/models/core.py 90.50% <100.00%> (ø)
superset/db_engine_specs/bigquery.py 81.68% <0.00%> (-1.00%) ⬇️

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

@srinify srinify merged commit d41cb66 into apache:master Dec 8, 2022
@askldjd askldjd deleted the aning/fixed-snowflake-encrypted-extra-import branch December 8, 2022 19:28
@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/XS 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to import Snowflake Database with the Encrypted Extra field
5 participants