The col("name")
gives you a column expression. If you want to extract data from column “name” just do the same thing without col("name")
:
val names = test.filter(test("id").equalTo("200"))
.select("name")
.collectAsList() // returns a List[Row]
Then for a row you could get name in String by:
val name = row.getString(0)