-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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: push predicates into virtual datasets #31486
Conversation
LGTM at quick glance. It would be nice to have a roadmap in place for this, so that the feature flag isn't left dangling. Something like:
Were you planning something similar? |
2b56017
to
9711014
Compare
@villebro there are roughly two reasons why we parse SQL in Superset:
The feature from this PR falls in category 2. I think that any functionality in that category should always be optional, since there are always security and correctness concerns when modifying a query. So I would propose the following:
|
Actually, I think we should have a list of engines in |
@betodealmeida would this also push RLS rules to the query predicate as well? |
I think so, but let me double check. |
Yeah, the RLS is applied in |
SUMMARY
In a perfect world database optimizers would know how to push predicates into inner queries, but in reality many databases don't do that. This can be a huge performance issue for charts built on top of virtual datasets, where the SQL is wrapped by the controls from the chart builder.
This PR introduces a new feature flag
OPTIMIZE_SQL
. When the feature is on, and the database engine has a supported dialect insqlglot
, SQL queries on virtual datasets will be optimized automatically, pushing the predicates into the innerSELECT
is possible.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
Added unit tests.
ADDITIONAL INFORMATION