ktmud commented on a change in pull request #14567:
URL: https://github.com/apache/superset/pull/14567#discussion_r634458650
##########
File path: superset-frontend/src/explore/constants.ts
##########
@@ -42,11 +42,18 @@ export const OPERATORS = {
'IS NOT NULL': 'IS NOT NULL',
'IS NULL': 'IS NULL',
'LATEST PARTITION': 'LATEST PARTITION',
+ 'IS TRUE': 'IS TRUE',
+ 'IS FALSE': 'IS FALSE',
};
+
export const OPERATORS_OPTIONS = Object.values(OPERATORS);
export const TABLE_ONLY_OPERATORS = [OPERATORS.LIKE];
export const DRUID_ONLY_OPERATORS = [OPERATORS.REGEX];
+export const BOOLEAN_ONLY_OPERATORS = [
+ OPERATORS['IS TRUE'],
+ OPERATORS['IS FALSE'],
+];
Review comment:
This variable could also be deleted.
##########
File path:
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.jsx
##########
@@ -236,16 +237,39 @@ export default class
AdhocFilterEditPopoverSimpleTabContent extends React.Compon
}
isOperatorRelevant(operator, subject) {
+ const column = this.props.datasource.columns?.find(
+ col => col.column_name === subject,
+ );
+ const isColumnBoolean =
+ !!column && (column.type === 'BOOL' || column.type === 'BOOLEAN');
+ const isColumnNumber = !!column && column.type === 'INT';
+ const isColumnFunction = !!column && !!column.expression;
+
if (operator && CUSTOM_OPERATORS.has(operator)) {
const { partitionColumn } = this.props;
return partitionColumn && subject && subject === partitionColumn;
}
-
+ if (
+ operator === OPERATORS['IS TRUE'] ||
+ operator === OPERATORS['IS FALSE']
+ ) {
+ return isColumnBoolean || isColumnNumber || isColumnFunction;
+ }
+ if (isColumnBoolean) {
+ return (
+ operator === OPERATORS['IS NULL'] ||
+ operator === OPERATORS['IS NOT NULL']
+ );
+ }
return !(
(this.props.datasource.type === 'druid' &&
- TABLE_ONLY_OPERATORS.indexOf(operator) >= 0) ||
+ [...BOOLEAN_ONLY_OPERATORS, ...TABLE_ONLY_OPERATORS].indexOf(
+ operator,
+ ) >= 0) ||
(this.props.datasource.type === 'table' &&
- DRUID_ONLY_OPERATORS.indexOf(operator) >= 0) ||
+ [...BOOLEAN_ONLY_OPERATORS, ...DRUID_ONLY_OPERATORS].indexOf(
+ operator,
+ ) >= 0) ||
Review comment:
You can revert changes in these two lines, too, since you've checked
boolean operators above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]