Spark is clearing the cached RDD after a write action is invoked on a dataframe arrived from this cache after some transformations. So any further action that could have used the cache has to recompute the RDD. However if the action is replaced by any other action like count or take the cache persists and can be used in subsequent operations.
Why does it happen?