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

fix(explore): #10098 boolean filter not working #14567

Conversation

m-ajay
Copy link
Contributor

@m-ajay m-ajay commented May 11, 2021

SUMMARY

Fixes #10098.
When the column type is boolean/number type, show IS TRUE and IS FALSE options.

Screen Shot 2021-05-11 at 1 23 37 PM

TEST PLAN

CI and manual test

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@junlincc
Copy link
Member

hi ajay, thanks for contributing to the quality bash! please make sure to include screenshot and description in your pr and change the title. e.g. fix(explore): filter on boolean column ...

@junlincc junlincc added need:more-info Requires more information from author need: change-title labels May 11, 2021
@m-ajay m-ajay changed the title [WIP] Fix/issue 10098 boolean filter not working fix: [WIP] #10098 boolean filter not working May 11, 2021
@graceguo-supercat graceguo-supercat changed the title fix: [WIP] #10098 boolean filter not working fix: #10098 boolean filter not working May 11, 2021
@graceguo-supercat graceguo-supercat marked this pull request as ready for review May 11, 2021 22:19
0
);
}
if (dataSourceType === 'table' && !isColumnNumber) {
Copy link

Choose a reason for hiding this comment

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

For calculated column, which could be number, string, date, or unset type. If it is unset, we probably show IS_TRUE, IS_FALSE as option?

Here is an example of setting for calculated column:

Screen Shot 2021-05-11 at 3 13 34 PM

Copy link
Member

@ktmud ktmud left a comment

Choose a reason for hiding this comment

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

I don't think we need to add additional comparators. Superset should be smart enough to know a column is boolean or not.

The col_spec accessed earlier already has an indication whether a column is Boolean. You can just handle the filter value differently based on this information.

@ktmud
Copy link
Member

ktmud commented May 11, 2021

The easier fix is probably convert string value "true"/"false" to booleans here.

An optional work is to update the frontend to change the input from text input to select.

@graceguo-supercat
Copy link

I don't think we need to additional comparators. Superset should be smart enough to know a column is boolean or not.

An optional work is to update the frontend to change the input from text input to select.

If not the additional operator, IS_TURE, IS_FALSE, which are 2 new options for the select, what is suggested way for the frontend to change the input from text input to select?

@m-ajay m-ajay changed the title fix: #10098 boolean filter not working fix(explore): #10098 boolean filter not working May 12, 2021
@ktmud
Copy link
Member

ktmud commented May 12, 2021

IIRC, currently the value input would query the backend for available options, we can probably just give it a fixed options if we detect the column type is boolean.

@codecov
Copy link

codecov bot commented May 12, 2021

Codecov Report

Merging #14567 (32ebf1c) into master (adbe56c) will decrease coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14567      +/-   ##
==========================================
- Coverage   77.40%   77.32%   -0.08%     
==========================================
  Files         958      958              
  Lines       48326    48579     +253     
  Branches     5677     5713      +36     
==========================================
+ Hits        37407    37565     +158     
- Misses      10719    10814      +95     
  Partials      200      200              
Flag Coverage Δ
hive ?
javascript 72.54% <100.00%> (+0.07%) ⬆️
mysql 81.39% <100.00%> (+0.23%) ⬆️
postgres 81.41% <100.00%> (+0.22%) ⬆️
presto ?
python 81.49% <100.00%> (-0.23%) ⬇️
sqlite 81.03% <100.00%> (+0.24%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset-frontend/src/explore/constants.ts 100.00% <ø> (ø)
...onents/controls/FilterControl/AdhocFilter/index.js 97.01% <100.00%> (+0.09%) ⬆️
...l/AdhocFilterEditPopoverSimpleTabContent/index.jsx 79.39% <100.00%> (+1.91%) ⬆️
superset/connectors/sqla/models.py 88.46% <100.00%> (-1.62%) ⬇️
superset/utils/core.py 88.90% <100.00%> (-0.10%) ⬇️
superset/db_engines/hive.py 0.00% <0.00%> (-82.15%) ⬇️
...uperset-frontend/src/components/Form/FormLabel.tsx 68.75% <0.00%> (-31.25%) ⬇️
superset/db_engine_specs/hive.py 70.32% <0.00%> (-17.08%) ⬇️
...ontend/src/common/hooks/apiResources/dashboards.ts 40.00% <0.00%> (-10.00%) ⬇️
...ponents/controls/TimeSeriesColumnControl/index.jsx 91.78% <0.00%> (-8.22%) ⬇️
... and 83 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update adbe56c...32ebf1c. Read the comment docs.

@pull-request-size pull-request-size bot added size/L and removed size/M labels May 12, 2021
@junlincc junlincc removed need: change-title need:more-info Requires more information from author labels May 13, 2021
@junlincc
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

@junlincc Ephemeral environment spinning up at http://52.32.196.39:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@m-ajay m-ajay requested a review from ktmud May 13, 2021 13:45
Copy link

@graceguo-supercat graceguo-supercat left a comment

Choose a reason for hiding this comment

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

LGTM

if (dataSourceType === 'table') {
return !(DRUID_ONLY_OPERATORS.indexOf(operator) >= 0);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this whole section can be simplified as

if (operator === OPERATORS['IS TRUE'] || operator === OPERATORS['IS FALSE'])) {
    return isColumnBoolean || isColumnBoolean;
}
if (isColumnBoolean) {
    return operator === OPERATORS['IS NULL'] || operator === OPERATORS['IS NOT NULL'];
}

@m-ajay m-ajay requested a review from ktmud May 17, 2021 14:23
Copy link
Member

@geido geido left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@ktmud ktmud left a comment

Choose a reason for hiding this comment

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

LGTM with just a couple of notes on cleanups.

DRUID_ONLY_OPERATORS.indexOf(operator) >= 0) ||
[...BOOLEAN_ONLY_OPERATORS, ...DRUID_ONLY_OPERATORS].indexOf(
operator,
) >= 0) ||
Copy link
Member

Choose a reason for hiding this comment

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

You can revert changes in these two lines, too, since you've checked boolean operators above.

export const BOOLEAN_ONLY_OPERATORS = [
OPERATORS['IS TRUE'],
OPERATORS['IS FALSE'],
];
Copy link
Member

Choose a reason for hiding this comment

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

This variable could also be deleted.

@graceguo-supercat graceguo-supercat merged commit 90378ed into apache:master May 18, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

@m-ajay m-ajay deleted the fix/issue-10098-boolean-filter-not-working branch May 19, 2021 19:54
@junlincc
Copy link
Member

junlincc commented May 20, 2021

@m-ajay thanks again for the fix! i believe boolean filter is broken in filter box as well, does this change cover that?

cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
* Restrict operators when column is boolean

* refactor 'isOperatorRelevant' a little bit

* Include 'BOOLEAN' to handle presto

* Update tests

* number column should show bool operators

* fix test - some dbs translate true/false to 1/0

* Fix tests and add linting

* When column type is boolean, show bool operators

* Address PR comments - simplify conditions

* Fix a linting error

* Addressing PR comment - remove unused variables
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* Restrict operators when column is boolean

* refactor 'isOperatorRelevant' a little bit

* Include 'BOOLEAN' to handle presto

* Update tests

* number column should show bool operators

* fix test - some dbs translate true/false to 1/0

* Fix tests and add linting

* When column type is boolean, show bool operators

* Address PR comments - simplify conditions

* Fix a linting error

* Addressing PR comment - remove unused variables
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
* Restrict operators when column is boolean

* refactor 'isOperatorRelevant' a little bit

* Include 'BOOLEAN' to handle presto

* Update tests

* number column should show bool operators

* fix test - some dbs translate true/false to 1/0

* Fix tests and add linting

* When column type is boolean, show bool operators

* Address PR comments - simplify conditions

* Fix a linting error

* Addressing PR comment - remove unused variables
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.0 labels Mar 12, 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 size/L 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter on bool column not working properly in SQL Lab -> Explore
6 participants