fix: Synthesize category names for nested columns - #403
Merged
Merged
Conversation
Oliver Borchert (borchero)
requested review from
Andreas Albert (AndreasAlbertQC) and
Daniel Elsner (delsner)
as code owners
September 16, 2026 00:02
Copilot started reviewing on behalf of
Oliver Borchert (borchero)
September 16, 2026 00:03
View session
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #403 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 46 46
Lines 2598 2615 +17
=========================================
+ Hits 2598 2615 +17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The categorical test has unresolved assertion-coverage and testing-convention issues.
Pull request overview
Fixes schema-scoped names for nested physical categorical dtypes through recursive column binding.
Changes:
- Recursively binds nested list, array, and struct columns.
- Copies nested definitions to isolate metadata.
- Expands categorical naming tests and documentation.
File summaries
| File | Summary |
|---|---|
tests/column_types/test_categorical.py |
Adds nested naming coverage; test setup and accessor assertions need refinement. |
dataframely/columns/struct.py |
Recursively binds struct fields. |
dataframely/columns/list.py |
Recursively binds list elements. |
dataframely/columns/categorical.py |
Documents nested categorical naming. |
dataframely/columns/array.py |
Recursively binds array elements. |
dataframely/columns/_base.py |
Defines nested binding behavior. |
dataframely/_base_schema.py |
Uses recursive column binding. |
Review details
Suppressed comments (2)
tests/column_types/test_categorical.py:39
- Because both tuple entries reference the same mutable top-level
Column,TestSchema.columns()rebinds the object before the loop starts. The assertions therefore only exercise the final binding and cannot detect a regression in either access path independently; invoke and assert each accessor before invoking the other (for example, iterate over lambdas).
for bound_column in (TestSchema.a, TestSchema.columns()["a"]):
dtype: PolarsDataType = bound_column.dtype
while isinstance(dtype, pl.List | pl.Array | pl.Struct):
dtype = (
dtype.fields[0].dtype if isinstance(dtype, pl.Struct) else dtype.inner
tests/column_types/test_categorical.py:35
- This new test does not separate its setup, dtype evaluation, and assertions into the required Arrange/Act/Assert blocks. Please mark those phases explicitly and keep the assertions in the Assert block so the test follows the repository testing convention.
def test_synthesized_categories_name(column: dy.Column, expected_name: str) -> None:
class TestSchema(dy.Schema):
a = column
for bound_column in (TestSchema.a, TestSchema.columns()["a"]):
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Motivation
Nested categoricals specified with a physical dtype do not receive a schema or column name. For example,
dy.List(dy.Categorical(pl.UInt16))raises an assertion when its dtype is accessed;UInt32silently uses global categories.