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

chore!: update mutator to take kwargs #19083

Merged
merged 5 commits into from Mar 18, 2022

Conversation

eschutho
Copy link
Member

@eschutho eschutho commented Mar 9, 2022

This is a breaking change. To make the mutator more flexible for future changes, I am passing all but the required sql argument that is in the default config to kwargs. If we want to add more values to the mutator in the future we can without breaking any mutator config overwrite functions.

TESTING INSTRUCTIONS

There is an existing test for the mutator.

ADDITIONAL INFORMATION

  • Has associated issue: closes Change function params for the mutator config #19106
  • 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

@superset-github-bot superset-github-bot bot added the Superset-Community-Partners Preset community partner program participants label Mar 9, 2022
@eschutho eschutho removed the Superset-Community-Partners Preset community partner program participants label Mar 9, 2022
@eschutho eschutho added v2.0 risk:breaking-change Issues or PRs that will introduce breaking changes labels Mar 9, 2022
@codecov
Copy link

codecov bot commented Mar 9, 2022

Codecov Report

Merging #19083 (94065f3) into master (97abc28) will decrease coverage by 0.02%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master   #19083      +/-   ##
==========================================
- Coverage   66.52%   66.50%   -0.03%     
==========================================
  Files        1667     1667              
  Lines       64341    64340       -1     
  Branches     6495     6495              
==========================================
- Hits        42805    42787      -18     
- Misses      19853    19870      +17     
  Partials     1683     1683              
Flag Coverage Δ
hive 52.60% <50.00%> (-0.01%) ⬇️
mysql ?
postgres 81.51% <50.00%> (-0.02%) ⬇️
presto 52.45% <50.00%> (-0.01%) ⬇️
python 81.89% <50.00%> (-0.06%) ⬇️
sqlite 81.29% <50.00%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
superset/config.py 91.79% <ø> (-0.03%) ⬇️
superset/db_engine_specs/base.py 88.31% <0.00%> (ø)
superset/sql_validators/presto_db.py 82.89% <0.00%> (ø)
superset/connectors/sqla/models.py 89.88% <100.00%> (ø)
superset/sql_lab.py 81.64% <100.00%> (ø)
superset/common/utils/dataframe_utils.py 85.71% <0.00%> (-7.15%) ⬇️
superset/db_engine_specs/mysql.py 93.97% <0.00%> (-3.62%) ⬇️
superset/reports/commands/log_prune.py 85.71% <0.00%> (-3.58%) ⬇️
superset/commands/importers/v1/utils.py 92.20% <0.00%> (-1.30%) ⬇️
superset/models/core.py 88.33% <0.00%> (-0.72%) ⬇️
... and 3 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 97abc28...94065f3. Read the comment docs.

@eschutho
Copy link
Member Author

eschutho commented Mar 9, 2022

The hope here is that people will use the **kwargs param in their mutator methods instead of hardcoding the params. If they do that, then any future changes will be backward compatible. If they continue to look up the kwargs and add them explicitly to their method, then their implementation will break with future changes to the args that are passed in.

@eschutho eschutho force-pushed the elizabeth/update-mutator branch 3 times, most recently from 82335fe to 389e9e1 Compare March 9, 2022 20:45
@@ -504,7 +504,7 @@ def test_sql_mutator(self):
sql = tbl.get_query_str(query_obj)
self.assertNotIn("-- COMMENT", sql)

def mutator(*args):
def mutator(*args, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

Can we write a better test for making sure the mutator properly takes the params?

Copy link
Member Author

Choose a reason for hiding this comment

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

@hughhhh I added one more test to check that the database name is being passed in. LMK if you think more tests around that would be helpful. user_name was null and the security_manager is a function so printing them wouldn't really validate much.

sql = sql_query_mutator(sql, user_name, security_manager, database)
sql = sql_query_mutator(
sql,
user_name=user_name,
Copy link
Member

Choose a reason for hiding this comment

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

Qi, Is this assigning the existing user_name here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the current user_name, or rather identifier. Sometimes it doesn't map directly to the person's name depending on how they've authenticated.

@eschutho eschutho changed the title chore: update mutator to take kwargs chore!: update mutator to take kwargs Mar 10, 2022
Copy link
Member

@suddjian suddjian 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

@pkdotson pkdotson left a comment

Choose a reason for hiding this comment

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

lgtm!

@eschutho eschutho merged commit d645579 into apache:master Mar 18, 2022
@mistercrunch mistercrunch added 🏷️ 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 preset-io risk:breaking-change Issues or PRs that will introduce breaking changes size/M 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change function params for the mutator config
6 participants