FurcyPin commented on code in PR #36161:
URL: https://github.com/apache/spark/pull/36161#discussion_r850157987
##########
python/pyspark/sql/session.py:
##########
@@ -276,8 +315,20 @@ def getOrCreate(self) -> "SparkSession":
).applyModifiableSettings(session._jsparkSession,
self._options)
return session
- builder = Builder()
- """A class attribute having a :class:`Builder` to construct
:class:`SparkSession` instances."""
+ # TODO: This workaround can be dropped once support for Python 3.8 is
dropped
+ # In Python 3.9, the @property decorator has been made compatible with the
@classmethod decorator.
+ # https://docs.python.org/3.9/library/functions.html#classmethod
+ if sys.version >= "3.9":
+ @classmethod
+ @property
+ def builder(cls):
+ """A class attribute having a :class:`Builder` to construct
:class:`SparkSession` instances."""
+ return cls.Builder()
+ else:
+ @classproperty
+ def builder(cls):
+ """A class attribute having a :class:`Builder` to construct
:class:`SparkSession` instances."""
+ return cls.Builder()
Review Comment:
If I do that, the doctests won't pass in Python 3.8.
Remember this is a bugfix, I'd rather have pySpark behave the same way with
every Python version.
##########
python/pyspark/sql/session.py:
##########
@@ -276,8 +315,20 @@ def getOrCreate(self) -> "SparkSession":
).applyModifiableSettings(session._jsparkSession,
self._options)
return session
- builder = Builder()
- """A class attribute having a :class:`Builder` to construct
:class:`SparkSession` instances."""
+ # TODO: This workaround can be dropped once support for Python 3.8 is
dropped
+ # In Python 3.9, the @property decorator has been made compatible with the
@classmethod decorator.
+ # https://docs.python.org/3.9/library/functions.html#classmethod
+ if sys.version >= "3.9":
Review Comment:
Sure, I'll do that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]