-
Notifications
You must be signed in to change notification settings - Fork 122
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
[Proof of concept] Expr serialize #916
Conversation
I am not sure we should go down this route because this is serializing an internal representation, right? So there is no guarantee that, once a new Polars version lands, the JSON representation (keys and values) will remain relevant? I think relying on their SQL API should be slightly more stable, because that's a public API? |
The API is public:
And they don't say you can't rely on it. But I think you're likely correct regardless. Looking at the example JSON from my test, it seems they're including a lot of what looks like internal stuff. In theory if a particular representation breaks, a user could just get the new JSON from the new version of Polars. I'd be ok with that since this is supposed to be a backdoor. But I take your point!
That's true. However their docs say:
So I'm not sure exposing the SQL API would also expose the expressions we want, especially since:
But we should definitely pursue the SQL API regardless. How cool would it be for Still, I don't think the SQL API gets us the expressiveness I'm going for. But not exposing an API because it's internal/unreliable is potentially a deal breaker, so great feedback. |
The API is public but I am not sure if its output are guaranteed to be stable across versions. For example, it could be used to serialize expressions across nodes for the same Polars versions, but not guarantees across different ones. If Polars had an API for building an expression from a SQL fragment, that would be ideal. |
Seems like they do! |
@billylanchantin YES!!! |
@josevalim Ok I can close this and start working on exposing a SQL-to-exprs pipeline :) FYI you made a good point here: #818 (comment) But maybe viewing the SQL as somewhat of an escape hatch changes things a bit? |
Exactly. To me, the main question is if we can provide a consistent behaviour across backends. For example, if we have a Postgres backend, would this feature also make sense there? And I think it would, so let's go for it. |
Closing in favor of: #918 |
🚧 Do not merge
This PR is only a proof of concept.
Description
Adds
expr_to_json
andexpr_from_json
.The idea is to provide an escape hatch for Polars functionality we don't yet support. Included is a test case demonstrating that it's possible.
Discussion
Explorer can lag behind what's available in Polars. This functionality would allow users to opt into behavior not otherwise available. My hope is that we can turn this idea into something like
Ecto.Query.API.fragment/1
.This approach is messy for a few reasons:
But for that price, we instantly open up all expression-based operations. Please let me know if you think!