ktmud commented on a change in pull request #14567:
URL: https://github.com/apache/superset/pull/14567#discussion_r632059209
##########
File path:
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.jsx
##########
@@ -236,16 +237,45 @@ export default class
AdhocFilterEditPopoverSimpleTabContent extends React.Compon
}
isOperatorRelevant(operator, subject) {
+ const dataSourceType = this.props.datasource.type;
+ 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 (isColumnBoolean) {
+ return (
+ [
+ OPERATORS['IS NULL'],
+ OPERATORS['IS NOT NULL'],
+ ...BOOLEAN_ONLY_OPERATORS,
+ ].indexOf(operator) >= 0
+ );
+ }
+ if (isColumnNumber || isColumnFunction) {
+ if (dataSourceType === 'druid') {
+ return !(TABLE_ONLY_OPERATORS.indexOf(operator) >= 0);
+ }
+ if (dataSourceType === 'table') {
+ return !(DRUID_ONLY_OPERATORS.indexOf(operator) >= 0);
+ }
+ }
Review comment:
I think this whole section can be simplified as
```ts
if (operator === OPERATORS['IS TRUE'] || operator === OPERATORS['IS
FALSE'])) {
return isColumnBoolean || isColumnBoolean;
}
if (isColumnBoolean) {
return operator === OPERATORS['IS NULL'] || operator === OPERATORS['IS
NOT NULL'];
}
```
--
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]