Yicong-Huang commented on code in PR #58900: URL: https://github.com/apache/spark/pull/58900#discussion_r4067172443
########## python/pyspark/eval_handlers/__init__.py: ########## @@ -22,7 +22,18 @@ Each eval type handled here is an ``EvalTypeHandler`` subclass (in ``_base``) that declares its ``eval_type`` and self-registers at class definition, which ``read_udfs`` looks up via ``get_eval_type_handler``. Importing this package -imports the concrete handler submodules (``_arrow``) so they register. +imports the concrete handler submodules so they register. + +``_arrow`` requires pyarrow and imports it at module top, so it is only imported +when pyarrow is available; the Arrow eval types it serves cannot run without it. """ -from pyspark.eval_handlers import _arrow # noqa: F401 # registers handlers on import +try: + from pyspark.sql.pandas.utils import require_minimum_pyarrow_version + + require_minimum_pyarrow_version() +except Exception: Review Comment: I currently don't have a good idea about how we can achieve lazy evaluation of handlers and user friendly error message at the same time, in an elegant way. I think registering a handler successfully and failed later on pyarrow is not available is not ideal either: it's better to fail early, at registration. If you have a good solution feel free to raise a PR! -- 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]
