code: def week_end_date(col: Column, week_end_day: str = "Sat") -> Column:
      """Return a date column for the end of week for a given day.
  
      The Spark function `dayofweek` considers Sunday as the first day of the week, and
      uses the default value of 1 to indicate Sunday. Usage of the `when` and `otherwise`
      functions allow a comparison between the end of week day indicated and the day
      of week computed, and the return of the reference date if they match or the the
      addition of one week to the reference date otherwise.
  
      :param col: The reference date column.
      :type col: Column
      :param week_end_day: The week end day (default: 'Sat')
      :type week_end_day: str
      :return: A Column of end of the week dates.
      :rtype: Column
      """
      _raise_if_invalid_day(week_end_day)
      # these are the default Spark mappings.  Spark considers Sunday the first day of the week.
      day_of_week_mapping = {
          "Sun": 1,
          "Mon": 2,
          "Tue": 3,
          "Wed": 4,
          "Thu": 5,
          "Fri": 6,
          "Sat": 7,
      }
      return F.when(
          F.dayofweek(col).eqNullSafe(
              F.lit(day_of_week_mapping[week_end_day])
          ),
          col,
      ).otherwise(F.next_day(col, week_end_day))
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING
  import re
  import uuid
  from typing import Any
  import pyspark.sql.functions
  from pyspark.sql.types import ArrayType, BooleanType, StringType
label_desc: Use image node_id 9 for calling a global function with example usage: week_end_date(col, week_end_day) and returns: F