
Data Governance & Script Generation Framework
Designed and delivered an end-to-end framework for generating and executing Snowflake and Databricks management scripts from a centralised template repository. Implemented as stored procedures (Snowflake) and an OOP TemplateGenerator class (Databricks/Python). Uses owner's-rights execution and Service Principal privilege escalation so no human user holds GRANT or CREATE USER rights on any platform. A self-documenting help system is built directly into the interface.
Designed and delivered an end-to-end framework for generating and executing Snowflake and Databricks management scripts from a centralised template repository — eliminating hardcoded SQL scripts, reducing human error, and enabling non-privileged users to perform administrative operations safely.
Snowflake Implementation
- Designed the
SCRIPT_TEMPLATEtable inADMINISTRATION.UTILSas the single source of truth for all script templates, storingSCRIPT_TYPE,ACCESS_TYPE,PARAMETER_NAMES, and parameterisedTEMPLATEbodies. - Authored the core stored procedure
GENERATE_SCRIPT_FROM_TEMPLATE(VARCHAR returns) supporting three invocation modes: standalone in the Snowflake UI, inside Snowflake loops, embedded in parent procedures, and via external tools (dbt, SnowSQL). - Implemented a self-documenting help system — passing empty strings to any argument returns contextual usage information, access type listings, or parameter schemas directly from the template table.
- Built procedures based on similar principles:
CREATE_SCHEMAS,CHANGE_OWNERSHIP,GENERATE_TECHNICAL_ROLE,CREATE_SECURITY, as well as many others. - As an example of a very complex procedure I built the procedure
CREATE_STRUCTURES_WITH_ACCESSES— combining various other procs together. It executes in the background the following procs:CREATE_SCHEMAS,CHANGE_OWNERSHIP,GENERATE_TECHNICAL_ROLEandCREATE_SECURITY, and creates a DATABASE structure with SCHEMAS protected by appropriate access rights. - Established a consistent error-handling contract: all procedures return a VARCHAR string; errors surface as strings prefixed with
!Error, enabling clean handling in loops and parent procedures.
Databricks / Azure Extension
- Architected the equivalent Python-based framework for Databricks — translating the Snowflake procedural pattern into an object-oriented
TemplateGeneratorclass backed by a Delta table in Unity Catalog (administration_se.utils.script_template). - Stored the class in a Unity Catalog Volume, making it importable across notebooks, dbt Python models, Databricks Jobs, and external REST callers without code duplication.
- Replicated the three-argument help-mode interface identically —
generate_script('','',''),generate_script('TYPE','',''),generate_script('TYPE','ACCESS','')— preserving the same developer experience across both platforms. - Implemented the privilege-escalation layer using a Databricks Job configured with
run_as: Service Principal— mirroring Snowflake'sEXECUTE AS OWNERso that human callers with no GRANT or CREATE USER rights can trigger elevated operations safely. - Implemented child methods
generate_grant_role()andgenerate_user()as thin wrappers over the core method, maintaining the same single-responsibility design as the Snowflake procedures. - Defined Unity Catalog RBAC grants — separating read access (SELECT on template table, READ VOLUME) for regular engineers from MANAGE GRANTS and CREATE USER rights held exclusively by the Service Principal.
Impact & Outcomes
- Reduced time to provision new users and roles from manual multi-step processes to a single parameterised procedure call.
- Eliminated direct privilege exposure — no human user holds GRANT or CREATE USER rights on either platform.
- Framework adopted across dbt pipelines, ADF orchestration flows, and Databricks notebook workflows with zero code changes to the core class.
- Template table acts as living documentation — all script patterns, their parameters, and descriptions are queryable directly from SQL or the help system.
Metadata-Driven Automated Testing Framework
Built a data quality testing module integrated directly into the ADF ingestion workflow. Reuses the same generalised Copy pipeline and Metadata database — no separate test infrastructure. A Databricks Python test class executes row count, nullability, freshness, uniqueness, referential, and custom SQL checks after every ingestion run. All results are recorded against the object run ID for full traceability. Tests are configured via a self-service Metadata UI without code deployment.
Delta Lake Table Processing Framework
Designed and implemented a metadata-driven Delta Lake processing framework on Databricks using a modular OOP Python architecture. Four core classes — MetadataClass, FileLoaderClass, DeltaProcessorClass, and ProcessingClass — handle all pipeline concerns independently. Supports full load, incremental load, and CDC merge. Onboarding a new data object requires only a metadata entry, not code changes.