Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion docs/concepts/audits.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ By default, SQLMesh will halt plan application when an audit fails so potentiall

A comprehensive suite of audits can identify data issues upstream, whether they are from your vendors or other teams. Audits also empower your data engineers and analysts to work with confidence by catching problems early as they work on new features or make updates to your models.

**NOTE**: For incremental models, audits are only applied to intervals being processed - not for the entire underlying table.
**NOTE**: For incremental by time range models, audits are only applied to intervals being processed - not for the entire underlying table.

## User-Defined Audits
In SQLMesh, user-defined audits are defined in `.sql` files in an `audits` directory in your SQLMesh project. Multiple audits can be defined in a single file, so you can organize them to your liking. Alternatively, audits can be defined inline within the model definition itself.
Expand Down
32 changes: 4 additions & 28 deletions sqlmesh/core/config/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1720,38 +1720,14 @@ def _engine_adapter(self) -> t.Type[EngineAdapter]:

@property
def _connection_factory(self) -> t.Callable:
"""
Override connection factory to create a dynamic catalog-aware factory.
This factory closure can access runtime catalog information passed to it.
"""

# Get the base connection factory from parent
# Override to support catalog switching for Fabric
base_factory = super()._connection_factory

def create_fabric_connection(
target_catalog: t.Optional[str] = None, **kwargs: t.Any
target_catalog: t.Optional[str] = None, *args: t.Any, **kwargs: t.Any
) -> t.Any:
"""
Create a Fabric connection with optional dynamic catalog override.

Args:
target_catalog: Optional catalog to use instead of the configured database
**kwargs: Additional connection parameters
"""
# Use target_catalog if provided, otherwise fall back to configured database
effective_database = target_catalog if target_catalog is not None else self.database

# Create connection with the effective database
connection_kwargs = {
**{k: v for k, v in self.dict().items() if k in self._connection_kwargs_keys},
**kwargs,
}

# Override database parameter
if effective_database:
connection_kwargs["database"] = effective_database

return base_factory(**connection_kwargs)
kwargs["database"] = target_catalog or self.database
return base_factory(*args, **kwargs)

return create_fabric_connection

Expand Down
Loading