code: def upload_as_parquet(df) -> Dataset:
      """Generate a random parquet. Fails if cannot generate a non-existent name."""
  
      # get a random tmp name and check if it exists
      sqlCtx = get_spark_session()
      success = False
      for _ in range(MAX_UPLOAD_PARQUET_TRIES):
          suffix = rand_string(length=UPLOAD_PARQUET_TMP_SUFFIX_LEN)
          rand_name = f"tmp_parquet_{suffix}"
          if not sqlCtx.catalog._jcatalog.tableExists(rand_name):
              success = True
              break
      if not success:
          raise Exception(
              f"Failed to find name after {MAX_UPLOAD_PARQUET_TRIES} tries."
          )
  
      # perform the write
      # pyre-fixme[61]: `rand_name` may not be initialized here.
      df.write.mode("errorifexists").format("parquet").saveAsTable(
          rand_name
      )
      # pyre-fixme[61]: `rand_name` may not be initialized here.
      parquet_url = get_table_url(rand_name)
      logger.info(f"Saved parquet to {parquet_url}")
      return Dataset(parquet_url=parquet_url)
  
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 20 for calling a global function with example usage: upload_as_parquet(df) and returns: Dataset