-
Notifications
You must be signed in to change notification settings - Fork 35
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 several methods to use string cache #361
Conversation
@etiennebacher I think we can just merge this one in as is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sorhawell thanks! I tweaked the docs a bit, nothing major. I just have one question regarding #234: it looks like I can make it work if I use pl$enable_string_cache()
before creating the DataFrame
pl$enable_string_cache(TRUE)
pl_letters_cat <- pl$DataFrame(list(a = factor(letters[1:3])))
pl_letters_cat$filter(
pl$col("a")$is_in(pl$lit("a"))
)
shape: (1, 1)
┌─────┐
│ a │
│ --- │
│ cat │
╞═════╡
│ a │
└─────┘
but after resetting the cache to FALSE
and creating the DataFrame in pl$with_string_cache()
doesn't seem to work:
pl$with_string_cache({
pl_letters_cat <- pl$DataFrame(list(a = factor(letters[1:3])))
})
pl_letters_cat$filter(
pl$col("a")$is_in(pl$lit("a"))
)
Error: Execution halted with the following contexts
0: In R: in $collect():
0: During function call [pl_letters_cat$filter(pl$col("a")$is_in(pl$lit("a")))]
1: Encountered the following error in Rust-Polars:
joins/or comparisons on categoricals can only happen if they were created under the same global string cache
How should I use pl$with_string_cache()
?
My bad, I just saw that the whole thing should be in pl$with_string_cache({
pl_letters_cat <- pl$DataFrame(list(a = factor(letters[1:3])))
pl_letters_cat$filter(
pl$col("a")$is_in(pl$lit("a"))
)
})
shape: (1, 1)
┌─────┐
│ a │
│ --- │
│ cat │
╞═════╡
│ a │
└─────┘ |
Close #350, close #234