-
Notifications
You must be signed in to change notification settings - Fork 605
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
feat(api): support deferred expressions in ibis.date
/ibis.time
/ibis.timestamp
#7204
Merged
Conversation
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
A quick demo: In [1]: import ibis
In [2]: ibis.options.interactive = True
In [3]: from ibis import _
In [4]: t = ibis.memtable({"h": [1, 4], "m": [2, 5], "s": [3, 6]})
In [5]: t.mutate(time=ibis.time(_.h, _.m, _.s)) # time column from components
Out[5]:
┏━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━┓
┃ h ┃ m ┃ s ┃ time ┃
┡━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━┩
│ int64 │ int64 │ int64 │ time │
├───────┼───────┼───────┼──────────┤
│ 1 │ 2 │ 3 │ 01:02:03 │
│ 4 │ 5 │ 6 │ 04:05:06 │
└───────┴───────┴───────┴──────────┘
In [6]: t.mutate(timestamp=ibis.timestamp(2023, 1, 2, _.h, _.m, _.s)) # timestamp column from components
┏━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ h ┃ m ┃ s ┃ timestamp ┃
┡━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ int64 │ int64 │ int64 │ timestamp │
├───────┼───────┼───────┼─────────────────────┤
│ 1 │ 2 │ 3 │ 2023-01-02 01:02:03 │
│ 4 │ 5 │ 6 │ 2023-01-02 04:05:06 │
└───────┴───────┴───────┴─────────────────────┘ |
gforsyth
approved these changes
Sep 25, 2023
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.
Very minor nit -- definitely not blocking.
This is very nice and the function argument restrictions are well done.
cpcloud
added
feature
Features or general enhancements
ux
User experience related issues
timestamps
Issues related to the timestamp API
labels
Sep 25, 2023
Went ahead and committed the suggested error message, so we can merge this! |
Oh bother, pre-commit 😒 |
Co-authored-by: Gil Forsyth <[email protected]>
cpcloud
force-pushed
the
deferred-date-time
branch
from
September 27, 2023 16:28
c234df0
to
a00dd26
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
feature
Features or general enhancements
timestamps
Issues related to the timestamp API
ux
User experience related issues
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.
This PR does a few things:
ibis.date
/ibis.time
/ibis.timestamp
deferrable
decorator (non-public) for wrapping top-level expr functions and making them work with deferred arguments.ibis.date
/ibis.time
/ibis.timestamp
ibis.date
/ibis.time
/ibis.timestamp
. In particular, now mypy/pyright will complain if you don't pass in all components required or the components are the incorrect type. It also fixes the return type to indicate it's not always a scalar.Fixes #4534.