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

[adhoc-filters] Adding adhoc-filters to all viz types #5206

Merged

Conversation

john-bodley
Copy link
Member

@john-bodley john-bodley commented Jun 15, 2018

So this PR came about because I was working on another feature which required a database migration to update SQL filters when I realized that I needed to update multiple form-data fields, specifically the following fields exist around filters:

  • adhoc_filters
  • filters
  • having
  • having_filters
  • where

Hence the purpose of this PR is to condense the number of form-data fields and simplify filter logic by rolling out ad-hoc filters for all visualization types.

Note I sense it's worthwhile to first outline how the current situation works. On the front-end the ad-hoc filters take the legacy filters, having, having_filters, and where fields which are then merged with adhoc_filters. The adhoc_filters persist in the URL form-data (and when the slice is saved) though are transformed (and removed) back into the legacy filters in the backend. This means that all five filters types can actually persist in the form-data.

This PR is the first of a two-phase change (to help minimize code change). This change is mostly a front-end change, i.e., it applies ad-hoc filters to all visualization types and performs a database migration to upgrade the filters (as opposed to doing this in the frontend). Note the backend still transforms the ad-hoc filters to legacy filters (though the adhhoc_filters field persists). Although this represents a duplication of data the ad-hoc filters are the source of truth throughout, i.e., the legacy filters are always derived from the ad-hoc filters. Note this change ensures that old URLs with legacy filters will still work.

For phase II the plan is to clean up the backend and deprecate the legacy filters. It will ensure URLs with legacy filters will continue to work.

Finally the ad-hoc filters include a unique ID which is required for the frontend which gets persisted to the database. There may be merit in removing this in the future.

Closes #5172.

to: @betodealmeida @GabeLoins @michellethomas @mistercrunch @williaster

@john-bodley john-bodley force-pushed the john-bodley-adhoc-filters-cleanup branch 10 times, most recently from a086903 to 1561cfb Compare June 15, 2018 03:20
@@ -881,4 +881,3 @@ def split_adhoc_filters_into_base_filters(fd):
fd['having'] = ' AND '.join(['({})'.format(sql) for sql in sql_having_filters])
fd['having_filters'] = simple_having_filters
fd['filters'] = simple_where_filters
del fd['adhoc_filters']
Copy link
Member Author

@john-bodley john-bodley Jun 15, 2018

Choose a reason for hiding this comment

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

Note we can no longer remove the adhoc_filters field as we need to ensure that ad-hoc filters persist. Currently (for right or wrong) by deleting this field the ad-hoc filters actually get rebuilt on the frontend by merging the legacy and ad-hoc filters.

@john-bodley john-bodley force-pushed the john-bodley-adhoc-filters-cleanup branch 19 times, most recently from 181805b to 99e2832 Compare June 15, 2018 18:43
@john-bodley john-bodley force-pushed the john-bodley-adhoc-filters-cleanup branch 2 times, most recently from 5879d10 to 1a54eb4 Compare June 16, 2018 00:25
@john-bodley john-bodley force-pushed the john-bodley-adhoc-filters-cleanup branch from 1a54eb4 to c288ed0 Compare June 16, 2018 16:27
Copy link
Contributor

@gabe-lyons gabe-lyons left a comment

Choose a reason for hiding this comment

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

Looks good from my end! Thank you john for making this improvement!

@@ -1683,18 +1683,6 @@
"renderTrigger": true,
"default": ""
},
"where": {
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't touched this file before- what is it doing exactly?

Copy link
Member

Choose a reason for hiding this comment

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

That represents the old TextControl where people would write their WHERE clause. Did we even run a db migration to convert the old filters (where & having) to new ones?

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see it's in this PR !

Copy link
Member Author

Choose a reason for hiding this comment

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

@mistercrunch I'm hoping to clean up the backend later this week so we can remove all references to the old where, having clauses entirely.

@@ -68,49 +59,6 @@ describe('AdhocFilterControl', () => {
expect(wrapper.find(OnPasteSelect)).to.have.lengthOf(1);
});

it('will translate legacy filters into adhoc filters if no adhoc filters are present', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

bye specs!

@@ -56,13 +60,15 @@ export default class AlteredSliceTag extends React.Component {
return 'N/A';
} else if (value === null) {
return 'null';
} else if (controls[key] && controls[key].type === 'FilterControl') {
} else if (controls[key] && controls[key].type === 'AdhocFilterControl') {
Copy link
Contributor

Choose a reason for hiding this comment

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

was this line necessary before? Should I have already made this change or was it only necessary once we removed the legacy filters?

Copy link
Member Author

@john-bodley john-bodley Jun 18, 2018

Choose a reason for hiding this comment

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

@GabeLoins I don't believe ad-hoc filters show up in the altered view. It merely worked if you did Run Query then these filters would be converted to the historical filters, clauses etc. and thus show in the the Altered slice view.

With this change the Altered slice view correctly represents the current UI state.

@john-bodley john-bodley merged commit d483ed1 into apache:master Jun 18, 2018
john-bodley added a commit that referenced this pull request Jun 20, 2018
john-bodley added a commit that referenced this pull request Jun 20, 2018
#5253)

* Revert "[sqllab] Fix sql lab resolution link (#5216)"

This reverts commit 93cdf60.

* Revert "Pin botocore version (#5184)"

This reverts commit 70679d4.

* Revert "Describe the use of custom OAuth2 authorization servers (#5220)"

This reverts commit a84f430.

* Revert "[bubble-chart] Fixing issue w/ metric names (#5237)"

This reverts commit 5c106b9.

* Revert "[adhoc-filters] Adding adhoc-filters to all viz types (#5206)"

This reverts commit d483ed1.

* Revert "[perf] add webpack 4 + SplitChunks + lazy load visualizations (#5240)"

This reverts commit 1fc4ee0.
john-bodley added a commit to john-bodley/superset that referenced this pull request Jun 20, 2018
apache#5253)

* Revert "[sqllab] Fix sql lab resolution link (apache#5216)"

This reverts commit 93cdf60.

* Revert "Pin botocore version (apache#5184)"

This reverts commit 70679d4.

* Revert "Describe the use of custom OAuth2 authorization servers (apache#5220)"

This reverts commit a84f430.

* Revert "[bubble-chart] Fixing issue w/ metric names (apache#5237)"

This reverts commit 5c106b9.

* Revert "[adhoc-filters] Adding adhoc-filters to all viz types (apache#5206)"

This reverts commit d483ed1.

* Revert "[perf] add webpack 4 + SplitChunks + lazy load visualizations (apache#5240)"

This reverts commit 1fc4ee0.

(cherry picked from commit 62427c8)
timifasubaa pushed a commit to airbnb/superset-fork that referenced this pull request Jul 25, 2018
timifasubaa pushed a commit to airbnb/superset-fork that referenced this pull request Jul 25, 2018
apache#5253)

* Revert "[sqllab] Fix sql lab resolution link (apache#5216)"

This reverts commit 93cdf60.

* Revert "Pin botocore version (apache#5184)"

This reverts commit 70679d4.

* Revert "Describe the use of custom OAuth2 authorization servers (apache#5220)"

This reverts commit a84f430.

* Revert "[bubble-chart] Fixing issue w/ metric names (apache#5237)"

This reverts commit 5c106b9.

* Revert "[adhoc-filters] Adding adhoc-filters to all viz types (apache#5206)"

This reverts commit d483ed1.

* Revert "[perf] add webpack 4 + SplitChunks + lazy load visualizations (apache#5240)"

This reverts commit 1fc4ee0.
graceguo-supercat pushed a commit to graceguo-supercat/superset that referenced this pull request Jul 26, 2018
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
apache#5253)

* Revert "[sqllab] Fix sql lab resolution link (apache#5216)"

This reverts commit 93cdf60.

* Revert "Pin botocore version (apache#5184)"

This reverts commit 70679d4.

* Revert "Describe the use of custom OAuth2 authorization servers (apache#5220)"

This reverts commit a84f430.

* Revert "[bubble-chart] Fixing issue w/ metric names (apache#5237)"

This reverts commit 5c106b9.

* Revert "[adhoc-filters] Adding adhoc-filters to all viz types (apache#5206)"

This reverts commit d483ed1.

* Revert "[perf] add webpack 4 + SplitChunks + lazy load visualizations (apache#5240)"

This reverts commit 1fc4ee0.
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.26.0 labels Feb 27, 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 🚢 0.26.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filters not saved when visualization changed
3 participants