I have a pyspark dataframe where I want to add a new lit column, like this
my_dataframe.select(col("col1"), lit("this is data").alias("col2"))
By default, when I write this to BigQuery, the lit column type is string (good), but the mode is required (bad). How can I write a lit column and make BigQuery think it is nullable? My workaround is below - looking for a cleaner approach.
my_dataframe.select(col("col1"), when(lit(1) == 1, lit("this is data")).alias("col2"))