fix: prioritize @EACH lambda params over column name conflicts by MubinUmarov · Pull Request #5769 · SQLMesh/sqlmesh
Summary
- Fixed silent
@EACH()failure when the lambda parameter name matches an existing column name - Lambda arguments (
args) now take priority over Column context checks evaluator.localssubstitution remains restricted to non-Column nodes (unchanged behavior)
Root Cause
In _norm_var_arg_lambda (sqlmesh/core/macros.py), the substitute function wrapped both args and evaluator.locals lookups inside if not isinstance(node.parent, exp.Column). This caused the lambda parameter to be silently skipped when it appeared as a column reference.
Test plan
- Added two test cases to
tests/core/test_macros.pycovering@EACHwith lambda parameter names that conflict with column names - All 138 tests in
test_macros.pypass
Fixes #5582
🤖 Generated with Claude Code