pola-rs / r-polars

Bring polars to R
https://pola-rs.github.io/r-polars/
Other
426 stars 38 forks source link

Add `as_polars_lit` and `as_polars_expr` #835

Open eitsupi opened 4 months ago

eitsupi commented 4 months ago

Related to #599, #570, #715

etiennebacher commented 4 months ago

So basically you'd want to do the conversion to expressions in R rather than in Rust? Like the parse_* functions in Python? https://github.com/pola-rs/polars/blob/740e740d9ce3678ea061d5cb4c2bc94892838383/py-polars/polars/utils/_parse_expr_input.py

That would be a massive change internally. On the R side we also have wrap_e() that is used sometimes. Whether we choose to do the conversion to Expr on the R side or on the Rust side, I agree it would be good to harmonize this. This is also related to #422

eitsupi commented 4 months ago

For example, the process of casting something like the Then class to Expr is currently handled by the match arm on the Rust side and cannot be added outside of this Rust crate. https://github.com/pola-rs/r-polars/blob/a65ae54593ca495e568a48bcbc842d8b44ae0761/src/rust/src/lazy/dsl.rs#L164-L166

I think this should be defined in a generic function on the R side. However, this would be a rather extensive change, so we did not make that change in #836.