Skip to content

Conversation

@chessman
Copy link
Contributor

@chessman chessman commented Jul 9, 2024

SUMMARY

When importing a directory using superset import-directory command, it should respect the impersonate_user flag specified in the database yaml definition.

TESTING INSTRUCTIONS

Import a database that supports this flag and verify that this flag is enabled.

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

@dosubot dosubot bot added the data:connect Namespace | Anything related to db connections / integrations label Jul 9, 2024
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! Not signed up? Use our Slack App to self-register.

Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

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

Makes me wonder whether other fields may get lost while doing export/import round trips.

@rusackas
Copy link
Member

rusackas commented Aug 5, 2024

I believe @yousoph and @eschutho are taking stock of bits that are not part of import/export but ought to be.

@rusackas rusackas requested a review from eschutho August 5, 2024 16:30
@codecov
Copy link

codecov bot commented Aug 5, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.70%. Comparing base (76d897e) to head (a5ed1e2).
⚠️ Report is 2203 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #29522       +/-   ##
===========================================
+ Coverage   60.48%   83.70%   +23.21%     
===========================================
  Files        1931      527     -1404     
  Lines       76236    38053    -38183     
  Branches     8568        0     -8568     
===========================================
- Hits        46114    31851    -14263     
+ Misses      28017     6202    -21815     
+ Partials     2105        0     -2105     
Flag Coverage Δ
hive ∅ <100.00%> (∅)
javascript ?
mysql ∅ <100.00%> (?)
postgres ∅ <100.00%> (?)
presto ∅ <100.00%> (∅)
python ∅ <100.00%> (∅)
sqlite ∅ <100.00%> (?)
unit ∅ <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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"impersonate_user"
"impersonate_user",

@eschutho
Copy link
Member

eschutho commented Aug 5, 2024

Can we add a unit test with the new param? Here's an example in tests/unit_tests/databases/commands/importers/v1/import_test.py

def test_import_database_with_user_impersonation(
    mocker: MockerFixture,
    session: Session,
) -> None:
    """
    Test importing a database that is managed externally.
    """
    from superset import security_manager
    from superset.commands.database.importers.v1.utils import import_database
    from superset.models.core import Database
    from tests.integration_tests.fixtures.importexport import database_config

    mocker.patch.object(security_manager, "can_access", return_value=True)

    engine = db.session.get_bind()
    Database.metadata.create_all(engine)  # pylint: disable=no-member

    config = copy.deepcopy(database_config)
    config["impersonate_user"] = True

    database = import_database(config)
    assert database.impersonate_user is True
    ```

@pull-request-size pull-request-size bot added size/S and removed size/XS labels Aug 7, 2024
@rusackas
Copy link
Member

rusackas commented Aug 8, 2024

Approving CI. Ping me if it passes and needs a merge!

@chessman
Copy link
Contributor Author

chessman commented Aug 8, 2024

@rusackas This error looks unrelated to my changes.

>       conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
E       sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "host1" to address: Temporary failure in name resolution
E       
E       (Background on this error at: https://sqlalche.me/e/14/e3q8)

@rusackas
Copy link
Member

Running CI. 🤞 Ping me if it turns green :D

@chessman
Copy link
Contributor Author

@rusackas it's green!

@eschutho eschutho merged commit 050c6da into apache:master Aug 12, 2024
@eschutho
Copy link
Member

Thanks @chessman!

@chessman chessman deleted the add-impersonate-user branch August 13, 2024 09:42
nyohasstium pushed a commit to Webgains/superset that referenced this pull request Jan 2, 2025
Co-authored-by: Eugene Apollonsky <[email protected]>
Co-authored-by: Elizabeth Thompson <[email protected]>
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 5.0.0 First shipped in 5.0.0 labels Jul 29, 2025
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 data:connect Namespace | Anything related to db connections / integrations size/S 🚢 5.0.0 First shipped in 5.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants