在Spark DataFrame中获取特定记录的最快方法

时间:2017-02-22 10:51:38

标签: scala apache-spark dataframe hive

我想在Spark 1.6 DataFrame中收集一个特定的Row,它来自一个分区的HiveTable(该表由一个名为date的String列分区并保存为Parquet

记录由datesectionsample

明确标识

另外,我有以下约束

  • datesection是字符串,sample是长

  • date是唯一的,Hive表由date分区。但 每个date

  • 在HDFS上可能有多个文件
  • section在数据框架中也是唯一的
  • sample对于给定的section
  • 是唯一的

到目前为止,我使用此查询,但执行需要相当长的时间(使用10个执行程序约25秒):

sqlContext.table("mytable")
.where($"date"=== date)
.where($"section"=== section)
.where($"sample" === sample)
.collect()(0)

我还尝试将collect()(0)替换为take(1)(0)而不是更快。

0 个答案:

没有答案
相关问题