Hi I am trying to do a scdtype2 update in dataframe having 280 columns.
val newYRecs = stgDF.columns
.foldLeft(joinedDF)
{(tempDF,colName) =>
tempDF.withColumn("new_" + colName, when(col("stg." + colName).isNull, col("tgt."+ colName)).otherwise(col("stg." + colName))).drop(col("stg." + colName)).drop(col("tgt." + colName)).withColumnRenamed("new_" + colName,colName)
This is taking 8 minutes alone to execute. Is there any way this can be optimized?