-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
fix(Filters): Apply native & cross filters on common columns #30438
Conversation
/testenv up |
@kgabryje Ephemeral environment spinning up at http://35.90.248.247:8080. Credentials are |
superset-frontend/src/dashboard/util/activeAllDashboardFilters.ts
Outdated
Show resolved
Hide resolved
Just realized that highlighting a filter that is not applicable should also be added as an enhancement for this PR. Working on that. |
/testenv up |
@sadpandajoe Ephemeral environment spinning up at http://35.88.232.227:8080. Credentials are |
Just a quick question, should it affect all charts if it's from the same database table even if one is virtual? Example here: http://35.88.232.227:8080/superset/dashboard/11/?native_filters_key=vORa9YtGn5rLPgi2AjgirnIJB_30m_cpUE3kzlqWFgMGjPIw3CKoFrTKjNNAUkan
right now following this step, all charts are affected by the virtual dataset. |
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.
Spoke with @yousoph and it sounds like my case is invalid so going to approve.
Ephemeral environment shutdown and build artifacts deleted. |
(cherry picked from commit 3629483)
All our dashboards utilize cross-filters across various virtual datasets, and we use Jinja to capture and apply filters, even if the filtered columns in the filter are not present in the dataset.
I'm afraid that if this is applied automatically to every case could basically break all of our dashboards |
Not sure if this should go here or to a new issue (and I won't manage to find time to create a reproducible example in the next week). However, I re-tested this feature together with cross filters and the following setup:
I looked through the code and it, in fact, does not consider searching for JINJA in the filter of other charts:
Shouldn't this also look through the There is a workaround to define a calculated column which matches the label of the emitter column. So, adding a calculated column "Colum A", which is simply using |
I didn't review these changes, but it was my understanding that
Similar to the comments above, I know of many use cases where there's jinja logic that intercepts filters for columns that aren't present in the dataset, and use those to modify the chart query somehow. I'm not sure if this has been explicitly stated as a feature that Superset supports, but I think this use case has been well established for a longer time already, hence I feel removing it will be problematic. Does this PR break said workflow? I'm happy to jump on a sync call to discuss this if needed. |
@geido was really careful to not break the compatibility. For that reason, columns with the same name are also affected even if they belong to different datasets. This was some legacy behavior that @geido rightfully maintained.
Looking at the video below, where each chart is from a different dataset, we can see that if I modify the scope, the chart is reloaded according to the scope. I noticed that the query is not being modified when reloading the chart but I don't know if this was intentional or if we found a bug. @geido Screen.Recording.2024-10-21.at.16.16.14.mov |
@Mainer-g00t @fmannhardt as you raised concerns here, did you find that this PR broke your use cases? |
Yes, it does. In our case, charts export filters that are picked up by jinja logic to filter dataset with data that is not part of the columns in the dataset. Specifically, our dataset looks like:
This leads to a roughly 500M row table. We split it in 3 datasets, one for each dimension and use x-filters to select on the other datasets. ie, clicking on one customer on the first table will filter all products and providers for that customer and so on. This allows us to display relationships in big datasets breaking it up in dimensions and using x-filters |
Just to confirm, have you tested the changes here and can confirm that they do indeed break your use case? Because to me it seems like you should still be able to do the same cross filtering even after this change, as long as you've defined your filter scopes correctly. |
Yes, we just tested it on 4.1 and breaks cross filtering for us. It does not apply filters if the column is not in the dataset even when it is used in the WHERE statement with jinja |
Thanks @Mainer-g00t and @fmannhardt. Let me have a deeper look at what you are mentioning. |
Thanks. Just to confirm it does break our use case in 4.1rc3 for two underlying reasons:
(1) The column filtering is renamed with a label (colx as X). So, cross filtering does consider it as X.
(2) We used JINJA to create a custom filter condition based on selected filters (on X) but since there there is no column X in the dataset, it won't do the filtering on the chart. Btw, it does filter correctly when clicking on show the data as table or as SQL statement. So, the filtering is inconsistent.
I think the code checking for expressions (quoted above) simply does not check there WHERE filters defined on the charts. It may also have issues with custom charts.
…________________________________
From: Geido ***@***.***>
Sent: Tuesday, October 22, 2024 2:57:19 PM
To: apache/superset ***@***.***>
Cc: Felix ***@***.***>; Mention ***@***.***>
Subject: Re: [apache/superset] fix(Filters): Apply native & cross filters on common columns (PR #30438)
Thanks @Mainer-g00t<https://github.com/Mainer-g00t> and @fmannhardt<https://github.com/fmannhardt>. Let me have a deeper look at what you are mentioning.
—
Reply to this email directly, view it on GitHub<#30438 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAYN7NVWRPCG2GXD4CF4KJDZ4ZDS7AVCNFSM6AAAAABPDK75DSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRZGIYTINBSHE>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Hi @fmannhardt @Mainer-g00t @geido. May I suggest opening a specific GitHub issue for this so we can track it here? |
Hello, sure, I'll try to do it today with an example of the behaviour before and after the change |
Hi @michael-s-molina , Thanks |
Thank you! I added the issue to the 4.1 board. |
SUMMARY
When in scope (global or specific) charts that are not applicable to the filter (do not share the same datasource or columns) were being applied anyway, causing unnecessary queries. This PR checks that the charts have columns in common or will exclude the charts.
AFTER
COVID.Vaccine.Dashboard.mp4
COVID.Vaccine.Dashboard.1.mp4
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION