I've tried this code to add a row to a dataframe if df2 is empty but I get this error and I don't understand the reason. I don't have any column called value.
Exception in thread "main" java.lang.IllegalArgumentException: requirement failed: The number of columns doesn't match. Old column names (1): value New column names (2): country, code
var df1 = Seq.empty[(String,String)].toDF("country","code").
val df2 = spark.emptyDataFrame
if (df2.isEmpty) df1 = df1.union(Seq("GLOBAL" , "EMPTY").toDF("country","code"))