Пожалуйста, проверьте ниже код.
В спарк вы можете получить доступ к столбцам без имени схемы.
scala> val value = Array("id","sd","cd")
value: Array[String] = Array(id, sd, cd)
scala> val cols_list = Array("cd","id","tm","no","in","ts","nm")
cols_list: Array[String] = Array(cd, id, tm, no, in, ts, nm)
scala> val columns = value ++ cols_list.diff(value)
columns: Array[String] = Array(id, sd, cd, tm, no, in, ts, nm)
scala> val schema = "abcd"
schema: String = abcd
scala> columns.map(column => s"${schema}.${column}") // This step is not required, in spark you can access columns without schema name. if you still want you can use like this.
res14: Array[String] = Array(abcd.id, abcd.sd, abcd.cd, abcd.tm, abcd.no, abcd.in, abcd.ts, abcd.nm)
scala> df.select(columns.head,columns.tail:_*).where($"status" === "ALERT")