msyavuz commented on code in PR #45681:
URL: https://github.com/apache/superset/pull/45681#discussion_r4379441152


##########
superset/models/helpers.py:
##########
@@ -3994,6 +3995,22 @@ def get_rendered_sql(
     def text(self, clause: str) -> TextClause:
         return self.db_engine_spec.get_text_clause(clause)
 
+    def _get_rls_schema(self) -> str:
+        """Resolve unqualified RLS table names against the schema used at 
execution.
+
+        Only dynamic-schema engines apply the datasource's schema to the 
connection.
+        Other engines resolve it from connection parameters or the inspector, 
using
+        the same query-aware resolver as SQL Lab authorization.
+        """
+        if self.db_engine_spec.supports_dynamic_schema:
+            return self.schema or 
self.database.get_default_schema(self.catalog) or ""
+        return (
+            self.database.resolve_query_default_schema(
+                self.sql, self.schema, self.catalog, self.template_params_dict
+            )
+            or ""

Review Comment:
   This point is still unanswered. On non-dynamic engines with no URI schema 
whose inspector default is `None` (e.g. Druid), the `or ""` here scopes RLS to 
an empty schema instead of the dataset schema that was used before. Unqualified 
tables then miss their physical dataset's RLS rule in both the query and the 
cache key.



##########
superset/models/helpers.py:
##########
@@ -3994,6 +3995,22 @@ def get_rendered_sql(
     def text(self, clause: str) -> TextClause:
         return self.db_engine_spec.get_text_clause(clause)
 
+    def _get_rls_schema(self) -> str:
+        """Resolve unqualified RLS table names against the schema used at 
execution.
+
+        Only dynamic-schema engines apply the datasource's schema to the 
connection.
+        Other engines resolve it from connection parameters or the inspector, 
using
+        the same query-aware resolver as SQL Lab authorization.
+        """
+        if self.db_engine_spec.supports_dynamic_schema:
+            return self.schema or 
self.database.get_default_schema(self.catalog) or ""
+        return (
+            self.database.resolve_query_default_schema(
+                self.sql, self.schema, self.catalog, self.template_params_dict

Review Comment:
   This point is still unanswered. On every virtual-dataset query and cache-key 
build for non-dynamic engines, this calls `get_schema_from_engine_params`. 
TDengine's and Couchbase's versions call 
`parse.unquote(sqlalchemy_uri.database)`, which raises `TypeError` when the URI 
has no database path, so fully qualified virtual datasets that used to work now 
fail.



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