def generate_wrapped_sql_function_body(
    primary_func: Callable[..., Any],
    functions: list[Callable[..., Any]],
    catalog: str,
    schema: str,
    replace: bool = False,
    dependencies: Optional[list[str]] = None,
    environment_version: str = "None",
) -> str:
    """
    Generate SQL body for creating the function in Unity Catalog.

    Args:
        primary_func: The primary Python callable function to convert into a UDF.
        functions: List of additional functions to be wrapped.
        catalog: The catalog name.
        schema: The schema name.
        replace: Whether to include the 'OR REPLACE' clause.
        dependencies: An optional list of PyPI dependencies for the function to utilize in the execution environment
        environment_version: The version of the environment to use for the function. Defaults to "None".

    Returns:
        SQL statement for creating the UDF.
    """

    wrapped_function_content = extract_wrapped_functions(functions)

    primary_metadata = extract_function_metadata(primary_func)

    # Update the primary function's body with the wrapped functions in-lined into the top of the body
    primary_metadata.function_body = (
        wrapped_function_content + "\n" + primary_metadata.function_body
    )

    sql_metadata = create_sql_metadata(primary_metadata)

    sql_body = assemble_sql_body(
        catalog,
        schema,
        primary_metadata.func_name,
        sql_metadata.sql_params,
        primary_metadata.sql_return_type,
        sql_metadata.func_comment,
        sql_metadata.indented_body,
        replace,
        dependencies,
        environment_version,
    )

    return sql_body

    Generate SQL body for creating the function in Unity Catalog.

    Args:
        primary_func: The primary Python callable function to convert into a UDF.
        functions: List of additional functions to be wrapped.
        catalog: The catalog name.
        schema: The schema name.
        replace: Whether to include the 'OR REPLACE' clause.
        dependencies: An optional list of PyPI dependencies for the function to utilize in the execution environment
        environment_version: The version of the environment to use for the function. Defaults to "None".

    Returns:
        SQL statement for creating the UDF.
    
ai/core/src/unitycatalog/ai/core/utils/callable_utils.py