Hi Janice Chi Great to see you're implementing a detailed reconciliation framework during your DB2 to Azure SQL Hyperscale migration. Both Option A (Databricks JDBC write) and Option B (ADF stored procedure call) are technically viable, but here's a breakdown based on robustness, maintainability, and failure recovery aligned with recommended Microsoft practices:
Recommended Approach: Option B – Use ADF to call stored procedure
Why Option B is preferred:
- Operational Clarity & Separation of Concerns: Let Databricks focus purely on data transformation and reconciliation metric generation, and delegate logging/persistence to ADF. This simplifies error tracing and decouples concerns.
- Better Failure Handling: ADF pipelines provide built-in retry policies, failure scopes, alerts, and granular activity-level monitoring when calling stored procedures.
- Centralized Logging Logic: Logic inside stored procedures is versioned, centralized, and easier to audit or update without modifying code in Databricks notebooks.
- Compliance and Audit-Readiness: Easier to enforce transactional boundaries (e.g., via
BEGIN TRANSACTION
) inside the SP for consistent audit logs.
When Option A may still be valid:
If extremely low-latency logging is needed or you're outside ADF's orchestration path (e.g., Databricks running independently).
In scenarios requiring complex or conditional metadata writes based on in-memory logic only available in Databricks.
Best Practices if using ADF + SP:
Use Execute Stored Procedure
activity in ADF with clear parameters for stage, row counts, hash, timestamp, etc.
Ensure your stored proc handles idempotency (i.e., no duplicate inserts on retries).
Log failures and outputs of the SP execution for traceability.
Use custom status codes or logging tables for enhanced observability if needed.
Docs reference (for ADF stored procedure activity): Azure Data Factory – Execute stored procedure
I hope this information helps. Please do let us know if you have any further queries.
Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues.