andersbogsnes commented on code in PR #2221:
URL: https://github.com/apache/iceberg-python/pull/2221#discussion_r2216939785


##########
pyiceberg/transforms.py:
##########
@@ -106,6 +109,17 @@
 TRUNCATE_PARSER = ParseNumberFromBrackets(TRUNCATE)
 
 
+def _try_import(module_name: str, extras_name: str | None = None) -> 
types.ModuleType:

Review Comment:
   Yeah, I couldn't immediately find a spot for it - I saw some other uses of 
an import check in tables which could potentially also use the function. 
   
   Could potentially go in `utils/optional_deps.py` or something similar? Given 
the number of optional dependencies, I'm sure there are other areas that could 
use a helper like this
   
   Pandas has it under `compat/_optional.py` for reference: 
https://github.com/pandas-dev/pandas/blob/main/pandas/compat/_optional.py



##########
pyiceberg/transforms.py:
##########
@@ -382,8 +396,7 @@ def __repr__(self) -> str:
         return f"BucketTransform(num_buckets={self._num_buckets})"
 
     def pyarrow_transform(self, source: IcebergType) -> "Callable[[pa.Array], 
pa.Array]":
-        from pyiceberg_core import transform as pyiceberg_core_transform
-
+        pyiceberg_core_transform = _try_import("pyiceberg_core", 
extras_name="pyiceberg_core").transform

Review Comment:
   Changed 👍 



-- 
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]

Reply via email to