-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add as_polars_expr
#835
Comments
So basically you'd want to do the conversion to expressions in R rather than in Rust? Like the That would be a massive change internally. On the R side we also have |
For example, the process of casting something like the r-polars/src/rust/src/lazy/dsl.rs Lines 164 to 166 in a65ae54
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. |
Seeing that scalar values were starting to get special treatment in upstream, I completely rewrote Since there is no scalar class in R, it seems that This change basically eliminates the need to describe the conversion from R to Polars in each of the two S3 methods, and if only library(neopolars)
lit0 <- pl$lit(hms::hms())
lit1 <- pl$lit(hms::as_hms("12:34:56"))
lit2 <- pl$lit(hms::as_hms(c("12:34:56", "23:45:56")))
lit0
#> Series[literal]
lit1
#> Series[literal].first()
lit2
#> Series[literal]
pl$select(lit0)
#> shape: (0, 1)
#> ┌─────────┐
#> │ literal │
#> │ --- │
#> │ time │
#> ╞═════════╡
#> └─────────┘
pl$select(lit1)
#> shape: (1, 1)
#> ┌──────────┐
#> │ literal │
#> │ --- │
#> │ time │
#> ╞══════════╡
#> │ 12:34:56 │
#> └──────────┘
pl$select(lit2)
#> shape: (2, 1)
#> ┌──────────┐
#> │ literal │
#> │ --- │
#> │ time │
#> ╞══════════╡
#> │ 12:34:56 │
#> │ 23:45:56 │
#> └──────────┘ Created on 2024-09-12 with reprex v2.1.1 |
Finally, it could be converted to Scalar as long as library(neopolars)
lit0 <- pl$lit(hms::hms())
lit1 <- pl$lit(hms::as_hms("12:34:56"))
lit2 <- pl$lit(hms::as_hms(c("12:34:56", "23:45:56")))
lit0
#> Series[literal]
lit1
#> 12:34:56
lit2
#> Series[literal]
pl$select(lit0)
#> shape: (0, 1)
#> ┌─────────┐
#> │ literal │
#> │ --- │
#> │ time │
#> ╞═════════╡
#> └─────────┘
pl$select(lit1)
#> shape: (1, 1)
#> ┌──────────┐
#> │ literal │
#> │ --- │
#> │ time │
#> ╞══════════╡
#> │ 12:34:56 │
#> └──────────┘
pl$select(lit2)
#> shape: (2, 1)
#> ┌──────────┐
#> │ literal │
#> │ --- │
#> │ time │
#> ╞══════════╡
#> │ 12:34:56 │
#> │ 23:45:56 │
#> └──────────┘ Created on 2024-09-22 with reprex v2.1.1 |
Related to #599, #570, #715
The text was updated successfully, but these errors were encountered: