Skip to content

RootModel entry points produce a spurious root column and go undocumented #593

Description

Summary

PR #590 (closing #583) unwrapped RootModel-typed fields to their bare root shape. A RootModel registered as a top-level entry point is still mishandled: extract_model_spec extracts it as a top-level RecordSpec, producing a spurious root column in the generated Spark schema, and the markdown reference omits it entirely.

Behavior

A RootModel entry point has no record structure of its own -- it serializes as its bare root value, a named alias over that shape like a NewType. Two problems follow.

Expression generation emits a struct with a synthetic root column -- the same wrong shape #583 described, one level up at the entry-point boundary rather than at a field.

Markdown generation drops it entirely: a RootModel is a named alias readers still need documented, but it reaches the markdown pipeline through no field tree, since a RootModel field unwraps to its bare shape and names no type.

Expectation

Skip RootModel entry points from expression generation -- an entry point is a contribution mechanism (a type usable as a field elsewhere), not only a top-level record to generate.

Document a RootModel entry point in markdown as a type alias over its bare root shape, reusing the NewType page since both are named aliases over an underlying shape.

Edge case

A self-referential RootModel (RootModel[list["Self"]]) has no finite bare shape and no node to carry a cycle back-edge, so the bare-shape unwrap recurses forever and surfaces as an opaque RecursionError. It should fail with a clear error instead.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions