Publish a custom query table version
What It Does
A staff author saves custom-table SQL and a permitted publisher requests its release. Removing an assignment can make dependent saved questions stop resolving.
The Flow
Save authored SQL, reviewed columns and defaults with the version previously read. Parse SQL with PostgreSQL grammar, reject disallowed constructs and sources, derive canonical SQL and fingerprint, and analyze in the validation workspace. Preview the chosen version in the configured validation workspace and return release-check information. Compare released and proposed output shape, identify breaking changes and enumerate saved-query dependants. Verify matching analysis and non-null unique record identity, then promote the draft, supersede the old version, create another draft and record release history. Apply inclusion, exclusion or released-version pin assignments with version checks and description-stamp updates.
When Something Fails
Return a conflict when the version has changed. A refused stale save does not replace the draft. Keep structured analysis problems; missing validation configuration refuses the operation. A draft without passing matching analysis cannot be published. Refuse an unavailable validation workspace or unsupported customer-workspace preview. Only preview history can be retained; no publication is implied. Refuse publication without the required dependency acknowledgements. The existing released version remains selected. Refuse failed checks or roll back the publication transaction. No partial publication is committed by that transaction. Refuse stale assignment writes. A successful assignment can change which workspaces resolve the dataset.
Idempotency and Concurrency
Analysis of the same SQL can produce the same canonical content, but saving is still a versioned write. Repeating an already committed publication with its old version conflicts. Definition locks and read versions coordinate draft, publication and assignment changes. Cross-workspace dependency inspection is limited to identifying affected saved queries.