Skip to content

Add cast function for creating logical cast expression #2870

@andygrove

Description

@andygrove

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
When using the dataframe API there is no easy way to cast a column to another type

Describe the solution you'd like
I would like a cast function something like this:

fn cast(expr: Expr, data_type: DataType) -> Expr {
    Expr::Cast {
        expr: Box::new(expr),
        data_type,
    }
}

This would allow me to then write dataframe code like this:

.with_column(
    "unixReviewTimestamp",
    cast(
        col("unixReviewTime"),
        DataType::Timestamp(TimeUnit::Millisecond, None),
    ),
)?

Describe alternatives you've considered
None

Additional context
None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions