Skip to content

Commit a9e829a

Browse files
committed
PR feedback
1 parent b06de10 commit a9e829a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

sqlmesh/core/model/common.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ def _extract_macro_func_variable_references(macro_func: exp.Expression) -> t.Set
164164
# they will be handled in a separate call of _extract_macro_func_variable_references.
165165
def _prune_nested_macro_func(expression: exp.Expression) -> bool:
166166
return (
167-
type(n) is d.MacroFunc
168-
and n is not macro_func
169-
and n.this.name.lower() not in (c.VAR, c.BLUEPRINT_VAR)
167+
type(expression) is d.MacroFunc
168+
and expression is not macro_func
169+
and expression.this.name.lower() not in (c.VAR, c.BLUEPRINT_VAR)
170170
)
171171

172172
for n in macro_func.walk(prune=_prune_nested_macro_func):
@@ -208,6 +208,9 @@ def _add_variables_to_python_env(
208208
used_variable_referenced_in_metadata_expression.get(var_name, True) and is_metadata
209209
)
210210

211+
# Variables are treated as metadata when:
212+
# - They are only referenced in metadata-only contexts, such as `audits (...)`, virtual statements, etc
213+
# - They are only referenced in metadata-only macros, either as their arguments of within their definitions
211214
metadata_used_variables = set()
212215
for used_var, macro_names in (macro_funcs_by_used_var or {}).items():
213216
if used_variable_referenced_in_metadata_expression.get(used_var) or all(

0 commit comments

Comments
 (0)