Skip to content

Nullable column missing fails validate(..., cast=True) #253

Open

Description

If a column is nullable, why do we not allow dataframely to create the column if it doesn't exist yet (filled with nulls) when casting? I realise you've probably thought about this but I couldn't find an explicit mention of this in the docs or GitHub issues.

import dataframely as dy
import polars as pl

class TableSchema(dy.Schema):
    column_a = dy.String(nullable=False)
    column_b = dy.String(nullable=True)

df = pl.DataFrame({"column_a": 0})
TableSchema.validate(df, cast=True)

# Raises SchemaError
# SchemaError: 1 missing columns for schema 'TableSchema': 'column_b'

Activity

  1. borchero commented on Jan 11, 2026

    @borchero
    Member

    One key design decision in dataframely today is that is doesn't ever alter inputs to validate. We are currently re-evaluating this decision though (also in the context of #237) and will revisit this once we've reached a conclusion :)

  2. brendancooley commented on Jan 18, 2026

    @brendancooley

    One key design decision in dataframely today is that is doesn't ever alter inputs to validate. We are currently re-evaluating this decision though (also in the context of #237) and will revisit this once we've reached a conclusion :)

    Is this in tension with the behavior noted by Ion Koutsouris (@ion-elgreco) in #258 (silently dropping extraneous columns)? Should operations that mutate the data frame be handled explicitly by different methods? filter, derive, etc?

  3. borchero commented on Jan 18, 2026

    @borchero
    Member

    Yeah, definitely related, there is also #100... all of those are in the same vein and likely warrant an extension to the API in one or multiple ways

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