rebenitez1802 commented on code in PR #37865:
URL: https://github.com/apache/superset/pull/37865#discussion_r2794217731


##########
superset/daos/dataset.py:
##########
@@ -49,6 +52,42 @@ class DatasetDAO(BaseDAO[SqlaTable]):
 
     base_filter = DatasourceFilter
 
+    @classmethod
+    def apply_column_operators(
+        cls,
+        query: Query,
+        column_operators: list[ColumnOperator] | None = None,
+    ) -> Query:
+        """Override to handle database_name filter via join to Database table.
+
+        database_name lives on Database, not SqlaTable, so we intercept it
+        here, join to the Database table, and apply the filter there.
+        """
+        if not column_operators:
+            return query
+
+        remaining_operators: list[ColumnOperator] = []
+        db_name_operators: list[ColumnOperator] = []
+        for c in column_operators:
+            if not isinstance(c, ColumnOperator):
+                c = ColumnOperator.model_validate(c)
+            if c.col == "database_name":
+                db_name_operators.append(c)
+            else:
+                remaining_operators.append(c)
+
+        if db_name_operators:
+            query = query.join(Database, SqlaTable.database_id == Database.id)

Review Comment:
   is this join could be adding a posible join duplication from 
https://github.com/apache/superset/blob/98ca599eef913c01d82825f21a6addde024d1f3e/superset/views/base.py#L700
 ?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to