If you use the latest version Spark 1.3, you can use the DataFrame API like
val results = sqlContext.sql("SELECT name FROM people") results.select("name").show() 2015-03-22 15:40 GMT+08:00 amghost <zhengweita...@gmail.com>: > I would like to retrieve column value from Spark SQL query result. But > currently it seems that Spark SQL only support retrieving by index > > > val results = sqlContext.sql("SELECT name FROM people") > results.map(t => "Name: " + *t(0)*).collect().foreach(println) > > I think it will be much more convenient if I could do something like this: > > results.map(t => "Name: " + *t("name")*).collect().foreach(println) > > How do you like? > > > > -- > View this message in context: > http://apache-spark-user-list.1001560.n3.nabble.com/Should-Spark-SQL-support-retrieve-column-value-from-Row-by-column-name-tp22174.html > Sent from the Apache Spark User List mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@spark.apache.org > For additional commands, e-mail: user-h...@spark.apache.org > >