How to populate null values in Array with default value in Scala dataframe?

  Kiến thức lập trình

I have a dataframe which is having a array column. It contains list of values along with nulls. I want to replace the nulls with some other value.

import spark.implicits._
val columns=Array("id", "subject")
val df1=sc.parallelize(Seq(
  (1, Array("eng","math",null,null))
  
)).toDF(columns: _*)

df1.printSchema
df1.show()

LEAVE A COMMENT