class_docstr: This handler handles connection and execution of the Pinecone statements.
class_docstr_tok: ["This","handler","handles","connection","and","execution","of","the","Pinecone","statements","."]
docstr: Translate a list of FilterCondition objects a dict that can be used by pinecone.
  E.g.,
  [
      FilterCondition(
          column="metadata.created_at",
          op=FilterOperator.LESS_THAN,
          value="2020-01-01",
      ),
      FilterCondition(
          column="metadata.created_at",
          op=FilterOperator.GREATER_THAN,
          value="2019-01-01",
      )
  ]
  -->
  {
      "$and": [
          {"created_at": {"$lt": "2020-01-01"}},
          {"created_at": {"$gt": "2019-01-01"}}
      ]
  }
docstr_tok: ["Translate","a","list","of","FilterCondition","objects","a","dict","that","can","be","used","by","pinecone",".","E.g.",",","[","FilterCondition","(","column=","''","metadata.created_at","''",",","op=FilterOperator.LESS_THAN",",","value=","''","2020-01-01","''",",",")",",","FilterCondition","(","column=","''","metadata.created_at","''",",","op=FilterOperator.GREATER_THAN",",","value=","''","2019-01-01","''",",",")","]","--",">","{","``","$","and","''",":","[","{","``","created_at","''",":","{","``","$","lt","''",":","``","2020-01-01","''","}","}",",","{","``","created_at","''",":","{","``","$","gt","''",":","``","2019-01-01","''","}","}","]","}"]
code: def _translate_metadata_condition(
      self, conditions: List[FilterCondition]
  ) -> Optional[dict]:
      """
      Translate a list of FilterCondition objects a dict that can be used by pinecone.
      E.g.,
      [
          FilterCondition(
              column="metadata.created_at",
              op=FilterOperator.LESS_THAN,
              value="2020-01-01",
          ),
          FilterCondition(
              column="metadata.created_at",
              op=FilterOperator.GREATER_THAN,
              value="2019-01-01",
          )
      ]
      -->
      {
          "$and": [
              {"created_at": {"$lt": "2020-01-01"}},
              {"created_at": {"$gt": "2019-01-01"}}
          ]
      }
      """
      # we ignore all non-metadata conditions
      if conditions is None:
          return None
      metadata_conditions = [
          condition
          for condition in conditions
          if condition.column.startswith(TableField.METADATA.value)
      ]
      if len(metadata_conditions) == 0:
          return None
  
      # we translate each metadata condition into a dict
      pinecone_conditions = []
      for condition in metadata_conditions:
          metadata_key = condition.column.split(".")[-1]
          pinecone_conditions.append(
              {
                  metadata_key: {
                      self._get_pinecone_operator(
                          condition.op
                      ): condition.value
                  }
              }
          )
  
      # we combine all metadata conditions into a single dict
      metadata_condition = (
          {"$and": pinecone_conditions}
          if len(pinecone_conditions) > 1
          else pinecone_conditions[0]
      )
      return metadata_condition
  
imports: from collections import OrderedDict
  from typing import List, Optional
  import pinecone
  import pandas
  import ast
  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 5 for calling the PineconeHandler obj's underlying member method code with example usage: obj._translate_metadata_condition(conditions) and returns: metadata_condition, None, None