-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Custom SQL queries with filters #1996
Comments
I am also interesting on this request. Otherwise, a tableview based on the SQL query without Filtering will do scan on the whole table we are querying. It will be a large cost for the database. |
Well so the tables defined with SQL, or "Superset Views" if we can call them that, do support templating, and from the template it's possible to read the Here's what we squeeze in as template args: We did use that to make sure partition pruning was occurring in complex use cases, specifically on the date which was the partition column. You can imagine a table defined as SQL like
It's also possible to do conditional logic and much more in Jinja (templating language) so you could do something like this (this is not tested at all, would have to be teaked...)
|
Is it possible to get current logged in user using jinja templates? SELECT * FROM tbl |
more like:
|
@mistercrunch, I am getting this error in sql lab when running {{ current_username() }}, Template rendering failed: '_AppCtxGlobals' object has no attribute 'user' Please help! |
I tried to access "time_grain_sqla" (or any other key) in form_data dict in Explore but I am afraid that it is empty. I think it was added at some point: but removed since i don't know why:
So what I get is the empty dict from the constructor:
|
Hello there - We had a huge stack of our reports built using 0.20.4 which let us use custom filters that were not part of the data source in our queries, and now when we upgrade to 0.24.3 or higher we find that these custom filters are rejected or made blank at the jinja_parser stage. Question - Is there a reason this change was done to exclude external custom filters, because we are wondering if there has been a more elegant and cleaner way to do this? We are concerned that this feature might have been completely deprecated which sometimes aggravates our use cases by pulling a lot more data at every pull and making all the dashboards slower. Can someone please help? Thank you! |
@ksaagariconic Could you elaborate with an example what the custom filters looked like, and where they were defined? I believe |
Thanks for the instant response @villebro - we had a lot of queries structured with custom filter predicates like this,
What's happening now is that this predicate is completely getting ignored. It shows up in the frontend as "filter" but doesn't show up in the queryobj or eventual query. We tried this alternative, to use the new filter context, but it says filter is not defined.
What however works is if we have a column by the same name as the filter, e.g. a filter called country with the same variable name works dynamically - but as a predicate on the super query, and not on the actual query in itself. Does this make it clearer? Thanks for offering to help |
Is it possible to specify custom SQL query like using SQL Lab but with an opportunity to apply interactive FilterBox to it?
It would be really nice in tasks where you have to visualize aggregative metrics.
For example, if you have smth like that:
user1, log1,
user2, log2,
...
userN, logM
And you want to plot a distribution of counters of logs for users in a following way:
If I am not mistaken you can not do it directly from Superset slices but it is a very common case.
The text was updated successfully, but these errors were encountered: