HyukjinKwon commented on code in PR #36161:
URL: https://github.com/apache/spark/pull/36161#discussion_r850198367
##########
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:
Yeah, that's fine. You can just make the doctests skipped with ` # doctest:
+SKIP`. I worry if we introduce another bug by mimicking this class property vs
the standard implementation in Python 3.9. e.g.) we should check how it works
if somebody manually sets an attribute here.
--
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]