So here is my code block
val cols = df.columns
val w = cols(0)
val query1 = s"select $cols(0), square(age) as age, age as age2, first_name, last_name from test"
val query2 = s"select $w, square(age) as age, age as age2, first_name, last_name from test"
Query 2 works just fine, query 1 throws the following error
no viable alternative at input 'select ['(line 1, pos 7)
== SQL ==
select [Ljava.lang.String;@7988d54(0), square(age) as age, age as age2, first_name, last_name from test
Is there anyway to accomplish query1 without creating a temp variable? I want to acces the indexed cols datatype directly.