You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/07/18 20:54:24 UTC
[GitHub] [spark] xinrong-meng commented on a diff in pull request #37219: [WIP][SPARK-39794][PYTHON] Introduce parametric singleton for DataType
xinrong-meng commented on code in PR #37219:
URL: https://github.com/apache/spark/pull/37219#discussion_r923851884
##########
python/pyspark/sql/types.py:
##########
@@ -136,14 +136,15 @@ def fromInternal(self, obj: Any) -> Any:
class DataTypeSingleton(type):
"""Metaclass for DataType"""
- _instances: ClassVar[Dict[Type["DataTypeSingleton"], "DataTypeSingleton"]] = {}
+ _instances: ClassVar[Dict[Tuple, "DataTypeSingleton"]] = {}
- def __call__(cls: Type[T]) -> T: # type: ignore[override]
- if cls not in cls._instances: # type: ignore[attr-defined]
- cls._instances[cls] = super( # type: ignore[misc, attr-defined]
+ def __call__(cls: Type[T], *args: Any, **kwargs: Any) -> T: # type: ignore[override]
+ key = (cls, args, str(kwargs))
Review Comment:
Strict matching of arguments is expected to reuse the same instance.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org