code: def flatten_struct(
      df: DataFrame, col_name: str, separator: str = ":"
  ) -> DataFrame:
      """Flattens the specified StructType column in the input DataFrame and returns a new DataFrame with the flattened columns.
  
      :param df: The input PySpark DataFrame.
      :type df: DataFrame
      :param col_name: The column name of the StructType to be flattened.
      :type col_name: str
      :param separator: The separator to use in the resulting flattened column names, defaults to ':'.
      :type separator: str, optional
      :return: The DataFrame with the flattened StructType column.
      :rtype: List[Column]
      """
      struct_type = complex_fields(df.schema)[col_name]
      expanded = [
          F.col(f"`{col_name}`.`{k}`").alias(col_name + separator + k)
          for k in [n.name for n in struct_type.fields]
      ]
      return df.select("*", *expanded).drop(F.col(f"`{col_name}`"))
  
file_path: quinn/quinn/transformations.py
imports: from __future__ import annotations
  import re
  from collections.abc import Callable
  from pyspark.sql import DataFrame, SparkSession
  from pyspark.sql import functions
  from pyspark.sql.types import ArrayType, MapType, StructField, StructType
  from quinn.schema_helpers import complex_fields
label_desc: Use image node_id 6 for calling a global function with example usage: flatten_struct(df, col_name, separator) and returns: df