class_docstr: This handler handles connection and execution of the Xata statements.
class_docstr_tok: ["This","handler","handles","connection","and","execution","of","the","Xata","statements","."]
docstr: Run general query or a vector similarity search and return results.
docstr_tok: ["Run","general","query","or","a","vector","similarity","search","and","return","results","."]
code: def select(
      self,
      table_name: str,
      columns: List[str] = None,
      conditions: List[FilterCondition] = None,
      offset: int = None,
      limit: int = None,
  ) -> HandlerResponse:
      """Run general query or a vector similarity search and return results."""
      if not columns:
          columns = [col["name"] for col in self.SCHEMA]
      # Generate filter conditions
      filters = self._translate_non_vector_conditions(conditions)
      # Check for search vector
      search_vector = (
          []
          if conditions is None
          else [
              condition.value
              for condition in conditions
              if condition.column == TableField.SEARCH_VECTOR.value
          ]
      )
      if len(search_vector) > 0:
          search_vector = search_vector[0]
      else:
          search_vector = None
      # Search
      results_df = pd.DataFrame(columns)
      if search_vector is not None:
          # Similarity
          try:
              params = {
                  "queryVector": search_vector,
                  "column": TableField.EMBEDDINGS.value,
                  "similarityFunction": self._select_params[
                      "similarity_function"
                  ],
              }
              if filters:
                  params["filter"] = filters
              if limit:
                  params["size"] = limit
              results = self._client.data().vector_search(
                  table_name, params
              )
              # Check for errors
              if not results.is_success():
                  raise Exception(results["message"])
              # Convert result
              results_df = pd.DataFrame.from_records(results["records"])
              if "xata" in results_df.columns:
                  results_df["xata"] = results_df["xata"].apply(
                      lambda x: x["score"]
                  )
                  results_df.rename(
                      {"xata": TableField.DISTANCE.value},
                      axis=1,
                      inplace=True,
                  )
          except Exception as e:
              return Response(
                  resp_type=RESPONSE_TYPE.ERROR,
                  error_message=f"Unable to run similarity search: {e}",
              )
      else:
          # General get query
          try:
              params = {
                  "columns": columns if columns else [],
              }
              if filters:
                  params["filter"] = filters
              if limit or offset:
                  params["page"] = {}
                  if limit:
                      params["page"]["size"] = limit
                  if offset:
                      params["page"]["offset"] = offset
              results = self._client.data().query(table_name, params)
              # Check for errors
              if not results.is_success():
                  raise Exception(results["message"])
              # Convert result
              results_df = pd.DataFrame.from_records(results["records"])
              if "xata" in results_df.columns:
                  results_df.drop(["xata"], axis=1, inplace=True)
          except Exception as e:
              return Response(
                  resp_type=RESPONSE_TYPE.ERROR,
                  error_message=f"Unable to run general SELECT query : {e}",
              )
      return Response(
          resp_type=RESPONSE_TYPE.TABLE, data_frame=results_df
      )
  
imports: from collections import OrderedDict
  from typing import List, Optional
  import pandas
  import json
  import xata
  from xata.helpers import BulkProcessor
  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 HandlerResponse
  from mindsdb.integrations.libs.response import HandlerStatusResponse
  from mindsdb.integrations.libs.vectordatabase_handler import FilterCondition, FilterOperator, TableField, VectorStoreHandler
  from mindsdb.utilities import log
label_desc: Use image node_id 14 for calling the XataHandler obj's underlying member method code with example usage: obj.select(table_name, columns, conditions, offset, limit) and returns: Response, Response, Response