snowman2 opened a new issue, #2018:
URL: https://github.com/apache/iceberg-python/issues/2018

   ### Feature Request / Improvement
   
   Related #2008
   
   I have a custom credential refreshing process using `RefreshableCredentials` 
that is helpful for long running processes.  I would like to connect it with 
pyiceberg in a seamless way.
   
   Option 1 Add support to pass `session` to `S3FileSystem`:
   Once way to pass this process though is by way of the `session` parameter of 
[S3FileSystem](https://s3fs.readthedocs.io/en/latest/api.html#s3fs.core.S3FileSystem).
 However, that is presently not supported.
   
   catalog = load_catalog(
       "default",
       **{
           'type': 'sql',
           "uri": f"sqlite:///{warehouse_path}/pyiceberg_catalog.db",
           "warehouse": f"custom://{warehouse_path}",
           "py-io-impl": "pyiceberg.io.fsspec.FsspecFileIO",
           "botocore_session": my_botocore_session,
       },
   )
   
   
   Option 2: Hack `pyiceberg`
   
   Presently, a workaround is to add custom `AbstractFileSystem` implementation 
to `SCHEME_TO_FS ` 
https://github.com/apache/iceberg-python/blob/da88b8dcdb69af8e66e4a9a6eea8c9f1408bbf14/pyiceberg/io/fsspec.py#L223.
   
   ```python
   import pyiceberg.io.fsspec
   from custom_package import CustomFileSystem
   from fsspec import AbstractFileSystem
   from pyiceberg.typedef import Properties
   
   def _custom_file_system(_: Properties) -> AbstractFileSystem:
       return CustomFileSystem()
       
   pyiceberg.io.fsspec.SCHEME_TO_FS["custom"] = _custom_file_system
   ```
   
   Option 3: Add support for [custom fsspec 
backends](https://filesystem-spec.readthedocs.io/en/latest/developer.html#implementing-a-backend)
 to pyiceberg
   
   If you follow the `pandas` method of passing on `storage_options` to their 
methods 
[examples](https://pandas.pydata.org/pandas-docs/stable/search.html?q=storage_options):
   
   ```python
   catalog = load_catalog(
       "default",
       **{
           'type': 'sql',
           "uri": f"sqlite:///{warehouse_path}/pyiceberg_catalog.db",
           "warehouse": f"custom://{warehouse_path}",
           "py-io-impl": "pyiceberg.io.fsspec.FsspecFileIO",
           "storage_options": {"my_param": 1}
       },
   )
   ```
   
   Code in `fsspec.py`:
   
   ```python
   from functools import partial
   
   import pyiceberg.io.fsspec
   from fsspec import AbstractFileSystem
   from fsspec.registry import known_implementations, get_filesystem_class
   from pyiceberg.typedef import Properties
   
   
   def _generic_fsspec_implementation_handler(properties: Properties, scheme: 
str) -> AbstractFileSystem:
       storage_optons = properties.get("storage_options")
       if not storage_options:
           storage_options = {}
       return  get_filesystem_class(scheme)(**storage_options)
   
   for scheme in known_implementations:
       if scheme in pyiceberg.io.fsspec.SCHEME_TO_FS:
           continue
       pyiceberg.io.fsspec.SCHEME_TO_FS[scheme] = 
partial(_generic_fsspec_implementation_handler, scheme=scheme)
   ```
   
   
   If option 1 or option 3 sound like something you would like to add to your 
project, please let me know.
   
   
   
   
   
   


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