code: def flatten_map(
      df: DataFrame, col_name: str, separator: str = ":"
  ) -> DataFrame:
      """Flattens the specified MapType 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 MapType 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 MapType column.
      :rtype: DataFrame
      """
      keys_df = df.select(
          F.explode_outer(F.map_keys(F.col(f"`{col_name}`")))
      ).distinct()
      keys = [row[0] for row in keys_df.collect()]
      key_cols = [
          F.col(f"`{col_name}`")
          .getItem(k)
          .alias(col_name + separator + k)
          for k in keys
      ]
      return df.select(
          [F.col(f"`{col}`") for col in df.columns if col != col_name]
          + key_cols,
      )
  
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 7 for calling a global function with example usage: flatten_map(df, col_name, separator) and returns: df