class_docstr: This handler handles connection and execution of the S3 statements.
class_docstr_tok: ["This","handler","handles","connection","and","execution","of","the","S3","statements","."]
docstr: Receive raw query and act upon it somehow.
  Args:
      query (str): query in native format
  Returns:
      HandlerResponse
docstr_tok: ["Receive","raw","query","and","act","upon","it","somehow",".","Args",":","query","(","str",")",":","query","in","native","format","Returns",":","HandlerResponse"]
code: def native_query(self, query: str) -> StatusResponse:
      """
      Receive raw query and act upon it somehow.
      Args:
          query (str): query in native format
      Returns:
          HandlerResponse
      """
  
      need_to_close = self.is_connected is False
  
      connection = self.connect()
  
      try:
          result = connection.select_object_content(
              Bucket=self.connection_data["bucket"],
              Key=self.connection_data["key"],
              ExpressionType="SQL",
              Expression=query,
              InputSerialization=ast.literal_eval(
                  self.connection_data["input_serialization"]
              ),
              OutputSerialization={"CSV": {}},
          )
  
          records = []
          for event in result["Payload"]:
              if "Records" in event:
                  records.append(event["Records"]["Payload"])
              elif "Stats" in event:
                  stats = event["Stats"]["Details"]
  
          file_str = "".join(r.decode("utf-8") for r in records)
  
          df = pd.read_csv(io.StringIO(file_str))
  
          response = Response(RESPONSE_TYPE.TABLE, data_frame=df)
      except Exception as e:
          logger.error(
              f'Error running query: {query} on {self.connection_data["key"]} in {self.connection_data["bucket"]}!'
          )
          response = Response(RESPONSE_TYPE.ERROR, error_message=str(e))
  
      if need_to_close is True:
          self.disconnect()
  
      return response
  
imports: from typing import Optional
  from collections import OrderedDict
  import pandas
  import boto3
  import io
  import ast
  from mindsdb_sql import parse_sql
  from mindsdb_sql.render.sqlalchemy_render import SqlalchemyRender
  from mindsdb.integrations.libs.base import DatabaseHandler
  from mindsdb_sql.parser.ast.base import ASTNode
  from mindsdb.utilities import log
  from mindsdb.integrations.libs.response import HandlerStatusResponse, HandlerResponse, RESPONSE_TYPE
  from mindsdb.integrations.libs.const import HANDLER_CONNECTION_ARG_TYPE
label_desc: Use image node_id 6 for calling the S3Handler obj's underlying member method code with example usage: obj.native_query(query) and returns: response