betodealmeida commented on code in PR #38683:
URL: https://github.com/apache/superset/pull/38683#discussion_r2943753803
##########
superset/models/helpers.py:
##########
@@ -2049,15 +2053,20 @@ def get_from_clause(
if parsed_script.statements:
default_schema = self.database.get_default_schema(self.catalog)
try:
- for statement in parsed_script.statements:
+ # Only regenerate the SQL if RLS predicates were actually
applied.
+ # Unnecessary round-tripping through sqlglot can alter SQL in
+ # dialect-specific ways (e.g. dropping column aliases,
rewriting
+ # Redshift-specific syntax) and break virtual dataset queries.
+ if any(
apply_rls(
self.database,
self.catalog,
self.schema or default_schema or "",
statement,
)
- # Regenerate the SQL after RLS application
- from_sql = parsed_script.format()
+ for statement in parsed_script.statements
+ ):
+ from_sql = parsed_script.format()
Review Comment:
Oh, great catch!
--
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]