File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -228,6 +228,10 @@ class DuckDBAttachOptions(BaseConfig):
228228 encrypted : bool = False
229229 data_inlining_row_limit : t .Optional [int ] = None
230230
231+ # Azure specific options
232+ azure_account_name : t .Optional [str ] = None
233+ azure_account_host : t .Optional [str ] = None
234+
231235 def to_sql (self , alias : str ) -> str :
232236 options = []
233237 # 'duckdb' is actually not a supported type, but we'd like to allow it for
@@ -382,6 +386,24 @@ def init(cursor: duckdb.DuckDBPyConnection) -> None:
382386 try :
383387 if isinstance (path_options , DuckDBAttachOptions ):
384388 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+
385407 else :
386408 query = f"ATTACH IF NOT EXISTS '{ path_options } '"
387409 if not path_options .startswith ("md:" ):
You can’t perform that action at this time.
0 commit comments