fix: prioritize @EACH lambda params over column name conflicts#5769
Open
MubinUmarov wants to merge 2 commits intoSQLMesh:mainfrom
Open
fix: prioritize @EACH lambda params over column name conflicts#5769MubinUmarov wants to merge 2 commits intoSQLMesh:mainfrom
MubinUmarov wants to merge 2 commits intoSQLMesh:mainfrom
Conversation
When a lambda parameter name matched an existing column name, the substitution was silently skipped due to the `not isinstance(node.parent, exp.Column)` guard wrapping both `args` and `evaluator.locals` lookups. Lambda arguments now take priority regardless of Column context, while `evaluator.locals` substitution remains restricted to non-Column nodes. Fixes SQLMesh#5582 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tobymao
approved these changes
Apr 19, 2026
Contributor
|
@MubinUmarov thanks, please fix the build |
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.
Summary
@EACH()failure when the lambda parameter name matches an existing column nameargs) now take priority over Column context checksevaluator.localssubstitution remains restricted to non-Column nodes (unchanged behavior)Root Cause
In
_norm_var_arg_lambda(sqlmesh/core/macros.py), thesubstitutefunction wrapped bothargsandevaluator.localslookups insideif not isinstance(node.parent, exp.Column). This caused the lambda parameter to be silently skipped when it appeared as a column reference.Test plan
tests/core/test_macros.pycovering@EACHwith lambda parameter names that conflict with column namestest_macros.pypassFixes #5582
🤖 Generated with Claude Code