Iva*_*van 8 apache-spark apache-spark-sql pyspark
使用从Hive导入的Spark数据帧,有时我最终得到了几个我不需要的列.假设我不想用它们过滤它们
df = SqlContext.sql('select cols from mytable')
Run Code Online (Sandbox Code Playgroud)
我正在导入整个表格
df = SqlContext.table(mytable)
Run Code Online (Sandbox Code Playgroud)
做select和后续cache提高性能/减少内存使用,如
df = df.select('col_1', 'col_2', 'col_3')
df.cache()
df.count()
Run Code Online (Sandbox Code Playgroud)
或者只是浪费时间?我会做很多的操作和数据操作上df,如avg,withColumn等.
IMO 提前过滤它们是有意义的:
df = SqlContext.sql('select col_1, col_2, col_3 from mytable')
Run Code Online (Sandbox Code Playgroud)
这样你就不会浪费资源...
如果你不能这样做,那么你可以像你那样做......
| 归档时间: |
|
| 查看次数: |
12076 次 |
| 最近记录: |