code: def with_columns_renamed(
      fun: Callable[[str], str]
  ) -> Callable[[DataFrame], DataFrame]:
      """Ffunction designed to rename the columns of a `Spark DataFrame`.
  
      It takes a `Callable[[str], str]` object as an argument (``fun``) and returns a
      `Callable[[DataFrame], DataFrame]` object.
  
      When `_()` is called on a `DataFrame`, it creates a list of column names,
      applying the argument `fun()` to each of them, and returning a new `DataFrame`
      with the new column names.
  
      :param fun: Renaming function
      :returns: Function which takes DataFrame as parameter.
      """
  
      def _(df: DataFrame) -> DataFrame:
          cols = [
              F.col(f"`{col_name}`").alias(fun(col_name))
              for col_name in df.columns
          ]
          return df.select(*cols)
  
      return _
  
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 1 for calling a global function with example usage: with_columns_renamed(fun) and returns: _, df