Kernconcepten¶
Automatische platformdetectie¶
Platform() leest environment variables om de runtime te detecteren en geeft automatisch de juiste concrete subklasse terug — je importeert nooit rechtstreeks Fabric of Databricks:
Environment variable |
Gedetecteerd platform |
|---|---|
|
|
|
|
Geen van beide |
|
from scamander.processor.platform import Platform
platform = Platform() # returns a Fabric, Databricks, or Spark instance
Configmodel¶
Het Config Pydantic-model is het contract op het hoogste niveau tussen je metadatabestanden en het framework. Het bevat een source (wat te lezen) en een sink (waar te schrijven):
from scamander.models import Config
from scamander.models.source_config import SourceConfig
from scamander.models.source_config.csv import CsvSourceOptions
from scamander.models.sink_config import SinkConfig
from scamander.models.sink_config.lakehouse import LakeHouseSinkOptions
config = Config(
source=SourceConfig(type="csv", options=CsvSourceOptions()),
sink=SinkConfig(type="LakeHouse", options=LakeHouseSinkOptions()),
)
In de praktijk parse je Config vanuit een JSON- of YAML-bestand in plaats van het in code te construeren — zie 2. Een configbestand lezen.
Metadata-configbestanden¶
Configbestanden sturen elke pipeline-run aan: sources, sinks, kolomschema’s en gedragsvlaggen. JSON is het primaire formaat; CSV en YAML worden ook ondersteund.
Een typische JSON-metadataconfig voor het aanmaken van een tabel:
{
"table": "bronze.my_schema.customer",
"track_history": false,
"columns": [
{ "target": "customer_id", "type": "INT", "nullable": false, "primary_key": true },
{ "target": "customer_name", "type": "NVARCHAR", "nullable": true },
{ "target": "created_at", "type": "DATETIME2", "nullable": false },
{ "target": "revenue", "type": "DECIMAL", "nullable": true, "precision": 18, "scale": 2 }
]
}