Conversation
extract_columns accepts columns as plain names or as (name, doc) tuples.
The fill_with path looped over the raw arguments, so with tuples it
checked `("b", "doc") in df`, added a junk column named after the tuple,
and never filled `b`. Requesting `b` then failed with "No such column".
Fill using the column names only, in both the sync and async generators.
Generated-by: Claude Code (Claude Opus 5.5)
This branch has not been deployed
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.
@extract_columnsaccepts columns as plain names or as(name, doc)tuples. Withfill_with=set, the filler looped over the raw arguments, so documented columns were never filled. It checked("b", "doc b") in df, added a junk column named after the whole tuple, and leftbmissing. Requestingbthen failed.The same call with plain names (
extract_columns("a", "b", fill_with=0)) works.Changes
hamilton/function_modifiers/expanders.py:extract_columns.transform_nodecomputes the column names once (unwrapping(name, doc)tuples, as the extractor loop below already does). The sync and asyncdf_generators use those names to fill missing columns.tests/function_modifiers/test_expanders.py: two regressions (sync and async) forfill_withwith documented columns.How I tested this
main(661aa888): both fail. Sync: the dataframe columns are['col_1', ('col_1', 'col_1 doc'), ('col_3', 'col_3 doc')]instead of['col_1', 'col_3']. Async fails the same way.pytest tests/function_modifiers tests/test_function_modifiers.py tests/test_end_to_end.py tests/test_hamilton_driver.py tests/test_async_driver.py: 529 passed.ruff checkandruff format --check(0.15.14, the pre-commit version) are clean on the changed files.git diff --checkis clean.Notes
The filler has iterated over
self.columnslike this since at least 0857e5d (2023-03).Checklist
AI disclosure (per the ASF Generative Tooling guidance): this change was written with an AI coding tool (Claude Code, Claude Opus 5.5) working through the
breken-aiaccount. The tool found the bug, wrote the fix and the test, and wrote this description. The commit carries aGenerated-by:trailer. The diff is a small original change to existing Hamilton code and includes no third-party material. The red/green runs above are real and can be re-run from the diff. If you would rather not take AI-assisted contributions here, say so and I will close this.