Skip to content

Commit ea088aa

Browse files
feat(fabric): update connection configuration for Fabric adapter
1 parent 1655263 commit ea088aa

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

sqlmesh/core/config/connection.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,12 +1708,9 @@ class FabricConnectionConfig(MSSQLConnectionConfig):
17081708
DISPLAY_NAME: t.ClassVar[t.Literal["Fabric"]] = "Fabric" # type: ignore
17091709
DISPLAY_ORDER: t.ClassVar[t.Literal[17]] = 17 # type: ignore
17101710
driver: t.Literal["pyodbc"] = "pyodbc"
1711+
workspace: str
1712+
tenant: str
17111713
autocommit: t.Optional[bool] = True
1712-
workspace_id: t.Optional[str] = None
1713-
# Service Principal authentication for Fabric REST API
1714-
tenant_id: t.Optional[str] = None
1715-
client_id: t.Optional[str] = None
1716-
client_secret: t.Optional[str] = None
17171714

17181715
@property
17191716
def _engine_adapter(self) -> t.Type[EngineAdapter]:
@@ -1725,7 +1722,7 @@ def _engine_adapter(self) -> t.Type[EngineAdapter]:
17251722
def _extra_engine_config(self) -> t.Dict[str, t.Any]:
17261723
return {
17271724
"database": self.database,
1728-
"catalog_support": CatalogSupport.REQUIRES_SET_CATALOG,
1725+
"catalog_support": CatalogSupport.FULL_SUPPORT,
17291726
}
17301727

17311728

sqlmesh/core/engine_adapter/fabric.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def _insert_overwrite_by_condition(
5757

5858
def _get_access_token(self) -> str:
5959
"""Get access token using Service Principal authentication."""
60-
tenant_id = self._extra_config.get("tenant_id")
61-
client_id = self._extra_config.get("client_id")
62-
client_secret = self._extra_config.get("client_secret")
60+
tenant_id = self._extra_config.get("tenant")
61+
client_id = self._extra_config.get("user")
62+
client_secret = self._extra_config.get("password")
6363

6464
if not all([tenant_id, client_id, client_secret]):
6565
raise SQLMeshError(
@@ -102,14 +102,14 @@ def _make_fabric_api_request(
102102
if not requests:
103103
raise SQLMeshError("requests library is required for Fabric catalog operations")
104104

105-
workspace_id = self._extra_config.get("workspace_id")
106-
if not workspace_id:
105+
workspace = self._extra_config.get("workspace")
106+
if not workspace:
107107
raise SQLMeshError(
108-
"workspace_id parameter is required in connection config for Fabric catalog operations"
108+
"workspace parameter is required in connection config for Fabric catalog operations"
109109
)
110110

111111
base_url = "https://api.fabric.microsoft.com/v1"
112-
url = f"{base_url}/workspaces/{workspace_id}/{endpoint}"
112+
url = f"{base_url}/workspaces/{workspace}/{endpoint}"
113113

114114
headers = self._get_fabric_auth_headers()
115115

tests/core/engine_adapter/integration/config.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,12 @@ gateways:
192192
driver: pyodbc
193193
host: {{ env_var("FABRIC_HOST") }}
194194
user: {{ env_var("FABRIC_CLIENT_ID") }}
195-
password: {{ env_var("FABRIC_CLIENT_SECRET") }}
195+
password: {{ env_var("FABRIC_CLIENT_SECRET") }}
196196
database: {{ env_var("FABRIC_DATABASE") }}
197+
tenant: {{ env_var("FABRIC_TENANT") }}
198+
workspace: {{ env_var("FABRIC_WORKSPACE") }}
197199
odbc_properties:
198-
Authentication: ActiveDirectoryServicePrincipal
200+
Authentication: ActiveDirectoryServicePrincipal
199201
state_connection:
200202
type: duckdb
201203

0 commit comments

Comments
 (0)