Skip to content

dy.Schema.cast shouldn't cast valid dtype. #318

@gab23r

Description

@gab23r

In the following snippet, I would expect the cast call to be a no-op as pl.Int32 is already a valid dy.Integer.

This is related to this issue #314

import dataframely as dy
import polars as pl

class S(dy.Schema):
    a = dy.Integer()

df = pl.DataFrame({"a": range(10)}, schema=({"a": pl.Int32}))

# `pl.Int32` is a valid dtypes for `dy.Integer`
S.a.validate_dtype(df.schema["a"])

# but it got casted to `pl.Int64`
S.cast(df).schema
# Schema([('a', Int64)])

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