我試圖從Hive表中檢索列的列表並將結果存儲在spark數據框中。對Spark數據框/ Hive結果集進行排序
var my_column_list = hiveContext.sql(s""" SHOW COLUMNS IN $my_hive_table""")
但我無法按字母順序排序數據幀甚至顯示列查詢的結果。我嘗試使用sort和orderBy()。
如何按字母順序排列結果?
更新:加入我的代碼示例
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""")
//WARN LazyStruct: Extra bytes detected at the end of the row! Ignoring similar problems
lv_column_list.show //Works fine
lv_column_list.orderBy("result").show //Error arises
這裏排序不是問題,它與'show columns'命令的結果有關。 – cheseaux