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

feat: add support to NOT LIKE operator #29384

Merged
merged 9 commits into from
Jul 8, 2024
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 @@
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)

Check warning on line 1914 in superset/models/helpers.py

View check run for this annotation

Codecov / codecov/patch

superset/models/helpers.py#L1913-L1914

Added lines #L1913 - L1914 were not covered by tests

where_clause_and.append(sqla_col.not_like(eq))

Check warning on line 1916 in superset/models/helpers.py

View check run for this annotation

Codecov / codecov/patch

superset/models/helpers.py#L1916

Added line #L1916 was not covered by tests
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
Loading