Yicong-Huang commented on code in PR #58900: URL: https://github.com/apache/spark/pull/58900#discussion_r4064268774
########## 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: Thanks @Spenserrrr I had some debates in my mind and I think you are right. I was hoping to get rid of some type ignores and string based type annotations, and wished to have arrow imported once for all arrow eval types so that it can be bundled with registration: if we have arrow, arrow eval type handlers will be registered, if not, arrow eval types handlers will not exist. I do think that might be better in the long run. However, as you mentioned, currently when arrow is missing, we have a regression on its error message and "unknown eval type" would be more confusing than something like "arrow does not exist". As a result, I decided to revert the above changes and defer to later. if you have better ways to support the long term goal without compromising on the error cases, please feel free to improve with new 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]
