Fix dependency-name computation in schema-apply ordering#12
Merged
Conversation
Two real bugs in how _iter_sql_files/_get_sql_deps compute the name a file is tracked under, both silently degrading dependency ordering to "untracked -> assumed already satisfied" instead of an actual wait: - _get_sql_deps used str(t) on a matched Table node, which includes the alias for an aliased reference (e.g. "FROM app.visit v" -> "app.visit AS v"). That never matches the plain name a dependency's own CREATE target is recorded under. Use exp.table_name(t) instead. - _iter_sql_files derived a file's own declared name from the raw file stem, so a numeric ordering prefix (e.g. "0_visit_unified.sql") landed in all_declared as "schema.0_visit_unified" instead of "schema.visit_unified" -- never matching what any dependent file's SQL actually references. Strip it the same way the schema-directory name already is. apply_schema()'s retry-until-no-progress loop (this version) still converges even with these bugs present, since it retries raw SQL execution directly rather than relying on this bookkeeping - but the computed ordering itself was wrong, causing avoidable extra retry passes.
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.
Two real bugs in how _iter_sql_files/_get_sql_deps compute the name a file is tracked under, both silently degrading dependency ordering to "untracked -> assumed already satisfied" instead of an actual wait:
apply_schema()'s retry-until-no-progress loop (this version) still converges even with these bugs present, since it retries raw SQL execution directly rather than relying on this bookkeeping - but the computed ordering itself was wrong, causing avoidable extra retry passes.