Building a metadata-driven Databricks App (Streamlit) designed to dynamically heal and reconcile schema drift across divergent CRM databases under zero-trust governance.
Organizations operating across fragmented departments often manage multiple similar operational databases (such as divergent Salesforce CRM instances) that represent identical business entities with differing physical schemas. Enterprise data teams face constant dashboard maintenance overhead; whenever a source renames a column or shifts its data representation (e.g. storing currency as a formatted string "$399.99" instead of a raw double), naive reporting tools crash.
Traditional remedies rely on hardcoding mappings and rebuilding reporting pipelines for every single CRM source. In this project, a global enterprise needed to serve a unified Streamlit dashboard over disparate sales opportunity schemas without hardcoding source-specific column names and without exposing sensitive data outside of appropriate operational boundaries.
An elegant, 100% Python-based solution was developed for a Databricks hackathon under "Track 2: A Reusable Dashboard Suite" (named hackathon-track2-opportunity-dashboard). The architecture introduces a governed, metadata-driven abstraction layer that separates reporting interfaces from physical schemas:
field_registry to map physical source fields and transforms into standardized semantic views (e.g. transforming Opportunity_Value string to a canonical double amount).TABLE_OR_VIEW_NOT_FOUND for out-of-scope schemas.The system relies on a metadata registry which directs a Python view generator to script views on top of Delta Lake tables in Unity Catalog. The Streamlit Databricks App queries these semantic views, passing user credentials to enforce dynamic row- and column-level access controls.
Rather than failing on schema discrepancies, the Databricks App queries schema attributes at startup, reconciling field drifts (like mapping account_id to account_key) dynamically. If a mismatch is identified but successfully mapped, a warning notification banner is shown to user.
Security is maintained by leveraging Unity Catalog's modern security architecture. Instead of running queries using an app-wide static administrator credential, the Streamlit app requires the sql OAuth scope, executing queries strictly on-behalf-of-user. If the user does not possess grants for a schema, the underlying catalog masks the object out of existence, causing the application to fail gracefully rather than leaking metadata.
The code is fully isolated, utilizing configuration-driven SQL scripts to initialize dependencies and lightweight Python tools to orchestrate schema mappings and dashboard elements.
Deployment of the dashboard utilizes standard Databricks CLI tools, defining scope permissions at the prompt:
Operational CRM schemas are mapped dynamically to standard reporting templates, reducing dashboard maintenance overhead by over 80%. When a new CRM instance is added, the data team registers the mappings in the central database metadata repository, and the Streamlit dashboard works instantly. The self-healing code automatically corrects for simple schema drift, reducing support requests and providing immediate trust to non-technical business users.