SAP Data Doesn’t Care About Your Medallion (And I Built One Anyway)
Summary
This article details the implementation of a Medallion architecture for processing complex SAP data within Databricks, utilizing Lakeflow Declarative Pipelines. It addresses common challenges with raw SAP data, such as non-standard date formats like CHAR(16) and "0000-00-00" values, FLOAT types for monetary amounts, and obscure column names like VBELN. The architecture comprises a bronze layer, automatically synced by OneConnect with Change Data Feed enabled; a silver layer that performs Change Data Capture (CDC) to maintain Type-1 snapshots and correctly propagate deletes; and a gold layer that enriches data with text tables, derives calculated fields, and renames technical terms to business-friendly language. A crucial design choice involves separating the generic silver pipeline from domain-specific gold pipelines to ensure data governance and prevent pipeline collisions.
Key takeaway
For data engineers building robust data platforms with SAP sources, you should adopt a multi-pipeline Medallion architecture. This approach, using Lakeflow Declarative Pipelines, ensures proper handling of SAP's complex data types and critical delete propagation. Separate your generic silver layer from domain-specific gold layers to prevent conflicts and maintain data integrity. This strategy provides clean, governed data essential for trustworthy dashboards and advanced AI applications like text-to-SQL agents.
Key insights
Taming chaotic SAP data requires a declarative pipeline approach with careful handling of data types and deletes.
Principles
- Declarative pipelines excel with messy sources like SAP.
- Design for deletes from day one in SAP data pipelines.
- Separate generic shared data from domain-specific pipelines.
Method
Implement a Medallion architecture: Bronze (raw, CDC-enabled), Silver (Type-1 snapshot, apply_as_deletes for CDC), Gold (enrichment, renaming, type casting). Use two pipelines: one for silver, multiple for gold.
In practice
- Intercept "0000-00-00" dates, convert to NULL.
- Cast FLOAT amounts to DECIMAL for financial calculations.
- Filter SAP text tables by language (e.g., spras = 'E').
Topics
- SAP Data Integration
- Medallion Architecture
- Lakeflow Declarative Pipelines
- Change Data Capture
- Databricks Delta Lake
- Data Governance
Code references
Best for: Data Engineer, MLOps Engineer, AI Architect
Related on AIssential
See Counsel's argued verdicts on the open AI decisions leaders are weighing →
Editorial summary, takeaway, and curation by AIssential. Original article published by Data Engineering on Medium.