text: from weaverbird.backends.sql_translator.steps.utils.query_transformation import (
      apply_condition,
      build_selection_query,
  )
  from weaverbird.backends.sql_translator.types import (
      SQLPipelineTranslator,
      SQLQuery,
      SQLQueryDescriber,
      SQLQueryExecutor,
      SQLQueryRetriever,
  )
  from weaverbird.pipeline.steps import FilterStep
  
  
  def translate_filter(
      step: FilterStep,
      query: SQLQuery,
      index: int,
      sql_query_retriever: SQLQueryRetriever = None,
      sql_query_describer: SQLQueryDescriber = None,
      sql_query_executor: SQLQueryExecutor = None,
      sql_translate_pipeline: SQLPipelineTranslator = None,
      subcall_from_other_pipeline_count: int = None,
  ) -> SQLQuery:
      query_name = f'FILTER_STEP_{index}'
  
      completed_fields = query.metadata_manager.retrieve_query_metadata_columns_as_str(
          columns_filter=[]
      )
  
      new_query = SQLQuery(
          query_name=query_name,
          transformed_query=f"""{query.transformed_query}, {query_name} AS ({
          apply_condition(
              step.condition,
              f'''SELECT {completed_fields} FROM {query.query_name} WHERE ''')})""",
          selection_query=build_selection_query(
              query.metadata_manager.retrieve_query_metadata_columns(), query_name
          ),
          metadata_manager=query.metadata_manager,
      )
      return new_query
  