File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -225,6 +225,10 @@ class DuckDBAttachOptions(BaseConfig):
225225 encrypted : bool = False
226226 data_inlining_row_limit : t .Optional [int ] = None
227227
228+ # Azure specific options
229+ azure_account_name : t .Optional [str ] = None
230+ azure_account_host : t .Optional [str ] = None
231+
228232 def to_sql (self , alias : str ) -> str :
229233 options = []
230234 # 'duckdb' is actually not a supported type, but we'd like to allow it for
@@ -379,6 +383,24 @@ def init(cursor: duckdb.DuckDBPyConnection) -> None:
379383 try :
380384 if isinstance (path_options , DuckDBAttachOptions ):
381385 query = path_options .to_sql (alias )
386+
387+ if path_options .data_path .split (":" )[0 ] == "abfs" :
388+
389+ if path_options .azure_account_name is None or path_options .azure_account_host is None :
390+ raise ValueError ("azure_account_name and azure_account_host must be set when using abfs protocol" )
391+
392+
393+ storage_options = {
394+ "account_name" : path_options .azure_account_name ,
395+ "account_host" : path_options .azure_account_host ,
396+ "anon" :False ,
397+ }
398+ from fsspec import filesystem
399+
400+ fs = filesystem ("abfs" , ** storage_options )
401+ cursor .register_filesystem (fs )
402+ cursor .commit ()
403+
382404 else :
383405 query = f"ATTACH IF NOT EXISTS '{ path_options } '"
384406 if not path_options .startswith ("md:" ):
You can’t perform that action at this time.
0 commit comments