I am new to spark and was looking for an option to clear the cache completely. On digging more i found that i have two options
SparkInstance.catalog().clearCache(); // removes all the tables from the in-memory cache
where as on the other hand i can also do
persistentRDDs.forEach((k,v) -> {
v.unpersist(); // will unpersist all the RDD's
});
Now what i am trying to find and understand is which one would be a better option and why? I believe unpersisting RDD's will also remove all the data from memory that catalog() contains. Please correct me if i am wrong