相关疑难解决方法(0)

Spark 2.0 Dataset vs DataFrame

从spark 2.0.1开始我有一些问题.我阅读了很多文档,但到目前为止找不到足够的答案:

  • 有什么区别
    • df.select("foo")
    • df.select($"foo")
  • 我能正确理解吗
    • myDataSet.map(foo.someVal)是类型安全的,不会转换为RDD但保留在DataSet表示/没有额外的开销(2.0.0的性能明智)
  • 所有其他命令,例如select,..只是语法糖.它们不是类型安全的,可以使用地图代替.如果df.select("foo")没有地图声明,我怎么能输入?
    • 为什么我应该使用UDF/UADF而不是地图(假设地图保留在数据集表示中)?

scala apache-spark apache-spark-sql apache-spark-dataset apache-spark-2.0

23
推荐指数
1
解决办法
4687
查看次数

为什么谓词下推没有在类型化数据集API中使用(与非类型化数据框架API相比)?

我一直认为数据集/数据帧API是相同的......唯一的区别是数据集API将为您提供编译时安全性.对 ?

那么......我的案子非常简单:

 case class Player (playerID: String, birthYear: Int)

 val playersDs: Dataset[Player] = session.read
  .option("header", "true")
  .option("delimiter", ",")
  .option("inferSchema", "true")
  .csv(PeopleCsv)
  .as[Player]

 // Let's try to find players born in 1999. 
 // This will work, you have compile time safety... but it will not use predicate pushdown!!!
 playersDs.filter(_.birthYear == 1999).explain()

 // This will work as expected and use predicate pushdown!!!
 // But you can't have compile time safety with this :(
 playersDs.filter('birthYear === 1999).explain()
Run Code Online (Sandbox Code Playgroud)

从第一个示例解释将显示它不执行谓词下推(注意空PushedFilters):

== Physical Plan == …
Run Code Online (Sandbox Code Playgroud)

dataframe apache-spark apache-spark-sql apache-spark-dataset

9
推荐指数
1
解决办法
1643
查看次数