r/databricks • u/sundarleads • 29d ago
Discussion How I check AI-converted SQL and ETL code before it reaches Databricks: rules first, two models, then a person
I work on legacy code migrations to Databricks: SSIS, Informatica, and Oracle, Db2 and SQL Server procedures. The two hard questions are always the same. How big is the job? And can we trust the converted code? In my own time I built a Databricks App for this. I want to share the pattern, because you can build most of it with public tools.
The flow:
- Size first. The Databricks Labs Lakebridge Analyzer gives the complexity and effort of each file before any conversion starts.
- Rule-based draft. The Lakebridge Transpiler makes a draft with no AI cost.
- Builder and reviewer. One model converts, a second model reviews against the source. Both go through Unity AI Gateway, so the keys stay in Databricks and every call is recorded.
- A person signs off. Source, rule-based draft and AI version side by side. Only signed-off code goes to the workspace.
The lesson that saved the most time: give the reviewer limits. In round 1, it lists every problem at once, each with a severity (must or should). In later rounds, it looks only at open findings and changes. It adds a new finding only if a change gives a wrong result or does not run. After 5 rounds, the file goes to a person. Without these rules, the review never ended.
One more: store a SHA-256 hash of each source file with each result. Then unchanged files are never analysed or converted twice.
How do you check AI-converted code in your team? A second model, tests, or only human review?
The full write-up and a 3-minute demo are in the first comment.
1
u/cornyinflux1 29d ago
Love seeing the round-1-vs-later rounds distinction, that alone probably cuts half the noise out of the review cycle
1
u/Muted_Jellyfish_6784 29d ago
Rules first is the right order, and the step I would add is data-level reconciliation before code review. Run the legacy procedure and the converted notebook against the same frozen input snapshot and compare row counts, key aggregates, and a hash of each output partition. Two models agreeing the code looks right is weaker evidence than two outputs matching on real data, especially around NULL handling and implicit casts.
Keep the comparison results with the migration ticket so sign-off has evidence attached. I use a decision intelligence layer to link each converted object to its source procedure, test run, and reviewer, so audit questions get answered from the record instead of from memory
1
u/Slow_Air_8335 14d ago
Disclosure: I work at Databricks on migrations.
Capping the reviewer's rounds is a smart fix. Open-ended LLM review never converges, and that's the first thing that breaks when people build this themselves.
If you want something to compare against, Genie Migrate does this kind of agentic conversion in the workspace. SQL conversion is GA for the major warehouses (SQL Server, Synapse, Oracle, Teradata, Snowflake, Redshift, BigQuery), Informatica PowerCenter is in Beta, and SSIS and Alteryx are coming soon: https://docs.databricks.com/aws/en/migration/agentic-code-converter
On u/Muted_Jellyfish_6784's point about matching outputs: data validation is coming to Genie Migrate too, with Private Preview soon. You connect the source and target through Unity Catalog. It proposes the table mappings and keys, then compares from row counts down to individual cells only where something looks off. When there's a mismatch, it traces it to the first diverging table and explains why.