We have two approaches to selecting and filtering data from spark data frame df. First:
df = df.filter("filter definition").select('col1', 'col2', 'col3')
and second:
df = df.select('col1', 'col2', 'col3').filter("filter definition")
Suppose we want call the action of count after that.
Which one is more performant if we can change the place of filter and select in spark (I mean in definition of the filter we use from the selected columns and not more)? Why? Is there any difference to the filter and select swapping for different actions or not?


