Keep the id of List and LargeList features when visiting them - #8389
Open
LeSingh1 wants to merge 1 commit into
Open
Keep the id of List and LargeList features when visiting them#8389LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
`_visit()` and `_visit_with_path()` rebuild `List` and `LargeList` in order to
recurse into the inner feature, but they did not carry `id` over, so it was
silently reset to None. Every other feature type is passed through untouched
and keeps its `id`.
`Features.__init__` runs `_visit()` on every column (to convert the legacy
`[feature]` syntax to `List`), so this was reachable from plain user code:
>>> Features({"a": Value("int32", id="my feature")})["a"].id
'my feature'
>>> Features({"a": List(Value("int32"), id="my feature")})["a"].id
None
Pass `id` through in both visitors so list features behave like the rest.
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.
_visit()and_visit_with_path()rebuildList/LargeListin order to recurse into the inner feature, but they don't carryidover, so it is silently reset toNone. Every other feature type is passed through untouched and keeps itsid.Features.__init__runs_visit()on every column (to convert the legacy[feature]syntax toList), so this is reachable from plain user code:idis a live, tested concept —tests/features/test_features.pyalready asserts it survives forValue.This passes
idthrough in both visitors so list features behave like the rest. Nested cases are covered too (Features({"a": {"b": List(..., id=...)}})).Added
test_visit_with_list_types_keeps_id, parametrized overList,Listwithlength, andLargeList; all three fail onmainwithassert None == 'my feature'and pass with the change. Regression run acrosstests/features/,tests/test_arrow_writer.py,tests/test_table.py,tests/test_arrow_dataset.pyandtests/test_info.py→ 1150 passed, 129 skipped.