Fix node resolution on dbt Fusion (missing version kwarg resolves to '' instead of None) - #226
Open
allllllllez wants to merge 1 commit into
Open
Conversation
… dbt Fusion kwargs["version"] | default(kwargs["v"]) | default(none) relies on Jinja2's Undefined semantics for a missing kwarg key. On dbt Fusion, indexing a missing kwargs key does not produce Undefined, so it survives as '' and default(none) never fires. has_value() then treats '' as "a version was given", filters the graph node by version=='', and finds nothing since real unversioned models have version=None. Affects overrides.sql's ref() override (hit by every test via ref_tested_model), tests.sql's test(), and mock_builders.sql's mock_ref(). Fixes EqualExperts#225
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.
Fix node resolution on dbt Fusion (missing
versionkwarg resolves to''instead ofNone)Fixes #225
Problem
Every
dbt_unit_testing.test()fails on dbt Fusion withNode ... not found.. The graphlookup in
macros/utils.sql(model_node) is not at fault —graphis fully populated andthe target node matches correctly. The actual cause is that
node.versionends up as''instead of
Nonewhen noversion/vkwarg is passed.has_value()treats''as "aversion was requested", filters by
version == '', and finds nothing since real unversionedmodels have
version == None.Three call sites share the same fragile pattern, which relies on dbt Core's Python Jinja2
Undefinedsemantics for a missingkwargskey — a dependency Fusion's Jinja implementationdoesn't honor the same way:
Change
Replace the bracket-index +
default()chain withkwargs.get("x", kwargs.get("y", none))in:macros/overrides.sql(ref()override — hit by every single test viaref_tested_model())macros/tests.sql(dbt_unit_testing.test())macros/mock_builders.sql(mock_ref())No change to
macros/utils.sql— the graph lookup itself was already correct.Verification
Using this repo's
integration-tests/suite (31dbt_unit_testing.test()cases), on branchfix/fusion-kwargs-default-empty-string:2.0.0-preview.205(Postgres, experimental adapter)Node ..._v not found)[DbDriverFailed] HTTP error: io: No route to host— an unrelated connectivity limitation of Fusion's experimental postgres adapter, not a render/Jinja error1.7.11(existing test matrix, Postgres)1.12.3(latest available viapip install dbt-postgres==1.11.0, Postgres)run-integration-tests.shpasses, no regressionFull reproduction/verification commands are in #225.