Предположим, у нас есть DataFrame df
состоящий из следующих столбцов:
Имя, Фамилия, Размер, Ширина, Длина, Вес
Теперь мы хотим выполнить пару операций, например, мы хотим создать пару DataFrames, содержащих данные о размерах и ширине.
val df1 = df.groupBy("surname").agg( sum("size") )
val df2 = df.groupBy("surname").agg( sum("width") )
как вы можете заметить, другие столбцы, такие как длина, нигде не используются. Является ли Spark достаточно умным, чтобы отбросить лишние столбцы перед фазой перемешивания, или они переносятся? Уил работает:
val dfBasic = df.select("surname", "size", "width")
перед группировкой как-то повлияет на производительность?