Skip to content

fix: Synthesize category names for nested columns - #403

Merged
Oliver Borchert (borchero) merged 1 commit into
mainfrom
fix/nested-categorical-names
Sep 16, 2026
Merged

Oliver Borchert (borchero) merged 1 commit into
mainfrom
fix/nested-categorical-names

Conversation

@borchero

@borchero Oliver Borchert (borchero) commented Sep 16, 2026

Copy link
Copy Markdown
Member

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; UInt32 silently uses global categories.

Copilot AI lite review requested due to automatic review settings September 16, 2026 00:02
@github-actions github-actions Bot added the fix label Sep 16, 2026
@borchero Oliver Borchert (borchero) changed the title fix: synthesize category names for nested columns fix: Synthesize category names for nested columns Sep 16, 2026
@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9271774) to head (cda0aec).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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.

@borchero
Oliver Borchert (borchero) merged commit a823755 into main Sep 16, 2026
34 of 36 checks passed
@borchero
Oliver Borchert (borchero) deleted the fix/nested-categorical-names branch September 16, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants