<!-- example:databricks-migration -->
# Databricks migration specification example

A Snowflake-to-Databricks SQL migration that treats behavior preservation as an acceptance requirement.

- [HTML version](https://specifica.org/examples/databricks-migration/)
- [Specifica format](https://specifica.org/format.md)
- Reference template: not a built-in Playground starter

## spec.md

### Requirements

- [ ] Every in-scope Snowflake procedure is assigned to a migration wave with an owner.
- [ ] The client approves the behavior rules to preserve before a procedure is converted.
- [ ] A converted procedure preserves the source transaction boundaries.
- [ ] A numeric conversion that returns null on invalid input in Snowflake also returns null in Databricks SQL.
- [ ] Every converted object is evaluated against its approved rules before acceptance.
- [ ] A rule that needs a business decision is routed to its named owner; it is never guessed.
- [ ] Every accepted change has a record of the source, target, spec revision, checks and decisions.

### Edge Cases

- A converter drops `BEGIN` or `COMMIT` without warning → mark the transaction rule not met and send the change back.
- `TRY_TO_NUMBER` becomes `CAST` and invalid input now raises an error → use null-preserving target semantics or route an explicit rule change to the client.
- A downstream finance report has not been tested → mark it needs a human; do not infer acceptance.
- A source construct has no declared translation check → record it as not declared and assign an owner.

## design.md

### Flow

1. Inventory the source procedure and its dependencies.
2. Recover behavior rules into the Specifica spec.
3. The client approves the rules and names decision owners.
4. An agent or converter produces the Databricks SQL change.
5. The loop evaluates the change against the approved rules.
6. A missed rule goes back with evidence; a judgment call goes to its owner.
7. A passing change keeps the spec revision, inputs and evidence with the pull request.

### Decisions

- The converter writes the first change; it does not decide whether behavior was preserved.
- Each evaluation is pinned to one source version, target change and spec revision.
- Production cutover and rollback remain with the delivery team.

## tasks.md

### Migration order

- [ ] Inventory procedures, dependencies, owners and migration waves
- [ ] Recover and approve behavior rules for wave one
- [ ] Add baseline cases for transactions, invalid input and downstream reports
- [ ] Convert each procedure to Databricks SQL in a separate change
- [ ] Evaluate every change and correct rules that are not met
- [ ] Route unresolved decisions and dependencies to their owners
- [ ] Attach the acceptance record to each passing pull request
- [ ] Rehearse cutover and rollback with the delivery team

Optional workflow reference: [Cognium Autonomous Loop](https://cognium.net/how-it-works/). Related applied workflow: [Databricks migration](https://cognium.net/packs/databricks-migration/).
