Skip to content

Commit 2cec51c

Browse files
committed
add registration of abfs file system
1 parent 8afbaf1 commit 2cec51c

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

sqlmesh/core/config/connection.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff 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:"):

0 commit comments

Comments
 (0)