Repository navigation
Conversation
A target with schema = "preserve" keeps each model's own schema, but SQLBuild used "preserve" literally for the tables it writes for itself: every Snowflake build created a PRESERVE schema for _sqlbuild_resource_costs, and query-mode sqb diff, review markers and the janitor used it too. TargetSettingsValues::own_table_locations now resolves one location for these tables: the target's loader_schema, else the adapter's default schema, else S105 before running anything. Cost publication, query-diff scratch tables, review ownership markers and the janitor's artifact and review-schema lookups use it. BREAKING CHANGE: on a preserve target, _sqlbuild_resource_costs, query-diff scratch tables and review markers move to loader_schema, or the adapter's default schema. Adapters without one (Snowflake, BigQuery, Databricks) need targets.<name>.loader_schema for a query diff or review, and on Snowflake for every build; otherwise they fail with S105. Cost rows recorded earlier stay in the old preserve schema.
…ng to run pass S105 for SQLBuild's own tables now names the target, says its adapter has no default schema, and gives the fix: add loader_schema = "..." to that target. A build with no executable work records no costs, so it no longer needs a schema for them. Covered by a unit test of the Snowflake message, a query diff with the real Snowflake adapter that stops before connecting, and a no-work build on a preserve target.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
On a
schema = "preserve"target, SQLBuild usedpreserveliterally as the schema for its own tables. Every Snowflake build ranCREATE SCHEMA IF NOT EXISTS <db>.preservefor_sqlbuild_resource_costs. Query-modesqb diffput its scratch tables there, or failed when the schema was missing. Review markers and the janitor looked there too.Changes
TargetSettingsValues::own_table_locations, one resolver for SQLBuild's own tables. Withpreserveit usesloader_schema, then the adapter's default schema, else stops withS105before running anything. It never resolves topreserve.Verification
loader_schema, the adapter default, andS105for build and diff. A build with nothing to run passes. Nopreserveschema is left.S105before connecting; a unit test checks the exact message.loader_schemaandpublic.BREAKING CHANGE: Snowflake targets with
schema = "preserve"now needloader_schema. Snowflake has no default schema, so without it any build with work to run, a query diff or a review stops withS105before running anything; addloader_schema = "..."to the target. On everypreservetarget,_sqlbuild_resource_costs, query-diff scratch tables and review markers move toloader_schema, or else to the adapter's default schema. Cost rows recorded earlier stay in the oldpreserveschema.