This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 9724c99341 feat: add support to NOT LIKE operator (#29384)
9724c99341 is described below

commit 9724c993419952fbcbeb8cd19e51a723fc663b04
Author: Darwin Correa <[email protected]>
AuthorDate: Mon Jul 8 13:58:28 2024 -0500

    feat: add support to NOT LIKE operator (#29384)
---
 .../packages/superset-ui-core/src/query/types/Operator.ts            | 1 +
 superset/models/helpers.py                                           | 5 +++++
 superset/utils/core.py                                               | 1 +
 3 files changed, 7 insertions(+)

diff --git 
a/superset-frontend/packages/superset-ui-core/src/query/types/Operator.ts 
b/superset-frontend/packages/superset-ui-core/src/query/types/Operator.ts
index 5b598312c0..0d2cb5b59b 100644
--- a/superset-frontend/packages/superset-ui-core/src/query/types/Operator.ts
+++ b/superset-frontend/packages/superset-ui-core/src/query/types/Operator.ts
@@ -30,6 +30,7 @@ const BINARY_OPERATORS = [
   '<=',
   'ILIKE',
   'LIKE',
+  'NOT LIKE',
   'REGEX',
   'TEMPORAL_RANGE',
 ] as const;
diff --git a/superset/models/helpers.py b/superset/models/helpers.py
index b841426ff7..1c6ad2f5d3 100644
--- a/superset/models/helpers.py
+++ b/superset/models/helpers.py
@@ -1909,6 +1909,11 @@ class ExploreMixin:  # pylint: 
disable=too-many-public-methods
                             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)
diff --git a/superset/utils/core.py b/superset/utils/core.py
index ee5e451f3e..d01dd517ef 100644
--- a/superset/utils/core.py
+++ b/superset/utils/core.py
@@ -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"

Reply via email to