From 8fb8ad19d5c5db589e8d7cba5e8c4bee39136f26 Mon Sep 17 00:00:00 2001 From: Elazar Lachkar Date: Wed, 3 Jun 2026 12:25:33 +0000 Subject: [PATCH] fix: add explicit return(none) in get_elementary_relation when relation not found The v0.24.0 refactoring (PR #1006) added a deferral fallback but removed the unconditional return of adapter.get_relation()'s result. When the adapter returns None and deferral is off, the macro now falls through without calling return(). In dbt's Jinja2, this means the macro returns its rendered template text (whitespace) instead of None. Since a non-empty string is truthy, callers that check `if relation` incorrectly proceed as if the table exists, producing SQL like `from ` which causes BigQuery syntax errors. Add an explicit `return(none)` at the end to restore the v0.23.1 contract: when a relation is not found and deferral is not active, the macro returns None. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- macros/utils/graph/get_elementary_relation.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/macros/utils/graph/get_elementary_relation.sql b/macros/utils/graph/get_elementary_relation.sql index 76b99d65d..2ddf7d2f5 100644 --- a/macros/utils/graph/get_elementary_relation.sql +++ b/macros/utils/graph/get_elementary_relation.sql @@ -47,5 +47,6 @@ ) ) %} {% endif %} + {% do return(none) %} {%- endif %} {% endmacro %}