original_docstring: 
      Recursively build the list of all common table expressions that are needed to generate the sql for
      the given model
      :param dialect: SQL Dialect
      :param compiler_cache: Dictionary mapping model hashes to already compiled results
      :param model: model to convert to a list of SemiCompiledTuple
      :return:
      
docstring: Recursively build the list of all common table expressions that are needed to generate the sql for
  the given model
docstring_tokens: Recursively build the list of all common table expressions that are needed to generate the sql for the given model
code: def _to_cte_sql(dialect: Dialect,
                  compiler_cache: Dict[str, List[SemiCompiledTuple]],
                  model: SqlModel
                  ) -> List[SemiCompiledTuple]:
      """
      Recursively build the list of all common table expressions that are needed to generate the sql for
      the given model
      :param dialect: SQL Dialect
      :param compiler_cache: Dictionary mapping model hashes to already compiled results
      :param model: model to convert to a list of SemiCompiledTuple
      :return:
      """
      if model.hash in compiler_cache:
          return compiler_cache[model.hash]
  
      # First recursively compile all CTEs that we depend on
      result = []
      reference_names = {
          name: model_to_quoted_name(dialect=dialect, model=reference)
          for name, reference in model.references.items()
      }
      for ref_name, reference in model.references.items():
          if reference.materialization.is_cte:
              result.extend(_to_cte_sql(dialect=dialect, compiler_cache=compiler_cache, model=reference))
  
      # Compile the actual model
      result.extend(
          _single_model_to_sql(
              dialect=dialect,
              compiler_cache=compiler_cache,
              model=model,
              reference_names=reference_names
          )
      )
  
      compiler_cache[model.hash] = result
      return result
code_tokens: def _to_cte_sql ( dialect : Dialect , compiler_cache : Dict [ str , List [ SemiCompiledTuple ] ] , model : SqlModel ) -> List [ SemiCompiledTuple ] : if model . hash in compiler_cache : return compiler_cache [ model . hash ] result = [ ] reference_names = { name : model_to_quoted_name ( dialect = dialect , model = reference ) for name , reference in model . references . items ( ) } for ref_name , reference in model . references . items ( ) : if reference . materialization . is_cte : result . extend ( _to_cte_sql ( dialect = dialect , compiler_cache = compiler_cache , model = reference ) ) result . extend ( _single_model_to_sql ( dialect = dialect , compiler_cache = compiler_cache , model = model , reference_names = reference_names ) ) compiler_cache [ model . hash ] = result return result
short_docstring: Recursively build the list of all common table expressions that are needed to generate the sql for
  the given model
short_docstring_tokens: Recursively build the list of all common table expressions that are needed to generate the sql for the given model
comment: """
      Recursively build the list of all common table expressions that are needed to generate the sql for
      the given model
      :param dialect: SQL Dialect
      :param compiler_cache: Dictionary mapping model hashes to already compiled results
      :param model: model to convert to a list of SemiCompiledTuple
      :return:
      """$SEP$# First recursively compile all CTEs that we depend on$SEP$# Compile the actual model