dosubot[bot] commented on issue #29466:
URL: https://github.com/apache/superset/issues/29466#issuecomment-2205727753

   <!-- Greeting -->
   @PedroMartinSteenstrup Hello there! I'm here to help you with any bugs, 
questions, or contributions you have in mind. Let's squash those bugs together! 
😊
   
   <!-- Answer -->
   The issue you're encountering with SQL queries containing inline comments 
has been addressed in several pull requests, including #27725, #28363, #28567, 
and #29248. These changes ensure that comments are not stripped when executing 
SQL statements, which should resolve the errors you're seeing in both the 
dashboards' "view query" and SQL Lab.
   
   To fix the issue, ensure you are using the latest version of Superset where 
these fixes have been merged. Specifically, the changes in pull request #29248 
should address the problem you're facing with inline comments starting with 
`--` 
<sup>[[1]](https://github.com/apache/superset/blob/master/CHANGELOG/4.0.1.md)</sup>.
   
   If you are already on the latest version and still experiencing issues, 
double-check your `sql_mutator` function implementation and ensure it aligns 
with the updated handling of SQL comments. Here is a simplified example of how 
you might define the `sql_mutator` function:
   
   ```python
   def sql_mutator(sql, security_manager, database):
       from superset.utils.core import get_username
       user_name = get_username()
       q_suffix = f'Superset query context \'{{"user": "{user_name}"}}\''
       return f"{sql} -- {q_suffix}"
   ```
   
   Make sure your Superset configuration includes this function and that 
`MUTATE_AFTER_SPLIT` is set according to your needs:
   
   ```python
   SQL_QUERY_MUTATOR = sql_mutator
   MUTATE_AFTER_SPLIT = False
   ```
   
   This should help resolve the errors related to inline comments in your SQL 
queries.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
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: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to