-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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(charts): allow query mutator to update queries after splitting original sql #21645
Conversation
…/superset into ofs-digital-superset
…erset into ofs-digital-superset # Conflicts: # superset/models/core.py
…-digital-superset # Conflicts: # superset/connectors/sqla/models.py # superset/models/core.py
This reverts commit 38c450a.
This reverts commit af0eb77.
superset/models/core.py
Outdated
engine = self.get_sqla_engine(schema) | ||
username = utils.get_username() or username |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@villebro Comment from original Pull Request
This variable doesn't appear to be defined in this scope?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@baz-bakerhughes @villebro If caching is enabled in the Superset configuration, then by default the username value will be used and so username might not need be defined in the config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@villebro @baz-bakerhughes I have pushed the changes suggested.
Codecov Report
@@ Coverage Diff @@
## master #21645 +/- ##
==========================================
- Coverage 66.90% 66.84% -0.07%
==========================================
Files 1850 1850
Lines 70701 70713 +12
Branches 7750 7750
==========================================
- Hits 47306 47271 -35
- Misses 21379 21426 +47
Partials 2016 2016
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
boomp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@solanksh this worked great as a patch on 2.0.1 but in 2.1.0 this no longer seems to work. after clicking 'create chart' on results from sqllab it then shows "Unexpected error however if i click save dataset then it works...in 2.0.1 clicking explore forced u to save the dataset (as i notice it would send datasource type: table to the data/ endpoint) whereas 2.1.0 sends datasource type:query and doesn't force u to save the dataset @lyndsiWilliams @AAfghahi i see several commits about changing sqllab to explore flow, is there way to bring back the mandatory save dataset popup when clicking 'create chart' ? breaking change mentioned in #22802 (comment) seems like the mutate feature doesn't handle going straight into explore without creating dataset 😢 @rusackas @eschutho |
@tooptoop4 is the functionality only broken when the new config is set to |
@eschutho I always use with True because I need |
I got the same issue as yours.. Could you give me some alternative method to bypass this issue..? |
did u solve @okayhooni ? |
feat(charts): allow query mutator to update queries after splitting original sql
SUMMARY
The changes allow a user to use the SQL_QUERY_MUTATOR function to add statements such as SET ROLE without breaking functionality. Currently, adding a statemen like this works fine in the SQL Editor, but Charts run individual statements by splitting a passed query and throw errors since SET ROLE does not return any data on its own. With the new MUTATE_AFTER_SPLIT variable, users can choose to apply the mutator function after the chart's query execution function splits a given query, allowing users to apply a change to all statements in a query and have Chart functionality not be interrupted.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
In the config file, update the SQL_QUERY_MUTATOR function to add a statement which does not return any results on its own and is something which should be run alongside all other statements in a given query. An example of this is adding a SET ROLE statement to the beginning of a query. Create a new Chart and see if queries return errors due to no data being fetched. Now in the config file, add a MUTATE_AFTER_SPLIT variable and set it equal to True. Create a new Chart and make a query, and verify that the desired results are showing.
ADDITIONAL INFORMATION