I am trying to get a list of columns from a Hive table and store the result in a spark data block.
var my_column_list = hiveContext.sql(s""" SHOW COLUMNS IN $my_hive_table""")
But I cannot sort the data alphabetically or even the result of querying show columns. I tried using sort and orderBy ().
How can I sort the result alphabetically?
Update: Added sample of my code
import org.apache.spark.{ SparkConf, SparkContext }
import org.apache.spark.sql.DataFrame
import org.apache.spark.sql.hive.HiveContext
val hiveContext = new HiveContext(sc)
hiveContext.sql("USE my_test_db")
var lv_column_list = hiveContext.sql(s""" SHOW COLUMNS IN MYTABLE""")
lv_column_list.show
lv_column_list.orderBy("result").show
Amber source
share