import org.apache.spark.sql.Column

val primaryP = List("t01", "t03", "t11", "t1801", "t1803")
val workP = List("t05", "t1805")
val otherP = List("t02", "t04", "t06", "t07", "t08", "t09", "t10", "t12", "r13", "t14", "t15", "t16", "t18")

val columnNames = List("t03", "t01ddd", "t1803", "t18", "t05", "tnull", "blah blad", "t1515151515")

// x.startwWith(y) means do any in x start with y
val pp = columnNames.map(t => if (primaryP.exists(t.startsWith)) new Column(t) else Nil).filter(p => !p.equals(Nil))
val wp = columnNames.map(t => if (workP.exists(t.startsWith)) new Column(t) else Nil).filter(p => !p.equals(Nil))
val op = columnNames.map(t => if (otherP.exists(t.startsWith)) new Column(t)
            else Nil).filter(p => !p.equals(Nil)).filter(p => !pp.contains(p) && !wp.contains(p))
(pp,  wp,  op )