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
fix(explore): #10098 boolean filter not working #14567
Conversation
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 ... |
0 | ||
); | ||
} | ||
if (dataSourceType === 'table' && !isColumnNumber) { |
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.
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.
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.
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. |
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? |
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 |
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
/testenv up |
@junlincc Ephemeral environment spinning up at http://52.32.196.39:8080. Credentials are |
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.
LGTM
if (dataSourceType === 'table') { | ||
return !(DRUID_ONLY_OPERATORS.indexOf(operator) >= 0); | ||
} | ||
} |
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.
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'];
}
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.
LGTM!
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.
LGTM with just a couple of notes on cleanups.
DRUID_ONLY_OPERATORS.indexOf(operator) >= 0) || | ||
[...BOOLEAN_ONLY_OPERATORS, ...DRUID_ONLY_OPERATORS].indexOf( | ||
operator, | ||
) >= 0) || |
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.
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'], | ||
]; |
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.
This variable could also be deleted.
Ephemeral environment shutdown and build artifacts deleted. |
@m-ajay thanks again for the fix! i believe boolean filter is broken in filter box as well, does this change cover that? |
* 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
* 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
* 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
SUMMARY
Fixes #10098.
When the column type is boolean/number type, show
IS TRUE
andIS FALSE
options.TEST PLAN
CI and manual test
ADDITIONAL INFORMATION