Abhi2939 opened a new pull request, #41105:
URL: https://github.com/apache/beam/pull/41105
Addresses #41077.
`_expand_python_mapping_func` bound every input field whose name appeared as
a substring of the expression, so a field named `in` produced `in =
__row__.in`, which is a `SyntaxError`. This change binds only fields whose
names are valid, non-keyword identifiers (`name.isidentifier() and not
keyword.iskeyword(name)`). Unreferenced keyword-named fields can no longer
break an otherwise valid expression.
**Reproduction caveat:** I could not reproduce this end to end on master
(Python 3.12.3, commit 84a02fe905c). A schema containing a keyword-named field
is rejected earlier: `Create` and `MapToFields` both fail with `ValueError:
Type names and field names cannot be a keyword: 'in'`, raised from
`named_tuple_from_schema`. The generator flaw is real when called directly, so
the new unit tests call `_expand_python_mapping_func` directly rather than
running a pipeline. This is therefore a defensive fix. I'm happy to adjust or
close this if a different approach is preferred, and I'd be glad to hear of any
input path that does reach `Filter` with such a field.
The Java `JavaRowUdf` substring check mentioned in the issue is out of scope.
**Tests:** three unit tests in `yaml_mapping_test.py` (keyword-named field,
non-identifier field, and a control showing ordinary fields are still bound).
The first two fail without the fix.
------------------------
Thank you for your contribution! Follow this checklist to help us
incorporate your contribution quickly and easily:
- [x] Mention the appropriate issue in your description (`addresses
#41077`).
- [x] Replace these instructions with a description of your change and why
you have made it.
- [ ] Update `CHANGES.md` with noteworthy changes. (Not done: this is a
small defensive fix; happy to add an entry if maintainers want one.)
- [ ] If this contribution is large, please file an Apache Individual
Contributor License Agreement. (Not applicable: small change.)
See
[CONTRIBUTING.md](https://github.com/apache/beam/blob/master/CONTRIBUTING.md)
for more details.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]