docstr: Runs arbitrary sql and returns data as json
docstr_tok: ["Runs","arbitrary","sql","and","returns","data","as","json"]
code: def run(  # pylint: disable=too-many-statements,useless-suppression
      self,
  ) -> CommandResult:
      """Runs arbitrary sql and returns data as json"""
      try:
          query = self._try_get_existing_query()
          if self.is_query_handled(query):
              self._execution_context.set_query(query)  # type: ignore
              status = SqlJsonExecutionStatus.QUERY_ALREADY_CREATED
          else:
              status = self._run_sql_json_exec_from_scratch()
  
          self._execution_context_convertor.set_payload(
              self._execution_context, status
          )
  
          # save columns into metadata_json
          self._query_dao.save_metadata(
              self._execution_context.query,
              self._execution_context_convertor.payload,
          )
  
          return {
              "status": status,
              "payload": self._execution_context_convertor.serialize_payload(),
          }
      except (SupersetErrorException, SupersetErrorsException) as ex:
          # to make sure we raising the original
          # SupersetErrorsException || SupersetErrorsException
          raise ex
      except Exception as ex:
          raise SqlLabException(
              self._execution_context, exception=ex
          ) from ex
  
imports: from __future__ import annotations
  import copy
  import logging
  from typing import Any, TYPE_CHECKING
  from flask_babel import gettext
  from superset.commands.base import BaseCommand
  from superset.common.db_query_status import QueryStatus
  from superset.daos.exceptions import DAOCreateFailedError
  from superset.errors import SupersetErrorType
  from superset.exceptions import SupersetErrorException, SupersetErrorsException, SupersetGenericErrorException
  from superset.models.core import Database
  from superset.models.sql_lab import Query
  from superset.sqllab.command_status import SqlJsonExecutionStatus
  from superset.sqllab.exceptions import QueryIsForbiddenToAccessException, SqlLabException
  from superset.sqllab.execution_context_convertor import ExecutionContextConvertor
  from superset.sqllab.limiting_factor import LimitingFactor
label_desc: Use image node_id 3 for calling the ExecuteSqlCommand obj's underlying member method code with example usage: obj.run() and returns: dict