Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
b679716
feat: Add support for Microsoft Fabric Waerhouse
fresioAS Jun 16, 2025
9a6c575
removing some print statements
fresioAS Jun 16, 2025
347d3ed
adding dialect & handling temp views
fresioAS Jun 17, 2025
0ff075c
isnan error
fresioAS Jun 18, 2025
332ea32
CTEs no qualify
fresioAS Jun 19, 2025
585fb7e
simplifying
fresioAS Jun 23, 2025
1bbe90e
docs & tests
fresioAS Jun 23, 2025
6895570
connection tests
fresioAS Jun 23, 2025
9c0a2dd
remove table_exist and columns
fresioAS Jun 24, 2025
f40fc4d
updated tests
fresioAS Jun 25, 2025
5cc30ab
mypy
fresioAS Jun 25, 2025
d5f7aa7
ruff
fresioAS Jun 25, 2025
873d9f5
Merge branch 'main' into add_fabric_warehouse
fresioAS Jun 25, 2025
50fe5e4
Update fabric.md
fresioAS Jun 25, 2025
ae7197b
Merge branch 'main' into add_fabric_warehouse
fresioAS Jun 27, 2025
3a06c90
Update sqlmesh/core/engine_adapter/fabric.py
fresioAS Jul 2, 2025
15a9603
Merge branch 'main' into add_fabric_warehouse
fresioAS Jul 2, 2025
145b69b
Update fabric.py
fresioAS Jul 2, 2025
9c37b9e
Merge branch 'main' into add_fabric_warehouse
fresioAS Jul 3, 2025
ecf3e7b
Add Fabric to integration tests
erindru Jul 3, 2025
481c9a7
Merge remote-tracking branch 'fresioAS/add_fabric_warehouse' into fea…
mattiasthalen Jul 10, 2025
ec87592
Merge remote-tracking branch 'erindru/fresioas-sqlmesh-fabric-integra…
mattiasthalen Jul 10, 2025
9127bda
feat(tests): add fabric timestamp handling in dialects test
mattiasthalen Jul 10, 2025
deb9321
fix: update catalog support configuration in FabricConnectionConfig
mattiasthalen Jul 10, 2025
4412fc9
fix(mssql): update driver selection logic to allow enforcing pyodbc i…
mattiasthalen Jul 10, 2025
6ac197e
fix(fabric): Skip test_value_normalization for TIMESTAMPTZ
mattiasthalen Jul 11, 2025
173e0ac
Manually set sqlglot to dev branch.
mattiasthalen Jul 11, 2025
933a765
Merge branch 'main' into feat/add-fabric-engine
mattiasthalen Jul 11, 2025
e154241
feat: Add support for Microsoft Fabric Waerhouse
fresioAS Jun 16, 2025
2bdd417
removing some print statements
fresioAS Jun 16, 2025
cbe3bdc
adding dialect & handling temp views
fresioAS Jun 17, 2025
0080583
isnan error
fresioAS Jun 18, 2025
bded0d0
CTEs no qualify
fresioAS Jun 19, 2025
51753f1
simplifying
fresioAS Jun 23, 2025
55d7314
docs & tests
fresioAS Jun 23, 2025
1f37a4b
connection tests
fresioAS Jun 23, 2025
5cb0e4f
remove table_exist and columns
fresioAS Jun 24, 2025
8253545
updated tests
fresioAS Jun 25, 2025
6a54905
mypy
fresioAS Jun 25, 2025
6f1a575
ruff
fresioAS Jun 25, 2025
c2d10a2
Update fabric.md
fresioAS Jun 25, 2025
cd9f261
Update sqlmesh/core/engine_adapter/fabric.py
fresioAS Jul 2, 2025
1eb623a
Update fabric.py
fresioAS Jul 2, 2025
5113ef4
Update sqlmesh/core/config/connection.py
fresioAS Jul 10, 2025
d17677e
Add Fabric to integration tests
erindru Jul 3, 2025
c89351a
added mattiasthalen fork changes
fresioAS Jul 16, 2025
0bbca57
Merge remote-tracking branch 'upstream/main' into feat/add-fabric-engine
mattiasthalen Jul 17, 2025
a0ea870
Merge branch 'add_fabric_warehouse' into feat/add-fabric-engine
mattiasthalen Jul 20, 2025
e011ac6
Merge branch 'main' into feat/add-fabric-engine
mattiasthalen Jul 20, 2025
f54b0f6
fix: update varchar columns to varchar(max) in table diff tests
mattiasthalen Jul 20, 2025
cd4aa95
fix: change varchar(max) to varchar(8000) in integration tests
mattiasthalen Jul 20, 2025
94e7978
Revert "fix(mssql): update driver selection logic to allow enforcing …
mattiasthalen Jul 20, 2025
1628ca5
Test removal of fabric config
mattiasthalen Jul 20, 2025
09a0534
Merge remote-tracking branch 'upstream/main' into feat/add-fabric-engine
mattiasthalen Jul 22, 2025
bce209e
Bump SQLGlot to 27.2.0
mattiasthalen Jul 22, 2025
25c393f
Activate fabric profile in integration testing
mattiasthalen Jul 22, 2025
7756a8f
Add odbc to engine_tests_cloud in circleci
mattiasthalen Jul 22, 2025
1655263
feat(fabric): add catalog management for Fabric
mattiasthalen Jul 11, 2025
ea088aa
feat(fabric): update connection configuration for Fabric adapter
mattiasthalen Jul 11, 2025
e19e3e4
feat(fabric): Add support for catalog operations
mattiasthalen Jul 21, 2025
a869df3
feat(fabric): Refactor _create_catalog
mattiasthalen Jul 22, 2025
90d5abd
feat(fabric): Refactor _drop_catalog
mattiasthalen Jul 22, 2025
eac16da
fix(fabric): update response json
mattiasthalen Jul 22, 2025
f4aad00
feat(fabric): Override set_current_catalog
mattiasthalen Jul 24, 2025
38b82bb
feat(fabric): Override drop schema
mattiasthalen Jul 24, 2025
719a1d5
feat(fabric): Override create schema
mattiasthalen Jul 24, 2025
3af7ec9
feat(fabric): Override create view
mattiasthalen Jul 24, 2025
cedfab4
feat(fabric): Catalog dropping functionality in TestContext
mattiasthalen Jul 24, 2025
7cb8447
fix(fabric): Ensure schemas exist before creating tables
mattiasthalen Jul 24, 2025
fc2731b
Merge branch 'main' into feat/add-fabric-engine
mattiasthalen Jul 24, 2025
0ae2621
Revert "Add odbc to engine_tests_cloud in circleci"
mattiasthalen Jul 24, 2025
3d95bba
fix(circleci): Add unixodbc-dev to common dependencies in install script
mattiasthalen Jul 24, 2025
734dbda
Merge branch 'main' into feat/add-fabric-engine
mattiasthalen Jul 24, 2025
9718fd9
Revert "fix: change varchar(max) to varchar(8000) in integration tests"
mattiasthalen Jul 24, 2025
bd0f759
fix(docs): update installation command and add tenant & workspace UUI…
mattiasthalen Jul 24, 2025
6cd5430
fix(tests): change varchar(max) to varchar in table creation tests
mattiasthalen Jul 24, 2025
d4a3c2b
Bump sqlglot
mattiasthalen Jul 24, 2025
efa97af
feat(circleci): add fabric to the list of cloud engines to test
mattiasthalen Jul 24, 2025
148915a
Merge branch 'main' into feat/add-fabric-engine
mattiasthalen Jul 24, 2025
e693baf
fix(fabric): Update docs and add id to parameter names
mattiasthalen Jul 28, 2025
705a670
Merge remote-tracking branch 'upstream/main' into feat/add-fabric-engine
mattiasthalen Jul 28, 2025
eaba56a
fix(fabric): Leverage tenacity for retry logic
mattiasthalen Jul 29, 2025
9a720c8
fix(fabric): Use SchemaName instead of t.Union
mattiasthalen Jul 29, 2025
0dccfdc
fix(fabric): Use exp.Table to extract extract schema name
mattiasthalen Jul 29, 2025
0569051
fix(fabric): Correct catalog.schema parsing
mattiasthalen Jul 30, 2025
e0c0d3b
Merge remote-tracking branch 'upstream/main' into feat/add-fabric-engine
mattiasthalen Jul 30, 2025
cfcc05f
fix(fabric): Add workspace_id and tenant_id to unit tests
mattiasthalen Jul 30, 2025
550b917
Merge remote-tracking branch 'upstream/main' into feat/add-fabric-engine
mattiasthalen Jul 30, 2025
6496dbc
install ODBC for CircleCI config
fresioAS Aug 4, 2025
d0abf94
Merge branch 'main' into add_fabric_warehouse
fresioAS Aug 4, 2025
0d3f129
trying to fix circleci
fresioAS Aug 4, 2025
6dabf98
Merge branch 'add_fabric_warehouse' of https://github.com/fresioAS/sq…
fresioAS Aug 4, 2025
ca1b9e2
trying to fix circleci 2
fresioAS Aug 4, 2025
dc87f83
circleci added fabric + windows_test fix
fresioAS Aug 4, 2025
37c4062
circleci fabric dummy host
fresioAS Aug 4, 2025
7b83f2f
circleci fabric under cloud test
fresioAS Aug 4, 2025
406293e
Merge remote-tracking branch 'mattiasthalen/feat/add-fabric-engine' i…
fresioAS Aug 5, 2025
948e8b1
Merge branch 'main' into add_fabric_warehouse
fresioAS Aug 5, 2025
9feae31
Merge remote-tracking branch 'upstream/main' into add_fabric_warehouse
mattiasthalen Aug 6, 2025
b6a3bf5
fix(fabric): Rename to FabricEngineAdapter
mattiasthalen Aug 6, 2025
57657fe
fix(fabric): Import requests directly and update type annotations
mattiasthalen Aug 6, 2025
563366a
fix(fabric): Use thread-local storage for Fabric target catalog
mattiasthalen Aug 6, 2025
db078c2
feat(fabric): Consolidate catalog switching logic in Fabric adapter
mattiasthalen Aug 6, 2025
d67a101
fix(fabric): Use proper connection factory pattern for Fabric catalog…
mattiasthalen Aug 6, 2025
a490c81
Merge pull request #2 from mattiasthalen/add_fabric_warehouse
fresioAS Aug 6, 2025
881dff0
reverting continue_config
fresioAS Aug 6, 2025
8fe5faf
fix(fabric): Remove unwarranted checks
mattiasthalen Aug 7, 2025
b38b6c9
fix(fabric): Consolidate API methods
mattiasthalen Aug 7, 2025
6e018bb
fix(fabric): Simplify warehouse ID retrieval using next() for better …
mattiasthalen Aug 7, 2025
422d350
feat(fabric): Refactor connection factory
mattiasthalen Aug 7, 2025
6b702fa
feat(fabric): Remove redundant create_table and ctas overrides
mattiasthalen Aug 7, 2025
02121e2
Merge remote-tracking branch 'upstream/main' into add_fabric_warehouse
mattiasthalen Aug 7, 2025
776b840
fix(fabric): Enhance adapter with production-ready improvements
mattiasthalen Aug 7, 2025
f4df373
fix(fabric): Simplify adapter architecture and fix integration issues
mattiasthalen Aug 7, 2025
6a14738
Merge pull request #3 from mattiasthalen/add_fabric_warehouse
fresioAS Aug 7, 2025
88b5f0b
removed odbc from continue_config
fresioAS Aug 7, 2025
d2f2169
Revert " fix(fabric): Simplify adapter architecture and fix integrati…
fresioAS Aug 8, 2025
d28a781
Revert " fix(fabric): Enhance adapter with production-ready improveme…
fresioAS Aug 8, 2025
5652c7a
Merge branch 'main' into add_fabric_warehouse
fresioAS Aug 12, 2025
d0e4607
Factor out much of the vibe code
erindru Aug 13, 2025
d9729a1
Merge pull request #4 from erindru/erin/add_fabric_warehouse_mods
fresioAS Aug 13, 2025
1c8fc5c
Merge branch 'main' into add_fabric_warehouse
fresioAS Aug 13, 2025
a3a1303
Merge branch 'main' into add_fabric_warehouse
fresioAS Aug 14, 2025
f5a562e
Merge branch 'main' into add_fabric_warehouse
fresioAS Aug 15, 2025
6564b4e
Merge branch 'main' into add_fabric_warehouse
erindru Aug 19, 2025
53184b6
fix mypy
erindru Aug 19, 2025
0b837a1
fix unit tests
erindru Aug 19, 2025
49fd7cc
Merge branch 'main' into add_fabric_warehouse
erindru Aug 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .circleci/continue_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ workflows:
- bigquery
- clickhouse-cloud
- athena
# todo: enable fabric when cicd catalog create/drop implemented in manage-test-db.sh
#- fabric
- gcp-postgres
filters:
branches:
Expand Down
2 changes: 1 addition & 1 deletion .circleci/install-prerequisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fi

ENGINE="$1"

COMMON_DEPENDENCIES="libpq-dev netcat-traditional"
COMMON_DEPENDENCIES="libpq-dev netcat-traditional unixodbc-dev"
ENGINE_DEPENDENCIES=""

if [ "$ENGINE" == "spark" ]; then
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ clickhouse-cloud-test: guard-CLICKHOUSE_CLOUD_HOST guard-CLICKHOUSE_CLOUD_USERNA
athena-test: guard-AWS_ACCESS_KEY_ID guard-AWS_SECRET_ACCESS_KEY guard-ATHENA_S3_WAREHOUSE_LOCATION engine-athena-install
pytest -n auto -m "athena" --retries 3 --junitxml=test-results/junit-athena.xml

fabric-test: guard-FABRIC_HOST guard-FABRIC_CLIENT_ID guard-FABRIC_CLIENT_SECRET guard-FABRIC_DATABASE engine-fabric-install
pytest -n auto -m "fabric" --retries 3 --junitxml=test-results/junit-fabric.xml

gcp-postgres-test: guard-GCP_POSTGRES_INSTANCE_CONNECTION_STRING guard-GCP_POSTGRES_USER guard-GCP_POSTGRES_PASSWORD guard-GCP_POSTGRES_KEYFILE_JSON engine-gcppostgres-install
pytest -n auto -m "gcp_postgres" --retries 3 --junitxml=test-results/junit-gcp-postgres.xml

Expand Down
1 change: 1 addition & 0 deletions docs/guides/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,7 @@ These pages describe the connection configuration options for each execution eng
* [BigQuery](../integrations/engines/bigquery.md)
* [Databricks](../integrations/engines/databricks.md)
* [DuckDB](../integrations/engines/duckdb.md)
* [Fabric](../integrations/engines/fabric.md)
* [MotherDuck](../integrations/engines/motherduck.md)
* [MySQL](../integrations/engines/mysql.md)
* [MSSQL](../integrations/engines/mssql.md)
Expand Down
34 changes: 34 additions & 0 deletions docs/integrations/engines/fabric.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Fabric

## Local/Built-in Scheduler
**Engine Adapter Type**: `fabric`

NOTE: Fabric Warehouse is not recommended to be used for the SQLMesh [state connection](../../reference/configuration.md#connections).

### Installation
#### Microsoft Entra ID / Azure Active Directory Authentication:
```
pip install "sqlmesh[fabric]"
```

### Connection options

| Option | Description | Type | Required |
| ----------------- | ------------------------------------------------------------ | :----------: | :------: |
| `type` | Engine type name - must be `fabric` | string | Y |
| `host` | The hostname of the Fabric Warehouse server | string | Y |
| `user` | The client id to use for authentication with the Fabric Warehouse server | string | N |
| `password` | The client secret to use for authentication with the Fabric Warehouse server | string | N |
| `port` | The port number of the Fabric Warehouse server | int | N |
| `database` | The target database | string | N |
| `charset` | The character set used for the connection | string | N |
| `timeout` | The query timeout in seconds. Default: no timeout | int | N |
| `login_timeout` | The timeout for connection and login in seconds. Default: 60 | int | N |
| `appname` | The application name to use for the connection | string | N |
| `conn_properties` | The list of connection properties | list[string] | N |
| `autocommit` | Is autocommit mode enabled. Default: false | bool | N |
| `driver` | The driver to use for the connection. Default: pyodbc | string | N |
| `driver_name` | The driver name to use for the connection. E.g., *ODBC Driver 18 for SQL Server* | string | N |
| `tenant_id` | The Azure / Entra tenant UUID | string | Y |
| `workspace_id` | The Fabric workspace UUID. The preferred way to retrieve it is by running `notebookutils.runtime.context.get("currentWorkspaceId")` in a python notebook. | string | Y |
| `odbc_properties` | The dict of ODBC connection properties. E.g., authentication: ActiveDirectoryServicePrincipal. See more [here](https://learn.microsoft.com/en-us/sql/connect/odbc/dsn-connection-string-attribute?view=sql-server-ver16). | dict | N |
1 change: 1 addition & 0 deletions docs/integrations/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SQLMesh supports the following execution engines for running SQLMesh projects (e
* [ClickHouse](./engines/clickhouse.md) (clickhouse)
* [Databricks](./engines/databricks.md) (databricks)
* [DuckDB](./engines/duckdb.md) (duckdb)
* [Fabric](./engines/fabric.md) (fabric)
* [MotherDuck](./engines/motherduck.md) (motherduck)
* [MSSQL](./engines/mssql.md) (mssql)
* [MySQL](./engines/mysql.md) (mysql)
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ nav:
- integrations/engines/clickhouse.md
- integrations/engines/databricks.md
- integrations/engines/duckdb.md
- integrations/engines/fabric.md
- integrations/engines/motherduck.md
- integrations/engines/mssql.md
- integrations/engines/mysql.md
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ dev = [
dbt = ["dbt-core<2"]
dlt = ["dlt"]
duckdb = []
fabric = ["pyodbc>=5.0.0"]
gcppostgres = ["cloud-sql-python-connector[pg8000]>=1.8.0"]
github = ["PyGithub>=2.6.0"]
llm = ["langchain", "openai"]
Expand Down Expand Up @@ -253,6 +254,7 @@ markers = [
"clickhouse_cloud: test for Clickhouse (cloud mode)",
"databricks: test for Databricks",
"duckdb: test for DuckDB",
"fabric: test for Fabric",
"motherduck: test for MotherDuck",
"mssql: test for MSSQL",
"mysql: test for MySQL",
Expand Down
1 change: 1 addition & 0 deletions sqlmesh/core/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ConnectionConfig as ConnectionConfig,
DatabricksConnectionConfig as DatabricksConnectionConfig,
DuckDBConnectionConfig as DuckDBConnectionConfig,
FabricConnectionConfig as FabricConnectionConfig,
GCPPostgresConnectionConfig as GCPPostgresConnectionConfig,
MotherDuckConnectionConfig as MotherDuckConnectionConfig,
MSSQLConnectionConfig as MSSQLConnectionConfig,
Expand Down
57 changes: 56 additions & 1 deletion sqlmesh/core/config/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@

logger = logging.getLogger(__name__)

RECOMMENDED_STATE_SYNC_ENGINES = {"postgres", "gcp_postgres", "mysql", "mssql", "azuresql"}
RECOMMENDED_STATE_SYNC_ENGINES = {
"postgres",
"gcp_postgres",
"mysql",
"mssql",
"azuresql",
}
FORBIDDEN_STATE_SYNC_ENGINES = {
# Do not support row-level operations
"spark",
Expand Down Expand Up @@ -1684,6 +1690,55 @@ def _extra_engine_config(self) -> t.Dict[str, t.Any]:
return {"catalog_support": CatalogSupport.SINGLE_CATALOG_ONLY}


class FabricConnectionConfig(MSSQLConnectionConfig):
"""
Fabric Connection Configuration.
Inherits most settings from MSSQLConnectionConfig and sets the type to 'fabric'.
It is recommended to use the 'pyodbc' driver for Fabric.
"""

type_: t.Literal["fabric"] = Field(alias="type", default="fabric") # type: ignore
DIALECT: t.ClassVar[t.Literal["fabric"]] = "fabric" # type: ignore
DISPLAY_NAME: t.ClassVar[t.Literal["Fabric"]] = "Fabric" # type: ignore
DISPLAY_ORDER: t.ClassVar[t.Literal[17]] = 17 # type: ignore
driver: t.Literal["pyodbc"] = "pyodbc"
workspace_id: str
tenant_id: str
autocommit: t.Optional[bool] = True

@property
def _engine_adapter(self) -> t.Type[EngineAdapter]:
from sqlmesh.core.engine_adapter.fabric import FabricEngineAdapter

return FabricEngineAdapter

@property
def _connection_factory(self) -> t.Callable:
# Override to support catalog switching for Fabric
base_factory = super()._connection_factory

def create_fabric_connection(
target_catalog: t.Optional[str] = None, *args: t.Any, **kwargs: t.Any
) -> t.Callable:
kwargs["database"] = target_catalog or self.database
return base_factory(*args, **kwargs)

return create_fabric_connection

@property
def _extra_engine_config(self) -> t.Dict[str, t.Any]:
return {
"database": self.database,
# more operations than not require a specific catalog to be already active
# in particular, create/drop view, create/drop schema and querying information_schema
"catalog_support": CatalogSupport.REQUIRES_SET_CATALOG,
"workspace_id": self.workspace_id,
"tenant_id": self.tenant_id,
"user": self.user,
"password": self.password,
}


class SparkConnectionConfig(ConnectionConfig):
"""
Vanilla Spark Connection Configuration. Use `DatabricksConnectionConfig` for Databricks.
Expand Down
2 changes: 2 additions & 0 deletions sqlmesh/core/engine_adapter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from sqlmesh.core.engine_adapter.trino import TrinoEngineAdapter
from sqlmesh.core.engine_adapter.athena import AthenaEngineAdapter
from sqlmesh.core.engine_adapter.risingwave import RisingwaveEngineAdapter
from sqlmesh.core.engine_adapter.fabric import FabricEngineAdapter

DIALECT_TO_ENGINE_ADAPTER = {
"hive": SparkEngineAdapter,
Expand All @@ -35,6 +36,7 @@
"trino": TrinoEngineAdapter,
"athena": AthenaEngineAdapter,
"risingwave": RisingwaveEngineAdapter,
"fabric": FabricEngineAdapter,
}

DIALECT_ALIASES = {
Expand Down
Loading