Antonio-RiveroMartnez commented on code in PR #33340:
URL: https://github.com/apache/superset/pull/33340#discussion_r2073252347


##########
superset/databases/api.py:
##########
@@ -311,6 +311,16 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
     base_related_field_filters = {
         "changed_by": [["id", BaseFilterRelatedUsers, lambda: []]],
     }
+    @expose("/execute/", methods=("POST",))
+    @protect()
+    @statsd_metrics
+    @requires_json
+    @event_logger.log_this_with_context(
+        action=lambda self, *args, **kwargs: 
f"{self.__class__.__name__}.get_results",
+        log_to_statsd=False,
+    )
+    def execute_sql_query(self) -> FlaskResponse:
+        return self.response(request.json)

Review Comment:
   Is this a leftover? This API seems to be a noop.



##########
superset/sql/execution_context_convertor.py:
##########
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import logging
+from typing import Any, TYPE_CHECKING
+
+from superset.sqllab.command_status import SqlJsonExecutionStatus
+from superset.sql.utils import apply_display_max_row_configuration_if_require
+from superset.utils import json
+
+logger = logging.getLogger(__name__)
+
+if TYPE_CHECKING:
+    from superset.sqllab.sqllab_execution_context import 
SqlJsonExecutionContext
+
+
+class ExecutionContextConvertor:

Review Comment:
   Same as before, are we just relocating existing code under new folders? is 
there anything new or in addition to the existing one?



##########
superset/databases/api.py:
##########
@@ -311,6 +311,16 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
     base_related_field_filters = {
         "changed_by": [["id", BaseFilterRelatedUsers, lambda: []]],
     }
+    @expose("/execute/", methods=("POST",))

Review Comment:
   What's the intention of this API? because we already have an `execute` in 
`superset/sqllab/api.py`



##########
superset/databases/sql_query/api.py:
##########
@@ -0,0 +1,153 @@
+import logging
+from typing import Any, cast, Optional
+from urllib import parse
+
+from flask import request, Response
+from flask_appbuilder import permission_name
+from flask_appbuilder.api import expose, protect, rison, safe
+from marshmallow import ValidationError
+
+from superset.jinja_context import get_template_processor
+from superset import app, is_feature_enabled
+from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP
+from superset.extensions import event_logger
+from superset.superset_typing import FlaskResponse
+from superset.views.base_api import BaseSupersetApi, requires_json, 
statsd_metrics
+from superset.sql.sql_execution_context import SqlJsonExecutionContext
+from superset.sql.sql_json_executer import SqlJsonExecutor, 
ASynchronousSqlJsonExecutor, SynchronousSqlJsonExecutor 
+from superset.sql.execution_context_convertor import ExecutionContextConvertor
+from superset.daos.query import QueryDAO
+from superset.daos.database import DatabaseDAO
+
+from superset.commands.sql_lab.execute import CommandResult, ExecuteSqlCommand
+from superset.sqllab.validators import CanAccessQueryValidatorImpl
+from superset.sqllab.query_render import SqlQueryRenderImpl
+from superset.sqllab.command_status import SqlJsonExecutionStatus
+from superset.sql_lab import get_sql_results
+
+from superset.sqllab.exceptions import (
+    QueryIsForbiddenToAccessException,
+    SqlLabException,
+)
+from superset.views.base import json_success
+from superset.databases.sql_query.schemas import ExecutePayloadSchema
+config = app.config
+
+class SqlQueryRestApi(BaseSupersetApi):

Review Comment:
   Is this API supposed to be a relocation of the one existing in 
`superset/sqllab/api.py` ?
   - if it is, are we deprecating the existing one?
   - if it's not, but instead a new one, what's the difference and can we just 
extend the existing one? 



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