@@ -2009,7 +2009,7 @@ def __init__(self, data, attributes):
20092009
20102010 def _open_file (self , col_indices = None ):
20112011 """col_indices is only taken into account if self.data is a Path"""
2012- ipc = sys . modules [ ' pyarrow.ipc' ]
2012+ import pyarrow .ipc as ipc
20132013 if isinstance (self .data , Path ):
20142014 if col_indices is not None :
20152015 options = ipc .IpcReadOptions (included_fields = col_indices )
@@ -3514,6 +3514,14 @@ def dispatch_parquet_path_adapter(fpath):
35143514# modules are tried in the order they are defined
35153515def dispatch_file_suffix_by_available_module (suffix , module_dict : dict ):
35163516 for module_name , adapter_cls in module_dict .items ():
3517+ # We need this special case because find_spec can only safely check the
3518+ # presence of top level modules. For submodules, it actually imports
3519+ # the parent module and only then checks for the submodule, which
3520+ # breaks if the parent module is not available.
3521+ if '.' in module_name :
3522+ top_module = module_name .split ('.' )[0 ]
3523+ if importlib .util .find_spec (top_module ) is None :
3524+ continue
35173525 if importlib .util .find_spec (module_name ) is not None :
35183526 return adapter_cls
35193527 module_names = ', ' .join (module_dict .keys ())
0 commit comments