class_docstr: This handler handles connection and execution of the Cloud Spanner statements.
class_docstr_tok: ["This","handler","handles","connection","and","execution","of","the","Cloud","Spanner","statements","."]
docstr: Execute a SQL query.
  
  Args:
      query (str): The SQL query to execute.
  
  Returns:
      Response: The query result.
docstr_tok: ["Execute","a","SQL","query",".","Args",":","query","(","str",")",":","The","SQL","query","to","execute",".","Returns",":","Response",":","The","query","result","."]
code: def native_query(self, query: str) -> Response:
      """Execute a SQL query.
  
      Args:
          query (str): The SQL query to execute.
  
      Returns:
          Response: The query result.
      """
  
      connection = self.connect()
      cursor = connection.cursor()
  
      try:
          cursor.execute(query)
  
          # The cursor description check indicates if there are any results.
          # This is required as spanner_dbapi will fail on a fetchall() call on an empty cursor.
          if cursor.description:
              result = cursor.fetchall()
              response = Response(
                  RESPONSE_TYPE.TABLE,
                  data_frame=pd.DataFrame(
                      result, columns=[x[0] for x in cursor.description]
                  ),
              )
          else:
              response = Response(RESPONSE_TYPE.OK)
  
          connection.commit()
      except Exception as e:
          logger.error(
              f'Error running query: {query} on {self.connection_data["database_id"]}!'
          )
          response = Response(RESPONSE_TYPE.ERROR, error_message=str(e))
  
      cursor.close()
      if self.is_connected:
          self.disconnect()
  
      return response
  
imports: import json
  from collections import OrderedDict
  from google.oauth2 import service_account
  from google.cloud import spanner_dbapi
  from google.cloud.spanner_dbapi import Connection
  from google.cloud.sqlalchemy_spanner import SpannerDialect
  import pandas
  from mindsdb_sql import parse_sql
  from mindsdb_sql.parser.ast.base import ASTNode
  from mindsdb_sql.parser.ast import CreateTable, Function
  from mindsdb_sql.render.sqlalchemy_render import SqlalchemyRender
  from mindsdb.integrations.libs.base import DatabaseHandler
  from mindsdb.integrations.libs.const import HANDLER_CONNECTION_ARG_TYPE
  from mindsdb.integrations.libs.response import RESPONSE_TYPE
  from mindsdb.integrations.libs.response import HandlerResponse
  from mindsdb.integrations.libs.response import HandlerStatusResponse
  from mindsdb.utilities import log
label_desc: Use image node_id 6 for calling the CloudSpannerHandler obj's underlying member method code with example usage: obj.native_query(query) and returns: response