betodealmeida commented on code in PR #28639:
URL: https://github.com/apache/superset/pull/28639#discussion_r1610253810


##########
superset/db_engine_specs/trino.py:
##########
@@ -219,19 +219,22 @@ def execute_with_cursor(
         execute_result: dict[str, Any] = {}
         execute_event = threading.Event()
 
-        def _execute(results: dict[str, Any], event: threading.Event) -> None:
+        def _execute(
+            results: dict[str, Any], event: threading.Event, app: Flask
+        ) -> None:
             logger.debug("Query %d: Running query: %s", query_id, sql)
 
             try:
-                cls.execute(cursor, sql, query.database)
+                with app.app_context():
+                    cls.execute(cursor, sql, query.database)

Review Comment:
   Oh, interesting.



##########
superset/sql_parse.py:
##########
@@ -223,6 +224,19 @@ def get_cte_remainder_query(sql: str) -> tuple[str | None, 
str]:
     return cte, remainder
 
 
+def check_sql_functions_exist(
+    sql: str, function_list: set[str], engine: str | None = None
+) -> bool:
+    """
+    Check if the SQL statement contains any of the specified functions.
+
+    :param sql: The SQL statement
+    :param function_list: The list of functions to search for
+    :param engine: The engine to use for parsing the SQL statement
+    """
+    return ParsedQuery(sql, engine=engine).check_functions_exist(function_list)

Review Comment:
   We (probably me) will have to convert this to use `sqlglot` and the 
`SQLStatement` class (https://github.com/apache/superset/issues/26786) but I'm 
happy to do it, seems simple enough.



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