我是 Apache Spark 的初学者。我在学习 Spark 时遇到了困难。据我所知,Spark 基于惰性求值工作,并且 Spark 中的数据帧是不可变的。
我有一个包含 3 列
songay_xuly
、loai_ngay
和 ma
的数据框 df。如果我变身
df = df.withColumn("day", col("songay_xuly").cast("int"))
将创建一个新的数据框,两列
songay_xuly
和ma
会指向旧的df还是会是旧数据的重复数据?
提前致谢!
期待收到任何人的答复!
将
action
方面放在一边,如果您使用 Columns 链接 3 个并且不通过 .checkpoint
进行中断沿袭,则 withColumn
将被融合,并且您将拥有不可变的旧数据帧和这个新数据帧作为沿袭。
withColumn
的性能并非最佳,因此使用select
通常会更好。请参阅https://stackoverflow.com/questions/78241781/pyspark-performance-chained-transformations-vs-successive-reassignment/78243739#78243739https://stackoverflow.com/questions/78241781/pyspark-performance-chained-transformations- vs-连续重新分配/78243739#78243739.