mikebridge commented on code in PR #44899:
URL: https://github.com/apache/superset/pull/44899#discussion_r4200434419


##########
superset/common/query_object.py:
##########
@@ -494,6 +494,18 @@ def _is_valid_date_range(self, date_range: str) -> bool:
             return False
 
     def _sanitize_filters(self) -> None:
+        if (
+            self.datasource
+            and self.datasource.type == "semantic_view"
+            and (self.extras.get("where") or self.extras.get("having"))
+        ):
+            raise QueryObjectValidationError(
+                _(
+                    "SQL WHERE/HAVING expressions are not supported for 
semantic "
+                    "views. Remove the SQL clause or use a semantic dimension 
filter."
+                )
+            )

Review Comment:
   Good catch. The mapper still translates these extras for direct calls, but 
we've decided to keep custom SQL WHERE/HAVING unsupported on semantic views for 
this first release, so the 400 stays.
   
   - f93900c18c documents that boundary on the mapper helper: it is not 
reachable from the chart-data path.
   - cf761e5611 moves the rejection to the start of `QueryObject.validate()`, 
before the semantic view's provider is resolved, with a test that fails if the 
provider is touched first.
   
   Per-provider support would need its own sanitization and capability design, 
along the lines you describe for `ADHOC_EXPRESSIONS_IN_ORDERBY`. One known 
limit: the chart-data context builder can still read the view's column metadata 
before validation runs; the PR description notes it.



##########
superset/common/query_object.py:
##########
@@ -494,6 +494,18 @@ def _is_valid_date_range(self, date_range: str) -> bool:
             return False
 
     def _sanitize_filters(self) -> None:
+        if (
+            self.datasource
+            and self.datasource.type == "semantic_view"
+            and (self.extras.get("where") or self.extras.get("having"))

Review Comment:
   Custom SQL WHERE/HAVING on semantic views is intentionally unsupported for 
this first release, so rejecting it here is the intended behaviour. The 
mapper's conversion helper is kept for direct callers, and f93900c18c documents 
that it is not reachable from chart-data. Provider-specific support would need 
a separate capability and sanitization design.



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