Github user MLnick commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13780#discussion_r67833027
  
    --- Diff: python/pyspark/sql/dataframe.py ---
    @@ -376,24 +376,47 @@ def foreachPartition(self, f):
     
         @since(1.3)
         def cache(self):
    -        """ Persists with the default storage level (C{MEMORY_ONLY}).
    +        """Persists the :class:`DataFrame` with the default storage level 
(C{MEMORY_AND_DISK}).
    +
    +        .. note:: the default storage level has changed to 
C{MEMORY_AND_DISK} to match Scala in 2.0.
             """
             self.is_cached = True
             self._jdf.cache()
             return self
     
         @since(1.3)
    -    def persist(self, storageLevel=StorageLevel.MEMORY_ONLY):
    -        """Sets the storage level to persist its values across operations
    -        after the first time it is computed. This can only be used to 
assign
    -        a new storage level if the RDD does not have a storage level set 
yet.
    -        If no storage level is specified defaults to (C{MEMORY_ONLY}).
    +    def persist(self, storageLevel=StorageLevel.MEMORY_AND_DISK):
    --- End diff --
    
    @rxin I updated the default here in `persist`, to match `cache`.
    
    But actually, it's still not quite correct - the default storage levels for 
Python are all serialized. But the MEMORY-based ones don't match the Scala side 
(which are deserialized). This was done for RDDs but doesn't quite work for 
DataFrames (since DF on the Scala side is cached deserialized by default).
    
    So here `df.cache()` results in `MEMORY_AND_DISK (deser)` while 
`df.persist()` results in `MEMORY_AND_DISK (ser)`. Ideally I'd say we don't 
want to encourage users to accidentally use the serialized forms for DF caching 
(since it is less efficient, as I understand it?). Let me know what you think


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to