Skip to content

Commit

Permalink
feat: add support to NOT LIKE operator (#29384)
Browse files Browse the repository at this point in the history
  • Loading branch information
dacopan committed Jul 8, 2024
1 parent ee72d6c commit 9724c99
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const BINARY_OPERATORS = [
'<=',
'ILIKE',
'LIKE',
'NOT LIKE',
'REGEX',
'TEMPORAL_RANGE',
] as const;
Expand Down
5 changes: 5 additions & 0 deletions superset/models/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1909,6 +1909,11 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma
where_clause_and.append(sqla_col.like(eq))
else:
where_clause_and.append(sqla_col.ilike(eq))
elif op in {utils.FilterOperator.NOT_LIKE.value}:
if target_generic_type != GenericDataType.STRING:
sqla_col = sa.cast(sqla_col, sa.String)

where_clause_and.append(sqla_col.not_like(eq))
elif (
op == utils.FilterOperator.TEMPORAL_RANGE.value
and isinstance(eq, str)
Expand Down
1 change: 1 addition & 0 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class FilterOperator(StrEnum):
GREATER_THAN_OR_EQUALS = ">="
LESS_THAN_OR_EQUALS = "<="
LIKE = "LIKE"
NOT_LIKE = "NOT LIKE"
ILIKE = "ILIKE"
IS_NULL = "IS NULL"
IS_NOT_NULL = "IS NOT NULL"
Expand Down

0 comments on commit 9724c99

Please sign in to comment.