code: def calc_custom_reward(df, custom_reward_expression: str):
      sqlCtx = get_spark_session()
      # create a temporary table for running sql
      temp_table_name = "_tmp_calc_reward_df"
      temp_reward_name = "_tmp_reward_col"
      df.createOrReplaceTempView(temp_table_name)
      df = sqlCtx.sql(
          f"SELECT *, CAST(COALESCE({custom_reward_expression}, 0) AS FLOAT)"
          f" as {temp_reward_name} FROM {temp_table_name}"
      )
      return df.drop("reward").withColumnRenamed(
          temp_reward_name, "reward"
      )
  
imports: import logging
  from typing import List, Optional, Tuple
  from pyspark.sql.functions import col, crc32, explode, map_keys, udf
  from pyspark.sql.types import ArrayType, BooleanType, FloatType, LongType, MapType, StructField, StructType
  from reagent.data.data_fetcher import DataFetcher
  from reagent.data.spark_utils import get_spark_session, get_table_url
  from reagent.workflow.types import Dataset, TableSpec
label_desc: Use image node_id 1 for calling a global function with example usage: calc_custom_reward(df, custom_reward_expression) and returns: df