Vitor-Avila commented on code in PR #33542:
URL: https://github.com/apache/superset/pull/33542#discussion_r2116046589
##########
superset/sql_lab.py:
##########
@@ -434,67 +452,52 @@ def execute_sql_statements( # noqa: C901
db_engine_spec.patch()
if database.allow_run_async and not results_backend:
- raise SupersetErrorException(
- SupersetError(
- message=__("Results backend is not configured."),
-
error_type=SupersetErrorType.RESULTS_BACKEND_NOT_CONFIGURED_ERROR,
- level=ErrorLevel.ERROR,
- )
- )
-
- # Breaking down into multiple statements
- parsed_query = ParsedQuery(
- rendered_query,
- engine=db_engine_spec.engine,
- )
- if not db_engine_spec.run_multiple_statements_as_one:
- statements = parsed_query.get_statements()
- logger.info(
- "Query %s: Executing %i statement(s)", str(query_id),
len(statements)
- )
- else:
- statements = [rendered_query]
- logger.info("Query %s: Executing query as a single statement",
str(query_id))
+ raise SupersetResultsBackendNotConfigureException()
logger.info("Query %s: Set query to 'running'", str(query_id))
query.status = QueryStatus.RUNNING
query.start_running_time = now_as_float()
db.session.commit()
- # Should we create a table or view from the select?
- if (
- query.select_as_cta
- and query.ctas_method == CtasMethod.TABLE
- and not parsed_query.is_valid_ctas()
- ):
- raise SupersetErrorException(
- SupersetError(
- message=__(
- "CTAS (create table as select) can only be run with a
query where "
- "the last statement is a SELECT. Please make sure your
query has "
- "a SELECT as its last statement. Then, try running your
query "
- "again."
- ),
- error_type=SupersetErrorType.INVALID_CTAS_QUERY_ERROR,
- level=ErrorLevel.ERROR,
- )
- )
- if (
- query.select_as_cta
- and query.ctas_method == CtasMethod.VIEW
- and not parsed_query.is_valid_cvas()
- ):
- raise SupersetErrorException(
- SupersetError(
- message=__(
- "CVAS (create view as select) can only be run with a query
with "
- "a single SELECT statement. Please make sure your query
has only "
- "a SELECT statement. Then, try running your query again."
- ),
- error_type=SupersetErrorType.INVALID_CVAS_QUERY_ERROR,
- level=ErrorLevel.ERROR,
- )
+ parsed_script = SQLScript(rendered_query, engine=db_engine_spec.engine)
+
+ if parsed_script.has_mutation() and not database.allow_dml:
+ raise SupersetDMLNotAllowedException()
Review Comment:
Previously we would validate statement by statement if they were DML. Now
we're validating before splitting statements -- does that work properly with
`sqlglot`?
--
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]