@@ -270,6 +270,7 @@ class BaseDuckDBConnectionConfig(ConnectionConfig):
270270 extensions: A list of autoloadable extensions to load.
271271 connector_config: A dictionary of configuration to pass into the duckdb connector.
272272 secrets: A list of dictionaries used to generate DuckDB secrets for authenticating with external services (e.g. S3).
273+ file_systems: A list of dictionaries used to register `fsspec` filesystems to the DuckDB cursor.
273274 concurrent_tasks: The maximum number of tasks that can use this connection concurrently.
274275 register_comments: Whether or not to register model comments with the SQL engine.
275276 pre_ping: Whether or not to pre-ping the connection before starting a new transaction to ensure it is still alive.
@@ -281,6 +282,7 @@ class BaseDuckDBConnectionConfig(ConnectionConfig):
281282 extensions : t .List [t .Union [str , t .Dict [str , t .Any ]]] = []
282283 connector_config : t .Dict [str , t .Any ] = {}
283284 secrets : t .List [t .Dict [str , t .Any ]] = []
285+ file_systems : t .List [t .Dict [str , t .Any ]] = []
284286
285287 concurrent_tasks : int = 1
286288 register_comments : bool = True
@@ -375,6 +377,15 @@ def init(cursor: duckdb.DuckDBPyConnection) -> None:
375377 except Exception as e :
376378 raise ConfigError (f"Failed to create secret: { e } " )
377379
380+ if self .file_systems :
381+ from fsspec import filesystem # type: ignore
382+
383+ for file_system in self .file_systems :
384+ protocol = file_system .pop ("protocol" )
385+ storage_options = file_system .pop ("storage_options" )
386+ fs = filesystem (protocol , ** storage_options )
387+ cursor .register_filesystem (fs )
388+
378389 for i , (alias , path_options ) in enumerate (
379390 (getattr (self , "catalogs" , None ) or {}).items ()
380391 ):
@@ -386,24 +397,6 @@ def init(cursor: duckdb.DuckDBPyConnection) -> None:
386397 try :
387398 if isinstance (path_options , DuckDBAttachOptions ):
388399 query = path_options .to_sql (alias )
389-
390- if path_options .data_path .split (":" )[0 ] == "abfs" :
391-
392- if path_options .azure_account_name is None or path_options .azure_account_host is None :
393- raise ValueError ("azure_account_name and azure_account_host must be set when using abfs protocol" )
394-
395-
396- storage_options = {
397- "account_name" : path_options .azure_account_name ,
398- "account_host" : path_options .azure_account_host ,
399- "anon" :False ,
400- }
401- from fsspec import filesystem
402-
403- fs = filesystem ("abfs" , ** storage_options )
404- cursor .register_filesystem (fs )
405- cursor .commit ()
406-
407400 else :
408401 query = f"ATTACH IF NOT EXISTS '{ path_options } '"
409402 if not path_options .startswith ("md:" ):
0 commit comments