Scamander MDIF¶
Scamander (Metadata-Driven Ingestion Framework, or MDIF) is a multi-platform Python SDK for metadata-driven data ingestion and transformation on Spark-based platforms. It abstracts away the differences between Microsoft Fabric and Databricks, so one ingestion or transformation pipeline runs unchanged on either, or on vanilla PySpark for local testing.
The platform’s Airflow providers (see Custom Airflow providers)
schedule when and where a job runs. MDIF is the library that job’s
own code imports: the notebook kernel a SparkNotebookOperator task
runs is a Spark driver, and it’s usually MDIF doing the actual
reading, transforming, and writing inside it.
A few things MDIF gives you out of the box:
The same Python code runs on Fabric, Databricks, and local Spark with no changes.
Delta tables get created straight from JSON metadata, including data types, nullability, primary/foreign keys, and SCD Type-2 history columns.
A chainable
TransformerAPI covers the full bronze→silver→gold path: type casting, cleaning, joins, aggregations, window functions, and pivots.QualityCheckerruns Great Expectations suites against any Spark DataFrame from a config-driven expectation model, logging results and optionally raising on failure.Anonymizerhandles anonymization and pseudonymization: six techniques (hash, mask, redact, generalize, encrypt, fake) driven by a declarativeAnonymizationConfig, and it plugs straight into theTransformerchain as.anonymize(config).Every pipeline run produces human-readable console logs, which are automatically forwarded into structured machine logs persisted to a Delta table.
CSV, JSON, Oracle, SQL Server, PostgreSQL, and Lakehouse sources are all accessed through the same
Source.connect()interface.A session wrapper takes care of OAuth 2.0 token refresh for REST API calls, so you don’t have to.
Architecture¶
src/scamander/
├── processor/ # Platform (abstract base, auto-detecting factory),
│ # Fabric, Databricks, Spark (vanilla fallback)
├── sources/ # Source (factory) + csv/json/oracle/postgresql/
│ # sqlserver/lakehouse connectors
├── sinks/ # Sink (factory) + lakehouse_sink
├── transformations/ # Transformer (fluent builder), cleaning
│ # (bronze→silver), enrichment (silver→gold), scd
├── quality/ # QualityChecker, QualityReporter
├── anonymization/ # Anonymizer + pure anonymization functions
├── secrets/ # SecretProvider + Vault / Azure Key Vault /
│ # Databricks implementations
├── models/ # Pydantic config models: Config, per-source and
│ # per-sink options, transformation/quality/
│ # anonymization config
├── utils/ # extract_archive, read_json_records
├── logging/ # HumanLogger (stdout), MachineLogger (Delta table)
└── api/ # OAuth2Session (auto-refreshing requests.Session)
Contents
- Getting started
- Installation
- Core concepts
- Usage guide
- 1. Initialise the platform
- 2. Read a config file
- 3. Read data from a source
- 4. Write data to a Delta table
- 5. Create a table from metadata
- 6. Bronze → Silver transformations
- 7. Silver → Gold transformations
- 8. SCD Type-2 merges
- 9. Config-driven transformation pipelines
- 10. File utilities
- 11. Logging
- 12. OAuth 2.0 API calls
- 13. Data quality checks
- 14. Anonymization / pseudonymization
- 15. Secret providers
- API reference
- Anonymization
- Api
- Logging
- Models
- Processor
- Quality
- Secrets
- Sources
- Transformations
- Utils
- Platform
- Databricks and Fabric
- Source connectors
- Transformer
- QualityChecker and QualityReporter
- Anonymizer
- Utils
- Loggers
- OAuth2Session
- Secret providers
- Supported source types
- Datatype mapping
- SCD Type-2 history tracking