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

Filter Enhancement (#933) - Filter Value Dropdown #1061

Closed
wants to merge 1 commit into from

Conversation

the-dcruz
Copy link
Contributor

Overview

This PR address the issue #933, which is to replace the filter TextField with a FreeFormSelect to make it easier for the user to know what types of values are possible for a filter.

If their desired value is not in the list, they can still type in their custom value. (Especially common for regex operation)

The feature must be enabled on the table/datasource.

Technical Changes

  • Added new API endpoint /filter/<datasource_type>/<datasource_id>/<column>/
  • Added new function values_for_column to models.DruidDatasource and models.SqlaTable (migration script included)
    • values_for_column uses the same querystring as query
    • Currently limited to 500 values
  • Added new boolean column to datasources and tables to indicate allowing filter value select
  • add_filter in explore.jsx will now fix the filter IDs upon render instead of by prepForm on query submit

Screenshots

How filter looks:
screen shot 2016-08-15 at 2 07 56 pm

Option on table:
screen shot 2016-08-15 at 2 12 18 pm

TODO for Future PR

  • Entire filter can be redone in React
  • Cache filter endpoint

@mistercrunch

@the-dcruz
Copy link
Contributor Author

This PR is the same as #948

Sorry I closed that PR while I was fixing issues after rebasing and my force push didn't allow me to re-open it.

@kkalyan
Copy link
Contributor

kkalyan commented Sep 6, 2016

Great enhancement, thanks @the-dcruz!

Is there a way to select multiple options ?
Currently comma separated values works as OR. May be switch to Select2 widget ?

@mistercrunch
Copy link
Member

It needs to be backward compatible with the existing multi-value filters.

@the-dcruz
Copy link
Contributor Author

@kkalyan @mistercrunch
I currently have this implemented with a freeform select since it is likely that not all possible values for a given column will be displayed (limit=500 currently). My idea was to have this select act as a guide for the user to see a sample of the possible values for the column. The user can then type the values with commas as before.

Maybe a better implementation I can try would be a freeform multiselect?

@the-dcruz
Copy link
Contributor Author

Updated PR to now use freeform multiselect.

screen shot 2016-09-12 at 1 27 32 pm

@ShengyaoQian
Copy link

This would be a very helpful enhancement!

@the-dcruz
Copy link
Contributor Author

the-dcruz commented Sep 15, 2016

@mistercrunch I was wondering if there was still a chance of this PR being looked into. I've periodically rebased it but will hold off until I know it will be looked at. Thanks

@mistercrunch
Copy link
Member

Oh nice! I didn't see your updates since my last comment. I'm a bit overwhelmed with the amount of notifications and communication channels around me.

This looks good, I'll fetch your branch and do some testing on our staging environment today.

@mistercrunch
Copy link
Member

Quick question before I test, we recently had a PR to fix a bug around filtering on strings that include commas, is that handled on your side?

@mistercrunch
Copy link
Member

@vera-liu , since you're familiar with this feature and this part of the code, would you mind doing some testing/reviewing here?

@the-dcruz
Copy link
Contributor Author

@mistercrunch Doesn't ring a bell. Could you point me to the PR? I'll try to get that integrated. Thanks for taking a look btw!

And no worries, I understand it can't be easy managing multiple popular open source projects 😄

@vera-liu
Copy link
Contributor

Hi! I was trying to test this on energy_usage example database but somehow the values are not showing up for me. Am I on the right user flow?

  1. Toggle 'Enable Filter Select' in Edit mode of energy_usage
  2. Go to explore view and click on plus-sign of Filters

screen shot 2016-09-21 at 1 53 15 pm

@the-dcruz
Copy link
Contributor Author

@vera-liu I use the same time parameters for this query as specified for the slice. Can you show me which time params you selected?

@vera-liu
Copy link
Contributor

These ones?
screen shot 2016-09-21 at 2 18 14 pm

@the-dcruz
Copy link
Contributor Author

Yes. Does 7 Days ago actually return any data to display in the chart?

@vera-liu
Copy link
Contributor

Yes:
screen shot 2016-09-21 at 2 20 18 pm
But the filter values do not show up in the dropdown:
screen shot 2016-09-21 at 2 21 13 pm

@the-dcruz
Copy link
Contributor Author

@vera-liu I see my issue. Energy usage does not have any time column.

I guess I'll ignore time in my query if there is no time column. I'll add that fix in a bit. Could you try with something time sensitive like "birth names"?

@the-dcruz
Copy link
Contributor Author

@vera-liu I pushed the fix so it should work for the energy table now. I'll rebase as soon as you think things look good. Thanks!

@vera-liu
Copy link
Contributor

vera-liu commented Sep 21, 2016

It's looking good :). We used to have a bug with comma in filter values:
#1045

Solved in this PR: #1084

We should include that fix in this PR

timestamp >= text(dttm_col.dttm_sql_literal(from_dttm)),
timestamp <= text(dttm_col.dttm_sql_literal(to_dttm)),
]
qry = qry.where(and_(*time_filter)) if granularity else qry
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need if granularity else qry here? If this is inside if granularity: it should always be true right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Forgot to remove this.

@the-dcruz
Copy link
Contributor Author

@vera-liu I decided that the most consistent way to integrate your fix is to wrap all the filter choices with the single quotes.

This seems reasonable to me since this is a dropdown containing column values instead of column names like many of the other dropdowns.

screen shot 2016-09-21 at 5 00 16 pm

@vera-liu
Copy link
Contributor

vera-liu commented Sep 22, 2016

Do you mind rebasing on latest master since it has python test for filter values with commas?

@the-dcruz the-dcruz force-pushed the filter-value-selector branch 2 times, most recently from 7ded4c4 to e539882 Compare September 22, 2016 18:12
@the-dcruz
Copy link
Contributor Author

@vera-liu Sure. Done

@the-dcruz
Copy link
Contributor Author

Looks like another migration file was introduced after rebase, causing the tests to fail. I'll update my migration file and rebase again.

@the-dcruz
Copy link
Contributor Author

Tests look good after rebase @vera-liu

@vera-liu
Copy link
Contributor

vera-liu commented Sep 26, 2016

So Sorry for the delay, I think it's looking good! I'll test it against prod db and then confirm. Could you resolve the conflicts and bump the migration in the meantime? Thank you for the patience! @the-dcruz

@mistercrunch
Copy link
Member

please rebase so that we can merge this!

@kkalyan
Copy link
Contributor

kkalyan commented Nov 4, 2016

@the-dcruz can't wait to see this in master, please rebase!

@the-dcruz the-dcruz force-pushed the filter-value-selector branch 3 times, most recently from 32cd717 to a8c3bbb Compare November 8, 2016 01:35
@the-dcruz
Copy link
Contributor Author

the-dcruz commented Nov 8, 2016

@kkalyan Sorry about the wait! I had abandoned this PR thinking it was going to be waived off until exploreV2.

@mistercrunch I've rebased and retested this.

@ascott
Copy link
Contributor

ascott commented Nov 17, 2016

@vera-liu would you make sure this gets added to the filters component in V2?

@vera-liu
Copy link
Contributor

Seems like caravel-superset renaming caused conflicts in this PR, I will try to include this feature in explore V2, but feel free to merge into V1 if you would like @the-dcruz, it's an awesome feature to have!

@mistercrunch
Copy link
Member

This is done in master

zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 17, 2021
Bumps [ssri](https://github.com/npm/ssri) from 6.0.1 to 6.0.2. **This update includes a security fix.**
- [Release notes](https://github.com/npm/ssri/releases)
- [Changelog](https://github.com/npm/ssri/blob/v6.0.2/CHANGELOG.md)
- [Commits](npm/ssri@v6.0.1...v6.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 24, 2021
Bumps [ssri](https://github.com/npm/ssri) from 6.0.1 to 6.0.2. **This update includes a security fix.**
- [Release notes](https://github.com/npm/ssri/releases)
- [Changelog](https://github.com/npm/ssri/blob/v6.0.2/CHANGELOG.md)
- [Commits](npm/ssri@v6.0.1...v6.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 25, 2021
Bumps [ssri](https://github.com/npm/ssri) from 6.0.1 to 6.0.2. **This update includes a security fix.**
- [Release notes](https://github.com/npm/ssri/releases)
- [Changelog](https://github.com/npm/ssri/blob/v6.0.2/CHANGELOG.md)
- [Commits](npm/ssri@v6.0.1...v6.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 26, 2021
Bumps [ssri](https://github.com/npm/ssri) from 6.0.1 to 6.0.2. **This update includes a security fix.**
- [Release notes](https://github.com/npm/ssri/releases)
- [Changelog](https://github.com/npm/ssri/blob/v6.0.2/CHANGELOG.md)
- [Commits](npm/ssri@v6.0.1...v6.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants