-
Notifications
You must be signed in to change notification settings - Fork 121
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
Additional temporal arithmetic #696
Merged
josevalim
merged 28 commits into
elixir-explorer:main
from
billylanchantin:date-diff-and-cleanup
Aug 29, 2023
Merged
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d85c4ff
consistent newlines above return
billylanchantin 51f9fd0
Merge branch 'main' into date-diff-and-cleanup
billylanchantin 4b1c6fc
first pass at redoing arithmetic operations
billylanchantin 3c5b71b
minor error message change
billylanchantin f4800dc
add types
billylanchantin 849d3ad
add/2 related tests
billylanchantin 2c94cc1
fix default precision for date - date
billylanchantin 95908af
subtract/2 tests
billylanchantin e26d0ae
more coverage for duration-only arithmetic
billylanchantin a452658
allow multiplying durations and floats
billylanchantin 15b65c8
multiplication tests
billylanchantin aeafe8f
support divide by float
billylanchantin be71f9a
need to cast on divide too
billylanchantin cbc69e2
use consistent comment
billylanchantin 12b50ad
divide tests
billylanchantin 3445824
reuse error format
billylanchantin a843db9
remove unused module attribute
billylanchantin d97a44a
fix dialyzer warning
billylanchantin 8672d16
centralize dtype logic
billylanchantin 0861619
Merge branch 'main' into date-diff-and-cleanup
billylanchantin 093e9ce
move arithmetic casting logic to shared
billylanchantin d940a3d
move argument swap for add/2 into rust
billylanchantin 2dbf652
swap in Elixir instead
billylanchantin 75d8a78
move multiply & divide workarounds to polars backend
billylanchantin 25d0610
move defp contents into def
billylanchantin 66a317f
failed attempt at arg-swapping expressions
billylanchantin 50d4e3a
allow duration scalars in expressions
billylanchantin b751989
remove expression fix attempt; keep but skip tests
billylanchantin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Perhaps the best place to swap args is in expression.ex. In there we convert all lazy frame operations into Polars expressions, so you can override
add
,multiply
, and friends in there to both swap and post-cast.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.
I tried there initially, but lazy series didn't seem to contain the dtype information I needed to make decisions about whether to swap, cast, etc.
E.g. if we add this custom
to_expr
clause for add:We see the following after running
df1 = DF.mutate(df, add1: sub + aug_20)
:I don't know the dtypes of those args, so I don't know if I should swap or not.
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.
GAH. Does it work in expression.rs? Can we fetch the dtype there and swap there?
If not, we would need to start storing the dtype then... it is more work though, so it probably makes sense to break this apart, add the dtype field to lazy series, and then come back to this. If we indeed can't do it in Rust, then we should merge a subset of this PR that doesn't require the arg swapping, and work on the other fix later.
I guess there is always the option of fixing Polars too.
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.
I don't think so? I'll try to check more thoroughly later today tho. Polars expressions weren't super well documented so I'll have to read some source code.
Do you mean supporting
Explorer.Series.add(duration, date)
a letting a lazy expression possibly panic? Or droppingduration + date
support altogether until we can address the issue?You read my mind...
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.
I meant adding a field called dtype to
Explorer.Backend.LazySeries
. If we do this though, I would make it so we change all Explorer.Backends.Series callbacks to receive the output dtype as argument (or anout_series
, which has the correct result type, like we do for dataframes).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.
Sorry I meant what should we do for this PR? Definitely coming back later and adding the dtype info we need to make decisions sounds good.
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.
For this PR, let's only support the dtype pairs we can implement today (without changing polars or without changing lazy series). Or do you mean we cannot support any of them? :D
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.
Actually, let's keep the arg swap in
Explorer.Series
for now. It is not ideal but it is semantically fine. We can add a TODO to them.For the integer vs duration, which requires the post cast, we can pre-cast the integer to duration, right?
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.
👍
No,
duration * duration
isn't supported. I think only way to do it is post-cast.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.
I honestly think opening up a PR in Polars might be the least painful way accomplish this 😅